Skip to content

Commit a3763be

Browse files
committed
stab at fixing clang crash
1 parent f550320 commit a3763be

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

jsrc/ar.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,6 +1214,20 @@ static DF2(jtfold12){F12IP;A z,vz;
12141214
// we are adding uz to a recursible block, with transfer of ownership. The new owner protects the block. If uz is abandoned it is safe to zap even if it is x. Sets new uz
12151215
// Fold Multiple. Add the new value to the result array
12161216
UI newslot=AN(zz); // where the new value will go
1217+
#if 1 // test version to try to eliminate crash
1218+
if(withprob(newslot==zzalloc,0.03)){ // current alloc full?
1219+
// current alloc is full. Double the allocation, swap it with zz (transferring ownership), and copy the data
1220+
zzalloc=2*zzalloc+(AKXR(1)>>LGSZI); // new allocation, cacheline multiple
1221+
// obsolete A zznew; GATV0E(zznew,INT,zzalloc,1,goto exitpop;) A *zznewzap=AZAPLOC(zznew); A *zzzap=AZAPLOC(zz); // allocate, & get pointers to tstack slots old & new
1222+
A zznew; GATV0E(zznew,INT,zzalloc,1,goto exitpop;) ACINITUNPUSH(zznew) // allocate & zap new block
1223+
// obsolete AT(zz)=INT; AFLAG(zz)=0;
1224+
JMC(AAV1(zznew),AAV1(zz),newslot<<LGSZI,0) AZAPLOC(zznew)=AZAPLOC(zz);
1225+
AT(zznew)=BOX; AFLAG(zznew)=BOX&RECURSIBLE; // new zz now has pointers to allocated blocks and to its dedicated zaploc
1226+
AN(zznew)=newslot+1; AAV(zznew)[newslot]=z; // AAV not AAV1
1227+
*AZAPLOC(zz)=zznew; mf(zz); zz=zznew; // swap buffers, transferring ownership to zznew & protecting it; free zz using mf to avoid traversing boxes
1228+
// obsolete *zznewzap=zz;
1229+
}else{AAV1(zz)[newslot]=z; AN(zz)=newslot+1;} // install the new value & account for it in len
1230+
#else
12171231
if(withprob(newslot==zzalloc,0.03)){ // current alloc full?
12181232
// current alloc is full. Double the allocation, swap it with zz (transferring ownership), and copy the data
12191233
zzalloc=2*zzalloc+(AKXR(1)>>LGSZI); // new allocation, cacheline multiple
@@ -1225,6 +1239,7 @@ static DF2(jtfold12){F12IP;A z,vz;
12251239
AT(zz)=BOX; AFLAG(zz)=BOX&RECURSIBLE; // new zz now has pointers to allocated blocks and to its dedicated zaploc
12261240
}
12271241
AAV1(zz)[newslot]=z; AN(zz)=newslot+1; // install the new value & account for it in len
1242+
#endif
12281243
}else{
12291244
// Fold Single. Replace the value in zz
12301245
// obsolete ra(z) // uz is not guaranteed to stay in the result till the end; therefore we must not zap it for fold single since it might be w also.

0 commit comments

Comments
 (0)