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
// in this version one value is always written to shape
1419
1419
#defineGACOPYSHAPE(name,type,atoms,rank,shaape) {I *_s=(I*)(shaape); I *_d=AS(name); *_d=*_s; I _r=1-(rank); NOUNROLL do{_s+=SGNTO0(_r); _d+=SGNTO0(_r); *_d=*_s;}while(++_r<0);}
1420
1420
#endif
1421
-
#defineGACOPY1(name,type,atoms,rank,shaape) {I *_d=AS(name); UI _r=(rank); NOUNROLL do{*_d++=1;}while(--_r);} // copy all 1s to shape - rank must not be 0
1421
+
#defineGACOPY1(name,type,atoms,rank,shaape) {UI _r=(rank); NOUNROLL do{AS(name)[_r-1]=1;}while(--_r);} // copy all 1s to shape - rank must not be 0
1422
1422
1423
1423
// GAE executes the given expression when there is an error
Copy file name to clipboardExpand all lines: jsrc/va2.c
+13-11Lines changed: 13 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -44,30 +44,32 @@ static NOINLINE I intforD(J jt, D d){D q;I z; // noinline because it uses so ma
44
44
// we know that AN=1 in a and w, which are FL/INT/B01 types. af is larger arg rank (=rank of result)
45
45
// obsolete I awip=2*SGNTO0(AC(a))+SGNTO0(AC(w)); awip=(awip&(I)jtinplace)+4*((I)jtinplace&3); // abandoned flags from aw; make (assignable),(inplaceable) flags
// obsolete A INLINE jtssingleton(J jt, A a,A w,I ipcaserank){A z;I aiv;void *zv;
49
49
Iawip=2*SGNTO0(AC(a))+SGNTO0(AC(w)); // collect inplaceable status for a and w
50
50
Iopcode=(I)FAV(self)->lu2.lc; // fetch operation#
51
-
void*av=voidAV(a), *wv=voidAV(w); // point to the argument values
52
51
Ijtinplace=(I)jt; jt=(J)(intptr_t)((I)jt&~JTFLAGMSK); // save jt as an I, clear low bits
53
52
// obsolete I zomb=2*(a==jt->zombieval)+(w==jt->zombieval); // see if either arg is being assigned
54
-
Azombv=jt->zombieval; // fetch address of assignand
53
+
Az=jt->zombieval; // fetch address of assignand, which we presumptively make the result
54
+
void*av=voidAV(a), *wv=voidAV(w), *zv; // point to the argument values and result
55
55
Icaseno=(opcode&0x7f)-VA2CBW1111; caseno=caseno<0?0:caseno; caseno=SSINGCASE(caseno,SSINGENC(at,wt)); // case # for eventual switch. Lump all Booleans at 0
56
-
Az=0; void*zv; // pointer to result location
57
56
// if the operation is a rank-0 comparison that can return num[result], don't bother with inplacing. Inplacing would be
58
57
// a potential gain if the result can itself be inplaced, but it is a certain loser when deciding where the result is
59
-
if((opcode>>7)>af)goto nozv; // true if 0x80 (comparison op) and af=0
58
+
if((opcode>>7)>af){z=0; goto nozv;}// true if 0x80 (comparison op) and af=0. Set z=0 as a flag to return num(result)
60
59
// See if we can inplace. We let some chances get away because they aren't worth testing for. There are two main possibilities: assignment (checked above)
61
60
// and abandoned arg (checked presently). If either passes, it must further be not VIRTUAL if assigned (lest it overwrite the backer of a virtual x/y arg)
62
-
// and not AFRO if bare; and never UNINCORPABLE since we may change the type and we don't want callers to bear the burden of checking that. It is possible that
63
-
// one arg would be inplaceable as an assignment and the other as abandoned, but we pick one and live with it.
64
-
if(awip&=jtinplace){z=awip&JTINPLACEW?w:a; if(likely((AFLAG(z)&AFUNINCORPABLE+AFRO)+(af^AR(z))==0))goto getzv;} // block is abandoned inplaceable, not disallowed and correct rank: inplace to it. Priority to w
61
+
// and not AFRO if bare; and never UNINCORPABLE since we may change the type and we don't want callers to bear the burden of checking that. Assign in place is best,
62
+
// because it makes the assignment skip the free
65
63
// See if we can inplace an assignment. That is always a good idea, though rare
66
-
if(unlikely((2*(a==zombv)+(w==zombv))&jtinplace)){ // one of the args is being reassigned
67
-
if(likely((AFLAG(zombv)&AFVIRTUAL+AFUNINCORPABLE)+(af^AR(zombv))==0)){z=zombv; goto getzv;} // mustn't modify VIRTUAL or INCORPABLE, and reassigned value must have the higher rank
64
+
if(unlikely((2*(a==z)+(w==z))&jtinplace)){ // one of the args is being reassigned
65
+
if(likely((AFLAG(z)&AFVIRTUAL+AFUNINCORPABLE)+(af^AR(z))==0)){goto getzv;} // mustn't modify VIRTUAL or INCORPABLE, and reassigned value must have the higher rank
68
66
// obsolete if(likely(af==AR(jt->zombieval))){z=jt->zombieval; goto getzv;} // the
69
67
// obsolete }
70
68
}
69
+
if(awip&=jtinplace){z=awip&JTINPLACEW?w:a; // block is abandoned inplaceable, : pick it. Priority to w
70
+
if(likely((AFLAG(z)&AFUNINCORPABLE+AFRO)+(af^AR(z))==0))goto getzv; // not disallowed and correct rank: use it
71
+
if(awip==3){z=a; if(likely((AFLAG(a)&AFUNINCORPABLE+AFRO)+(af^AR(a))==0))goto getzv;} // if a & w both eligible, check a if w failed
72
+
}
71
73
// obsolete awip&=jtinplace; z=awip&JTINPLACEA?a:z; z=awip&JTINPLACEW?w:z; // block is contextually inplaceable and inplaceable by count= abandoned. Give priority to w
72
74
#if0// obsolete
73
75
// if the operation is a rank-0 comparison that can return num[result], don't bother with inplacing. Inplacing would be
@@ -87,7 +89,7 @@ INLINE static A jtssingleton(J jt,A a,A w,I af,I at, I wt,A self){
87
89
#endif
88
90
// obsolete if(z&&likely(!(AFLAG(z)&AFUNINCORPABLE+AFRO)))if(likely(af==AR(z)))goto getzv; // not disallowed and correct rank, take it
89
91
// fall through: no inplacing, allocate the result, usually an atom. If not atom, make the shape all 1s
90
-
if(likely(af==0)){GAT0(z,FL,1,0); zv=voidAV0(z);}else{GATV1(z,FL,1,af); zv=voidAV(z);} // not voidAVn so that af is not needed
92
+
if(likely(af==0)){GAT0(z,FL,1,0); zv=voidAV0(z);}else{GATV1(z,FL,1,af); zv=voidAVn(af,z);} // af persists over call
91
93
goto nozv;
92
94
getzv:; // here when we are operating inplace on z
0 commit comments