You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: jsrc/jtype.h
+10-8Lines changed: 10 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -583,11 +583,12 @@ typedef I SI;
583
583
584
584
// Flags in the AR field of symbol tables
585
585
#defineARNAMED 1 // set in the rank of a named locale table. This bit is passed in the return from jtsyrd1
586
-
#defineARNAMEADDED LPERMANENT // Set in rank when a new name is added to the local symbol table. We transfer the bit from the L flags to the rank-flag
586
+
#defineARNAMEADDEDX LPERMANENTX // 2 Set in rank when a new name is added to the local symbol table. We transfer the bit from the L flags to the rank-flag
587
+
#defineARNAMEADDED (1LL<<ARNAMEADDEDX) // set if this is a cloned local symbol table (in which symbol numbers are invalid)
588
+
#defineARLCLONEDX NMSHAREDX // 4 set if this is a cloned local symbol table (in which symbol numbers are invalid)
589
+
#defineARLCLONED (1LL<<ARLCLONEDX) // set if this is a cloned local symbol table (in which symbol numbers are invalid)
587
590
#defineARLOCALTABLE 16 // Set in rank of all local symbol tables. This indicates that the first hashchain holds x/y info and should not be freed as a symbol
588
591
#defineARLSYMINUSE 32 // This bit is set in the rank of the original symbol table when it is in use
589
-
#defineARLCLONEDX NMSHAREDX // set if this is a cloned local symbol table (in which symbol numbers are invalid)
590
-
#defineARLCLONED (1LL<<ARLCLONEDX) // set if this is a cloned local symbol table (in which symbol numbers are invalid)
591
592
592
593
#defineSFNSIMPLEONLY 1 // to sfn: return simple name only, discarding any locative
593
594
@@ -695,9 +696,10 @@ typedef struct {
695
696
// In all local symbol tables, the first 'hashchain' has the chain numbers for y/x; they are the first symbols in those chains, always permanent
696
697
697
698
#defineLCH (I)1 /* changed since last exec of 4!:5 */
698
-
#defineLCACHED (I)2 // this value is cached in some nameref
699
+
#defineLPERMANENTX 1
700
+
#defineLPERMANENT ((I)1<<LPERMANENTX) // set if the name was assigned from an abandoned value, and we DID NOT raise the usecount of the value (we will have changed INPLACE to ACUC1, though).
699
701
#defineLINFO (I)4 /* locale info */
700
-
#defineLPERMANENT (I)8 // This is a permanent entry in a local symbol table; don't delete, just leave val=0
702
+
#defineLCACHED(I)8 // this value is cached in some nameref
701
703
#defineLWASABANDONEDX 4
702
704
#defineLWASABANDONED ((I)1<<LWASABANDONEDX) // set if the name was assigned from an abandoned value, and we DID NOT raise the usecount of the value (we will have changed INPLACE to ACUC1, though).
703
705
// when the name is reassigned or deleted, we must refrain from fa(), and if the value still has AC=ACUC1, we should revert it to inplaceable so that the parser will free it
@@ -757,16 +759,16 @@ typedef struct{
757
759
758
760
// values in flag:
759
761
#defineNMLOC 1 // direct locale abc_lm_ only one of NMLOC/NMILOC/NMIMPLOC is set
762
+
#defineNMSHAREDX 2
763
+
#defineNMSHARED (1LL<<NMSHAREDX) // This NM is for a locally-defined name and is shared by all references to the name
760
764
#defineNMILOC 2 // indirect locale abc__de__fgh ... only one of NMLOC/NMILOC/NMIMPLOC is set
761
-
#defineNMDOT4 // one of the names m. n. u. v. x. y. */
765
+
#defineNMDOT128 // one of the names m. n. u. v. x. y. */
762
766
#define NMXY 8 // x/y, which must have NAMEBYVALUE set
763
767
#defineNMIMPLOC 16 // this NM block is u./v. only one of NMLOC/NMILOC/NMIMPLOC is set
764
768
#defineNMCACHEDX 5
765
769
#defineNMCACHED (1LL<<NMCACHEDX) // This NM is to cache any valid lookup
766
770
#defineNMCACHEDSYMX 6
767
771
#defineNMCACHEDSYM (1<<NMCACHEDSYMX) // This NM is storing a symbol index, not a pointer to a reference
768
-
#defineNMSHAREDX 7
769
-
#defineNMSHARED (1LL<<NMSHAREDX) // This NM is for a locally-defined name and is shared by all references to the name
Copy file name to clipboardExpand all lines: jsrc/p.c
+14-13Lines changed: 14 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -342,7 +342,7 @@ static A virthook(J jtip, A f, A g){
342
342
// name:: delete the symbol name but not deleting the value. If the usecount of the value is 1 and it is not on the NVR stack, make it inplaceable. Replace the nameref with a tpush or NVR free
343
343
staticInamecoco(Jjt, Ay, Iat, LX*locbuckets, L*s, Asv, L*sympv){F1PREFIP;
344
344
if(((I)jtinplace&JTFROMEXEC))R1;
345
-
Afndst=UNLXAV0(locbuckets); if(unlikely((at&VERB)!=0))fndst=syrdforlocale(y); // get locale to use. This re-looks up global names, but they should be rare in name::
345
+
Afndst=UNLXAV0((LX*)((I)locbuckets&-8)); if(unlikely((at&VERB)!=0))fndst=syrdforlocale(y); // get locale to use. This re-looks up global names, but they should be rare in name::
346
346
LX*asymx=LXAV0(fndst)+SYMHASH(NAV(s->name)->hash,AN(fndst)-SYMLINFOSIZE); // get pointer to index of start of chain; address of previous symbol in chain
347
347
LXnextsymx=*asymx; // symbol number pointed to by asymx, possibly w/permanent indicator
UI4stack0pt=PTMARK; // will hold the EDGE+AVN value, which doesn't change much and is stored late someday combine this with mes (64-bit only)
497
+
// One of the bits of locbuckets gets moved to a register here, so we know register pressure isn't great
497
498
while(1){ // till no more matches possible...
498
499
499
500
// no executable fragment, pull from the queue. If we pull ')', there is no way we can execute
@@ -524,22 +525,22 @@ A jtparsea(J jt, A *queue, I nwds){F1PREFIP;PSTK * RESTRICT stack;A z,*v;
524
525
// To save some overhead, we inline this and do the analysis in a different order here
525
526
// The important performance case is local names with bucket info. Pull that out & do it without the call overhead
526
527
// This code is copied from s.c, except for the symx: since that occurs only in explicit definitions we can get to it only through here
527
-
Ilocstflags=AR(UNLXAV0(locbuckets)); // flags from local symbol table
528
-
L*sympv=JT(jt,sympv);
529
-
if(likely((SGNIF(locstflags,ARLCLONEDX)|(NAV(y)->symx-1))>=0)){ // if we are using primary table and there is a symbol stored there...
528
+
// obsolete I locstflags=AR(UNLXAV0(locbuckets)); // flags from local symbol table
529
+
L*sympv=JT(jt,sympv);// symbol root can change during parse, but not during stacking of a single execution
530
+
if(likely((SGNIF(locbuckets,ARLCLONEDX)|(NAV(y)->symx-1))>=0)){ // if we are using primary table and there is a symbol stored there...
530
531
s=sympv+(I)NAV(y)->symx; // get address of symbol in primary table
531
532
if(unlikely((sv=s->val)==0))goto rdglob; // if value has not been assigned, ignore it
532
533
}elseif(likely(NAV(y)->bucket!=0)){Ibx;
533
534
if(likely(0 <= (bx= ~NAV(y)->bucketx))){ // negative bucketx (now positive); skip that many items, and then you're at the right place. This is the path for almost all local symbols
534
-
s=locbuckets[NAV(y)->bucket]+sympv; // fetch hashchain headptr, point to L for first symbol
535
+
s=((LX*)((I)locbuckets&-8))[NAV(y)->bucket]+sympv; // fetch hashchain headptr, point to L for first symbol
535
536
if(unlikely(bx>0)){NOUNROLLdo{s=s->next+sympv;}while(--bx);} // skip the prescribed number, which is usually 1
536
537
if(unlikely((sv=s->val)==0))goto rdglob; // if value has not been assigned, ignore it
537
538
}else{
538
539
// positive bucketx (now negative); that means skip that many items and then do name search. This is set for words that were recognized as names but were not detected as assigned-to in the definition. This is the path for global symbols
539
540
// If no new names have been assigned since the table was created, we can skip this search, since it must fail (this is the path for words in z eg)
// from here on it is rare to find a name - usually they're globals defined elsewhere
542
-
LXlx=locbuckets[NAV(y)->bucket]; // index of first block if any
543
+
LXlx=((LX*)((I)locbuckets&-8))[NAV(y)->bucket]; // index of first block if any
543
544
Im=NAV(y)->m; C*nm=NAV(y)->s; UI4hsh=NAV(y)->hash; // length/addr of name from name block
544
545
if(unlikely(++bx!=0)){NOUNROLLdo{lx=sympv[lx].next;}while(++bx);} // rattle off the permanents, usually 1
545
546
// Now lx is the index of the first name that might match. Do the compares
@@ -582,8 +583,8 @@ rdglob: ; // here when we tried the buckets and failed
582
583
AAV1(jt->nvra)[jt->parserstackframe.nvrtop++] =sv; // record the place where the value was protected, so we can free it when this sentence completes
583
584
} // if NJA/virtual, leave NVR alone
584
585
}
585
-
}else goto undefname;
586
-
}else goto undefname;
586
+
}else goto undefname;// no val
587
+
}else goto undefname;// no sym
587
588
at|=VERB; // indicate that the symbol was not in the local table
588
589
}
589
590
// end of looking at local/global symbol tables
@@ -699,10 +700,10 @@ endname: ;
699
700
if((UI)(pline>>VJTFLGOK1X)>(UI)PTISNOTASGNNAME(stack[0]))if(likely(PTISM(stackfs[2]))){L*s; // assignment to name; nothing in the stack to the right of what we are about to execute; well-behaved function (doesn't change locales)
700
701
if(likely((AT(stack[0].a))&ASGNLOCAL)){
701
702
// local assignment. To avoid subroutine call overhead, make a quick check for primary symbol
702
-
if(likely((SGNIF(AR(UNLXAV0(locbuckets)),ARLCLONEDX)|(NAV(queue[mes-1])->symx-1))>=0)){ // if we are using primary table and there is a symbol stored there...
703
+
if(likely((SGNIF(locbuckets,ARLCLONEDX)|(NAV(queue[mes-1])->symx-1))>=0)){ // if we are using primary table and there is a symbol stored there...
703
704
s=JT(jt,sympv)+(I)NAV(queue[mes-1])->symx; // get address of symbol in primary table. There may be no value; that's OK
704
705
}else{s=jtprobeislocal(jt,queue[mes-1]);}
705
-
}elses=jtprobeisquiet(jt,queue[mes-1],UNLXAV0(locbuckets)); // global assignment, get slot address
706
+
}elses=jtprobeisquiet(jt,queue[mes-1],UNLXAV0((LX*)((I)locbuckets&-8))); // global assignment, get slot address
706
707
// Don't remember the assignand if it may change during execution, i. e. if the verb is unsafe. For line 1 we have to look at BOTH verbs that come after the assignment
0 commit comments