Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions jsrc/adverbs/ao.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ static DF2(jtkey){F2PREFIP;PROLOG(0009);A ai,z=0;I nitems;
// NOT small-range processing: go through the index+size table to create the frets and reordered data for passing to cut
nfrets=AM(ai); //fetch # frets before we possibly clone ai
I maxfretsize=(nitems>>8); maxfretsize=maxfretsize<nfrets?nfrets:maxfretsize; maxfretsize=4*maxfretsize+nfrets+1; // max # bytes needed for frets, if some are long
if((UI)maxfretsize<sizeof(localfrets)-NORMAH*SZI){frets=(A)localfrets; AT(frets)=0; if(MEMAUDIT&0xc)AFLAG(frets)=0;} // Cut tests the type field - only. If debug, the flag also
if((UI)maxfretsize<sizeof(localfrets)-NORMAH*SZI){frets=(A)localfrets; AT(frets)=0; } // Cut tests the type field - only. If debug, the flag also
else if((I)jtinplace&(I)((AFLAG(w)&(AFVIRTUAL|AFNJA))==0)&((UI)((-(I )(AT(w)&DIRECT))&AC(w)&(4-celllen)&((I )(SZI==4)-AR(w)))>>(BW-1-JTINPLACEWX)))frets=w;
else GATV0(frets,LIT,maxfretsize,0); // 1 byte per fret is adequate, since we have padding
fretp=CUTFRETFRETS(frets); // Place where we will store the fret-lengths. They are 1 byte normally, or 5 bytes for groups longer than 254
Expand Down Expand Up @@ -435,7 +435,7 @@ static DF2(jtkey){F2PREFIP;PROLOG(0009);A ai,z=0;I nitems;
av=IAV(a); DQ(nitems, I tval=ftblv[*av&valmsk]; ftblv[*av&valmsk]=tval-1; nfrets-=SGNTO0(tval); av=(I*)((I)av+k);) // build (negative) frequency table; sub 1 for each non-fret
// now that we have the number of freats, we can allocate the fret block
I maxfretsize=(nitems>>8); maxfretsize=maxfretsize<nfrets?nfrets:maxfretsize; maxfretsize=4*maxfretsize+nfrets+1; // max # bytes needed for frets
if((UI)maxfretsize<sizeof(localfrets)-NORMAH*SZI){frets=(A)localfrets; AT(frets)=0; if(MEMAUDIT&0xc)AFLAG(frets)=0;} // Cut tests the type field - only; for memaudit we need flag too
if((UI)maxfretsize<sizeof(localfrets)-NORMAH*SZI){frets=(A)localfrets; AT(frets)=0; } // Cut tests the type field - only; for memaudit we need flag too
else if((I)jtinplace&(I)((AFLAG(w)&(AFVIRTUAL|AFNJA))==0)&((UI)((-(I)(AT(w)&DIRECT))&AC(w)&(4-celllen)&((I)(SZI==4)-AR(w)))>>(BW-1-JTINPLACEWX)))frets=w;
else GATV0(frets,LIT,maxfretsize,0); // 1 byte per fret is adequate, since we have padding
fretp=CUTFRETFRETS(frets); // Place where we will store the fret-lengths. They are 1 byte normally, or 5 bytes for groups longer than 254
Expand Down
2 changes: 0 additions & 2 deletions jsrc/conjunctions/cg.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ A jtcreatecycliciterator(J jt, A z, A w){
// Create the (skeletal) clone, point it to come to the execution point, set the next-verb number to 0
AC(z)=ACPERMANENT; AT(z)=VERB; A gerund=FAV(z)->fgh[2]=FAV(w)->fgh[2]; FAV(z)->mr=FAV(w)->mr; FAV(z)->valencefns[0]=FAV(z)->valencefns[1]=jtexeccyclicgerund; FAV(z)->localuse.lI=0;
FAV(z)->flag2=0; FAV(z)->id=CCYCITER; // clear flags, and give this verb a proper id so it can be checked for
if(MEMAUDIT&0xc)AFLAG(z)=0; // in debug, flags must be valid
return z;
}
// Similar, but also install the list of gerund results that will select the verb to run
Expand All @@ -74,7 +73,6 @@ static A jtcreategerunditerator(J jt, A z, A w, A r){ // z is result area, w is
AC(z)=ACPERMANENT; AT(z)=VERB; FAV(z)->fgh[2]=FAV(w)->fgh[2]; FAV(z)->fgh[1]=r; FAV(z)->mr=FAV(w)->mr;
FAV(z)->valencefns[0]=FAV(z)->valencefns[1]=AT(r)&INT?jtexecgerundcellI:jtexecgerundcellB; FAV(z)->localuse.lI=0;
FAV(z)->flag2=0;
if(MEMAUDIT&0xc)AFLAG(z)=0; // in debug, flags must be valid
return z;
}

Expand Down
19 changes: 2 additions & 17 deletions jsrc/j.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,12 +297,6 @@ static inline omp_int_t omp_get_max_threads() { return 1;}

// Debugging options

// Use MEMAUDIT to sniff out errant memory alloc/free
#define MEMAUDIT 0x00 // Bitmask for memory audits: 1=check headers 2=full audit of tpush/tpop 4=write garbage to memory before freeing it 8=write garbage to memory after getting it
// 16=audit freelist at every alloc/free (starting after you have run 6!:5 (1) to turn it on)
// 13 (0xD) will verify that there are no blocks being used after they are freed, or freed prematurely. If you get a wild free, turn on bit 0x2
// 2 will detect double-frees before they happen, at the time of the erroneous tpush

#define AUDITEXECRESULTS 0 // When set, we go through all execution results to verify recursive and virtual bits are OK
#define FORCEVIRTUALINPUTS 0 // When 1 set, we make all non-inplaceable noun inputs to executions VIRTUAL. Tests should still run
// When 2 set, make all outputs from RETF() virtual. Tests for inplacing will fail; that's OK if nothing crashes
Expand Down Expand Up @@ -703,29 +697,20 @@ if(likely(z<3)){_zzt+=z; z=(I)&oneone; _zzt=_i&3?_zzt:(I*)z; z=_i&2?(I)_zzt:z; z
#define RESETRANK (jt->ranks=(RANK2T)~0)
#define RNE(exp) {return jt->jerr?0:(exp);}
#define RZ(exp) {if(unlikely(!(exp)))R0}
#if MEMAUDIT&0xc
#define DEADARG(x) (x?(AFLAG(x)&CONW?SEGFAULT:0):0); if(MEMAUDIT&0x10)auditmemchains(); if(MEMAUDIT&0x2)audittstack(jt);
#define ARGCHK1D(x) ARGCHK1(x) // these not needed normally, but useful for debugging
#define ARGCHK2D(x,y) ARGCHK2(x,y)
#else

#define DEADARG(x) 0
#define ARGCHK1D(x)
#define ARGCHK2D(x,y)
#endif

#define ARGCHK1(x) RZ(x) DEADARG(x); // bit set in deadbeef
#define ARGCHK2(x,y) ARGCHK1(x) ARGCHK1(y)
#define ARGCHK3(x,y,z) ARGCHK1(x) ARGCHK1(y) ARGCHK1(z)


// RETF is the normal function return. For debugging we hook into it
#if AUDITEXECRESULTS && (FORCEVIRTUALINPUTS==2)
#define RETF(exp) A ZZZz = (exp); auditblock(ZZZz,1,1); ZZZz = virtifnonip(jt,0,ZZZz); return ZZZz
#else
#if MEMAUDIT&0xc
#define RETF(exp) A ZZZz = (exp); DEADARG(ZZZz); return ZZZz
#else
#define RETF(exp) return exp
#endif
// Input is a byte. It is replicated to all lanes of a UI
#endif
#define REPLBYTETOW(in,out) (out=(UC)(in),out|=out<<8,out|=out<<16,out|=out<<32)
Expand Down
7 changes: 3 additions & 4 deletions jsrc/ja.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@
// Zczero is ~0 if usecount is going negative, 0 otherwise. Usecount 1->0, 8..1->8..2, 4..0 unchanged, others decrement
#define fadecr(x) I Zc=AC(x); AC(x)=Zc=Zc-1+((UI)Zc>>(BW-2)); // this does the decrement only, checking for PERMANENT
#define faaction(x, nomfaction) {fadecr(x) I tt=AT(x); Zc=REPSGN(Zc-1); if(unlikely(((tt&=TRAVERSIBLE)&(Zc|~AFLAG(x)))!=0))jtfa(jt,(x),tt); if(likely(Zc!=0)){jtmf(jt,x);} nomfaction}
#define fa(x) {if(likely((x)!=0))faaction((x),else {if(MEMAUDIT&2)audittstack(jt);})}
#define fa(x) {if(likely((x)!=0))faaction((x),)}
// Within the tpush/tpop when we know the usecount has gone to 0, no need to audit fa, since it was checked on the push
#define fana(x) {if(likely((x)!=0))fanano0(x)}
// when x is known to be valid and usecount has gone to 0
Expand Down Expand Up @@ -1197,12 +1197,11 @@
// NOTE that PERMANENT blocks are always marked traversible if they are of traversible type, so we will not recur on them internally
#define tpushcommon(x,suffix) {if(likely(!ACISPERM(AC(x)))){I tt=AT(x); A *pushp=jt->tnextpushp; *pushp++=(x); \
if(unlikely(!((I)pushp&(NTSTACKBLOCK-1)))){RZ(pushp=tg(pushp));} if(unlikely(((tt^AFLAG(x))&TRAVERSIBLE)!=0))RZ(pushp=jttpush(jt,(x),tt,pushp)); jt->tnextpushp=pushp; suffix}}
#define tpush(x) tpushcommon(x,if(MEMAUDIT&2)audittstack(jt);)
#define tpushna(x) tpushcommon(x,) // suppress audit
#define tpush(x) tpushcommon(x,)
// Internal version, used when the local name pushp is known to hold jt->tnextpushp
#define tpushi(x) {if(likely(!ACISPERM(AC(x)))){I tt=AT(x); *pushp++=(x); if(unlikely(!((I)pushp&(NTSTACKBLOCK-1)))){RZ(pushp=tg(pushp));} if((unlikely((tt^AFLAG(x))&TRAVERSIBLE)!=0))RZ(pushp=jttpush(jt,(x),tt,pushp)); }}
// tpush1 is like tpush, but it does not recur to lower levels. Used only for virtual block (which cannot be PERMANENT)
#define tpush1(x) {A *pushp=jt->tnextpushp; *pushp++=(x); if(unlikely(!((I)pushp&(NTSTACKBLOCK-1)))){RZ(pushp=tg(pushp));} jt->tnextpushp=pushp; if(MEMAUDIT&2)audittstack(jt);}
#define tpush1(x) {A *pushp=jt->tnextpushp; *pushp++=(x); if(unlikely(!((I)pushp&(NTSTACKBLOCK-1)))){RZ(pushp=tg(pushp));} jt->tnextpushp=pushp; }
#define traverse(x,y) jttraverse(jt,(x),(y))
#define trc(x) jttrc(jt,(x))
#define treach(x) jttreach(jt,(x))
Expand Down
1 change: 0 additions & 1 deletion jsrc/je.h
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,6 @@ extern void auditblock(A w, I nonrecurok, I virtok);
extern A virtifnonip(J jt, I ipok, A buf);
#endif
extern A jtassembleresults(J,I, A, A,A*,I,I,I,A,I,I,I);
extern void audittstack(J);
extern I cachedmmult(J,D*,D*,D*,I,I,I,I);
extern void copyTT(void *, void *, I, I,I);
extern A jtac1(J,AF);
Expand Down
3 changes: 0 additions & 3 deletions jsrc/jt.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,6 @@ typedef struct {
D tssbase; /* initial time of date */
A xmod; /* extended integer: the m in m&|@f */
I xmode; /* extended integer operating mode */
#if MEMAUDIT & 2
I audittstackdisabled; // set to 1 to disable auditing
#endif
I rng; /* RNG: generator selector */
UF rngF[5]; /* RNG: function to get the next random number */
UI* rngfxsv; /* RNG: rngv for fixed seed (?.) */
Expand Down
Loading