Skip to content

Commit bcd73d7

Browse files
committed
Expunge MEMAUDIT=5; Implement getkv w/0-1 key; don't eformat a sparse arg; don't resignal an error produced by 13!:8
1 parent 82bb95d commit bcd73d7

File tree

9 files changed

+77
-59
lines changed

9 files changed

+77
-59
lines changed

jsrc/crs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static A jtsprz(J jt,A z0,A y,A e,I f,I*s){A a,a0,q,y0,z;B d;I c,et,h,m,n,r,t,*u
3939
RZ(z0&&y&&e);
4040
ASSERT(AN(e),EVDOMAIN);
4141
if(AN(z0)&&!(AT(z0)&SPARSABLE))R z0; // no backdoor to sparse boxes. If non-sparsable type, leave dense
42-
if(ISSPARSE(AT(e))){ep=PAV(e); ASSERT(all1(eq(SPA(ep,e),SPA(ep,x))),EVSPARSE); q=SPA(ep,e);}
42+
if(ISSPARSE(AT(e))){ep=PAV(e); ASSERT(all1(eq(SPA(ep,e),SPA(ep,x))),EVSPARSE); q=SPA(ep,e);} // 'sparse' sparse element comes from boxing. If all elements identical, replace with sparse atom
4343
else{RZ(q=reshape(mtv,e)); ASSERT(all1(eq(q,e)),EVSPARSE);}
4444
if(!AS(z0)[0]){
4545
t=AT(q); zt=STYPE(t);
@@ -143,7 +143,7 @@ static A jtsprank2_a0(J jt,A a,A w,A fs,AF f2,I af,I acr){PROLOG(0045);A aa,ae,y
143143
av+=ak*ac; RE(ak=spradv(an,ab,af,acr,aj,ap,&aa)); aj+=ak;
144144
}
145145
RZ(z=ope(z)); AS(z)[0]=am; // we did one cell of aa to get the shape, but now we have to set back to correct # indexes
146-
z=sprz(z,zi,CALL2(f2,ae,w,fs),f,as);
146+
z=sprz(z,zi,CALL2(f2,ae,w,fs),f,as); // apply the function to the sparse element
147147
EPILOG(z);
148148
}
149149

jsrc/d.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ A jteformat(J jtfg,A self,A a,A w,A m){F12IP;
234234
A *old=jt->tnextpushp; // we must free all memory that we allocate here
235235
if((saverr=str(jt->etxn,jt->etxinfo->etx))!=0){ // save error code and message; if error in str, skip formatting
236236
A msg=0, m1ah=0, w1ah=0, a1ah=0; // indicate no formatted message; headers for the arguments, which we will delete before exit
237-
if(self){
237+
if(self){
238238
if(AT(self)!=0){ // if the self was FUNCTYPE0 eg, a placeholder, don't try to format with it
239239
// we are going to try to run eformat.
240240
// we have to reset the state of the error system after saving what we will need
@@ -253,18 +253,19 @@ A jteformat(J jtfg,A self,A a,A w,A m){F12IP;
253253
// we also have to isolate the user's a/w/m so that we do not disturb any flags or usecounts. We build headers for the nouns
254254
// The headers are like virtual blocks but they don't increment the usecount of the backer. That means that if further execution frees the backer
255255
// the header is left pointing to garbage. To avoid trouble we zap the headers here and free them by hand after we call eformat
256+
// Since we can't gah() for sparse blocks, we abort eformatting if we encounter one.
256257
A awm=0; // place to build the arg list for eformat
257-
if(m){A m1; rnk=mtv; if((m1=m1ah=gahzap(jt,AR(m),m))==0)goto noeformat; MCISH(AS(m1),AS(m),AR(m)) if((awm=box(m1))==0)goto noeformat; // if m exists, make it the last arg, and set rank to ''
258+
if(m&&!ISSPARSE(AT(m))){A m1; rnk=mtv; if((m1=m1ah=gahzap(jt,AR(m),m))==0)goto noeformat; MCISH(AS(m1),AS(m),AR(m)) if((awm=box(m1))==0)goto noeformat; // if m exists, make it the last arg, and set rank to ''
258259
}else if(e==EVASSEMBLY){
259260
// assembly errors are special. They require an info vector, which has been stored in jt->etxinfo. We pass this vector as m
260261
if((awm=box(vec(INT,jt->etxinfo->asseminfo.assemframelen+(offsetof(struct assem,assemshape)/sizeof(I)),&jt->etxinfo->asseminfo)))==0)goto noeformat;
261262
}
262263
// Convert self to AR. If self is not a verb convert a/w to AR also
263264
I selft=AT(self);
264265
A selfar; if((selfar=arep(self))==0)goto noeformat;
265-
if(w&&((selft&CONJ)||(AT(w)&NOUN))) // if w is valid
266+
if(w&&!ISSPARSE(AT(w))&&((selft&CONJ)||(AT(w)&NOUN))) // if w is valid
266267
{A w1=w; if(AT(w1)&NOUN){ if((w1=w1ah=gahzap(jt,AR(w),w))==0)goto noeformat; MCISH(AS(w1),AS(w),AR(w)) } if(!(selft&VERB))if((w1=arep(w1))==0)goto noeformat; if((awm=awm?jlink(w1,awm):box(w1))==0)goto noeformat;}
267-
if(a){A a1=a; if(AT(a1)&NOUN){if((a1=a1ah=gahzap(jt,AR(a),a))==0)goto noeformat; MCISH(AS(a1),AS(a),AR(a))} if(!(selft&VERB))if((a1=arep(a1))==0)goto noeformat; if((awm=awm?jlink(a1,awm):box(a1))==0)goto noeformat;}
268+
if(a&&!ISSPARSE(AT(a))){A a1=a; if(AT(a1)&NOUN){if((a1=a1ah=gahzap(jt,AR(a),a))==0)goto noeformat; MCISH(AS(a1),AS(a),AR(a))} if(!(selft&VERB))if((a1=arep(a1))==0)goto noeformat; if((awm=awm?jlink(a1,awm):box(a1))==0)goto noeformat;}
268269
// run the analyzer. Fold the unbalanced-paren info into the error number
269270
deba(DCJUNK,0,0,0); // create spacer frame so eformat calls don't overwrite stack
270271
// obsolete WITHDEBUGOFF(df1(msg,jlink(sc(e|(pareninfo<<8)),jlink(namestg,jlink(rnk,jlink(selfar,awm)))),val);) // run eformat_j_

jsrc/j.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2292,7 +2292,11 @@ if(unlikely(!_mm256_testz_pd(sgnbit,mantis0))){ /* if mantissa exactly 0, must
22922292
C _e=jt->emsgstate; jt->emsgstate|=EMSGSTATENOTEXT|EMSGSTATENOLINE|EMSGSTATENOEFORMAT|EMSGSTATETRAPPING; \
22932293
stmt jt->uflags.trace=_d|(jt->uflags.trace&~TRACEDB); jt->emsgstate=_e;} // execute stmt with debug/eformat turned off; restore at end. Sets jt->jerr if error, and should be used when calling possible user code
22942294
#define WITHDEBUGOFF(stmt) MAYBEWITHDEBUG(0,jt,stmt)
2295-
#define WITHEFORMATDEFERRED(stmt) {WITHDEBUGOFF(stmt) if(unlikely(jt->jerr!=0)){UC _d=jt->jerr; RESETERR ASSERT(0,_d)}} // execute stmt with debug/eformat turned off; at end, if there is an error, re-signal it
2295+
// obsolete #define WITHEFORMATDEFERRED(stmt) {WITHDEBUGOFF(stmt) if(unlikely(jt->jerr!=0)&&likely(jt->jerr!=0)){UC _d=jt->jerr; RESETERR ASSERT(0,_d)}} // execute stmt with debug/eformat turned off; at end, if there is an error, re-signal it
2296+
#define WITHEFORMATDEFERRED(stmt) {UC _d=jt->uflags.trace&TRACEDB;jt->uflags.trace&=~TRACEDB; \
2297+
C _e=jt->emsgstate; jt->emsgstate|=EMSGSTATENOTEXT|EMSGSTATENOLINE|EMSGSTATENOEFORMAT|EMSGSTATETRAPPING; \
2298+
stmt jt->uflags.trace=_d|(jt->uflags.trace&~TRACEDB); _d=jt->emsgstate; jt->emsgstate=_e; if(unlikely(jt->jerr!=0)&&likely(_d&EMSGSTATENOTEXT)){_d=jt->jerr; RESETERR ASSERT(0,_d)}} // WITHDEBUGOFF, but resignal any error so as to use caller's eformat.
2299+
// Exception: in EMSGSTATENOTEXT was turned off (and not restored), we figure that user used 13!:8, which we don't eformat, so we don't resignal it
22962300
// If the abandoned value we want to ra is likely the last thing on the tstack, look to see if it is. If so, just back up the tstack (if that backs over to the chain field, that will never match
22972301
// the ZAP pointer and we will not modify tpushnext). Otherwise ZAP the block
22982302
// It would be a disaster to back the tstack to in front of a valid 'old' pointer held somewhere. The subsequent tpop would never end. The case cannot occur, because we set 'old'

jsrc/ja.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@
345345
#define ext(x,y) jtext(jt,(x),(y))
346346
#define exta(x0,x1,x2,x3) jtexta(jt,(x0),(x1),(x2),(x3))
347347
#define extnvr(x) jtextnvr(jt,(x))
348-
#if ((MEMAUDIT&5)==5) && SY_64
348+
#if 0 && ((MEMAUDIT&5)==5) && SY_64 // obsolete
349349
#define scaft(x) testbuf(x); if(AFLAG(x)<0)SEGFAULT;
350350
#define scaft2(x)
351351
#endif

jsrc/je.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,7 @@ extern C spellin(I,C*);
10411041
extern void spellit(C,C*);
10421042
extern I smmallosize(A);
10431043
extern void smmfrr(A);
1044-
#if ((MEMAUDIT&5)==5) && SY_64 // scaf
1044+
#if 0 && ((MEMAUDIT&5)==5) && SY_64 // scaf obsolete
10451045
extern void testbuf(A);
10461046
#endif
10471047
extern I sqrtE(J,I,E*,E*);

jsrc/m.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,7 +1289,7 @@ __attribute__((noinline)) A jtgafalloos(J jt,I blockx,I n){A z;
12891289
R z;
12901290
}
12911291

1292-
#if ((MEMAUDIT&5)==5) && SY_64
1292+
#if 0 && ((MEMAUDIT&5)==5) && SY_64 // obsolete
12931293
#define ALLOSIZE (1024*1024)
12941294
static C allohash[ALLOSIZE]; // 0 is empty, 1 is tombstone, 2 is valid
12951295
static C * alloblocks[ALLOSIZE]; static US allolock=0; I nalloblocks=0; I allorunin=0;
@@ -1439,7 +1439,7 @@ if((I)jt&3)SEGFAULT;
14391439
#if SHOWALLALLOC
14401440
printf("%p+\n",z);
14411441
#endif
1442-
#if ((MEMAUDIT&5)==5) && SY_64
1442+
#if 0 && ((MEMAUDIT&5)==5) && SY_64 // obsolete
14431443
if(JT(jt,peekdata))addbuf(jt,z); // add to allocated list
14441444
#endif
14451445
R z;
@@ -1628,7 +1628,7 @@ printf("%p-\n",w);
16281628
#if PYXES
16291629
if(unlikely(w->origin!=(US)THREADID1(jt))){jtrepat1(jt,w,allocsize); R;} // if block was allocated from a different thread, pass it back to that thread where it can be garbage collected
16301630
#endif
1631-
#if ((MEMAUDIT&5)==5) && SY_64
1631+
#if 0 && ((MEMAUDIT&5)==5) && SY_64 // obsolete
16321632
if(JT(jt,peekdata))rembuf(jt,w); // remove from allocated list
16331633
#endif
16341634
AFCHAIN(w)=jt->mempool[blockx]; // append free list to the new addition...
@@ -1640,7 +1640,7 @@ if(JT(jt,peekdata))rembuf(jt,w); // remove from allocated list
16401640
}
16411641
}else if(unlikely(blockx==FHRHBINISGMP)){jtmfgmp(jt,w); // if GMP allocation, free it through GMP
16421642
}else{ // buffer allocated from malloc
1643-
#if ((MEMAUDIT&5)==5) && SY_64
1643+
#if 0 && ((MEMAUDIT&5)==5) && SY_64 // obsolete
16441644
if(JT(jt,peekdata))rembuf(jt,w); // remove from allocated list
16451645
#endif
16461646
I allocsize = FHRHSYSSIZE(hrh);

jsrc/vo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ static B jtopes2(J jt,A*zx,A*zy,B*b,A a,A e,A q,I wcr){A x;B*c;I dt,k,r,*s,t;P*p
453453
static A jtopes(J jt,I zt,A cs,A w){A a,d,e,sh,t,*wv,x,x1,y,y1,z;B*b;C*xv;I an,*av,c,dk,dt,*dv,i,j,k,m,m1,n,
454454
p,*s,*v,wcr,wr,xc,xk,yc,*yv,*zs;P*zp;
455455
n=AN(w); wr=AR(w); wv=AAV(w); wcr=AN(cs); dt=DTYPE(zt); dk=bpnoun(dt);
456-
RZ(opes1(&b,&a,&e,&m,cs,w)); an=AN(a); av=AV(a);
456+
RZ(opes1(&b,&a,&e,&m,cs,w)); an=AN(a); av=AV(a); // b=mask of sparse axes; a= I. b (sparse axes); e=sparse element; m=estimate of # nonsparse cells
457457
GASPARSE0(z,zt,1,wr+wcr); zs=AS(z); MCISH(zs,AS(w),wr); MCISH(zs+wr,AV(cs),wcr);
458458
zp=PAV(z); c=wcr-an; yc=wr+an;
459459
SPB(zp,e,cvt(dt,e)); e = SPA(zp,e); // in case of reassignment by SPB

0 commit comments

Comments
 (0)