properly free 𝕩 when needed
This commit is contained in:
parent
8eb3989d84
commit
dfa04f4922
2
makefile
2
makefile
@ -23,6 +23,8 @@ o3ng-singeli:
|
|||||||
@${MAKE} singeli=1 t=o3ng_si f="-g -O3 -march=native" c
|
@${MAKE} singeli=1 t=o3ng_si f="-g -O3 -march=native" c
|
||||||
debugn-singeli:
|
debugn-singeli:
|
||||||
@${MAKE} singeli=1 t=debugn_si f="-g -DDEBUG -march=native" c
|
@${MAKE} singeli=1 t=debugn_si f="-g -DDEBUG -march=native" c
|
||||||
|
heapverifyn-singeli:
|
||||||
|
@${MAKE} singeli=1 t=heapverifyn_si f="-g -DDEBUG -DHEAP_VERIFY -march=native" c
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,8 @@
|
|||||||
/* sysfn.c*/M(type,"•Type") M(decp,"•Decompose") M(primInd,"•PrimInd") M(glyph,"•Glyph") A(fill,"•FillFn") M(sys,"•getsys") A(grLen,"•GroupLen") D(grOrd,"•GroupOrd") \
|
/* sysfn.c*/M(type,"•Type") M(decp,"•Decompose") M(primInd,"•PrimInd") M(glyph,"•Glyph") A(fill,"•FillFn") M(sys,"•getsys") A(grLen,"•GroupLen") D(grOrd,"•GroupOrd") \
|
||||||
/* sysfn.c*/M(repr,"•Repr") M(fmt,"•Fmt") A(asrt,"!") A(casrt,"!") M(out,"•Out") M(show,"•Show") A(bqn,"•BQN") M(sh,"•SH") M(fromUtf8,"•FromUTF8") \
|
/* sysfn.c*/M(repr,"•Repr") M(fmt,"•Fmt") A(asrt,"!") A(casrt,"!") M(out,"•Out") M(show,"•Show") A(bqn,"•BQN") M(sh,"•SH") M(fromUtf8,"•FromUTF8") \
|
||||||
/* sysfn.c*/D(cmp,"•Cmp") A(hash,"•Hash") M(unixTime,"•UnixTime") M(monoTime,"•MonoTime") M(delay,"•Delay") M(makeRand,"•MakeRand") M(reBQN,"•ReBQN") M(exit,"•Exit") M(getLine,"•GetLine") \
|
/* sysfn.c*/D(cmp,"•Cmp") A(hash,"•Hash") M(unixTime,"•UnixTime") M(monoTime,"•MonoTime") M(delay,"•Delay") M(makeRand,"•MakeRand") M(reBQN,"•ReBQN") M(exit,"•Exit") M(getLine,"•GetLine") \
|
||||||
/*internal.c*/M(itype,"•internal.Type") M(refc,"•internal.Refc") M(squeeze,"•internal.Squeeze") M(deepSqueeze,"•internal.DeepSqueeze") M(isPure,"•internal.IsPure") A(info,"•internal.Info") \
|
/*internal.c*/M(itype,"•internal.Type") M(elType,"•internal.ElType") M(refc,"•internal.Refc") M(isPure,"•internal.IsPure") A(info,"•internal.Info") \
|
||||||
|
/*internal.c*/M(squeeze,"•internal.Squeeze") M(deepSqueeze,"•internal.DeepSqueeze") \
|
||||||
/*internal.c*/D(variation,"•internal.Variation") A(listVariations,"•internal.ListVariations") M(clearRefs,"•internal.ClearRefs") M(unshare,"•internal.Unshare")
|
/*internal.c*/D(variation,"•internal.Variation") A(listVariations,"•internal.ListVariations") M(clearRefs,"•internal.ClearRefs") M(unshare,"•internal.Unshare")
|
||||||
|
|
||||||
#define FOR_PM1(A,M,D) \
|
#define FOR_PM1(A,M,D) \
|
||||||
|
|||||||
@ -17,6 +17,11 @@ B itype_c1(B t, B x) {
|
|||||||
dec(x);
|
dec(x);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
B elType_c1(B t, B x) {
|
||||||
|
B r = m_i32(isArr(x)? TI(x,elType) : selfElType(x));
|
||||||
|
dec(x);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
B refc_c1(B t, B x) {
|
B refc_c1(B t, B x) {
|
||||||
B r = isVal(x)? m_i32(v(x)->refc) : m_str8l("(not heap-allocated)");
|
B r = isVal(x)? m_i32(v(x)->refc) : m_str8l("(not heap-allocated)");
|
||||||
dec(x);
|
dec(x);
|
||||||
@ -266,8 +271,8 @@ B getInternalNS() {
|
|||||||
listVariations_def = m_str8l("if");
|
listVariations_def = m_str8l("if");
|
||||||
gc_addFn(variation_gcRoot);
|
gc_addFn(variation_gcRoot);
|
||||||
#define F(X) inc(bi_##X),
|
#define F(X) inc(bi_##X),
|
||||||
B fn = bqn_exec(m_str32(U"{⟨ Type, Refc, Squeeze, IsPure, Info, ListVariations, Variation, ClearRefs, Unshare, DeepSqueeze⟩⇐𝕩}"), emptyCVec(), emptySVec());
|
B fn = bqn_exec(m_str32(U"{⟨ Type, ElType, Refc, Squeeze, IsPure, Info, ListVariations, Variation, ClearRefs, Unshare, DeepSqueeze⟩⇐𝕩}"), emptyCVec(), emptySVec());
|
||||||
B arg = m_caB(10,(B[]){F(itype)F(refc)F(squeeze)F(isPure)F(info)F(listVariations)F(variation)F(clearRefs)F(unshare)F(deepSqueeze)});
|
B arg = m_caB(11,(B[]){F(itype)F(elType)F(refc)F(squeeze)F(isPure)F(info)F(listVariations)F(variation)F(clearRefs)F(unshare)F(deepSqueeze)});
|
||||||
#undef F
|
#undef F
|
||||||
internalNS = c1(fn,arg);
|
internalNS = c1(fn,arg);
|
||||||
gc_add(internalNS);
|
gc_add(internalNS);
|
||||||
|
|||||||
@ -656,6 +656,9 @@ B delay_c1(B t, B x) {
|
|||||||
return m_f64(ts.tv_sec-ts0.tv_sec+(ts.tv_nsec-ts0.tv_nsec)*1e-9);
|
return m_f64(ts.tv_sec-ts0.tv_sec+(ts.tv_nsec-ts0.tv_nsec)*1e-9);
|
||||||
}
|
}
|
||||||
B exit_c1(B t, B x) {
|
B exit_c1(B t, B x) {
|
||||||
|
#ifdef HEAP_VERIFY
|
||||||
|
printf("(heapverify doesn't run on •Exit)\n");
|
||||||
|
#endif
|
||||||
bqn_exit(q_i32(x)? o2i(x) : 0);
|
bqn_exit(q_i32(x)? o2i(x) : 0);
|
||||||
}
|
}
|
||||||
B getLine_c1(B t, B x) {
|
B getLine_c1(B t, B x) {
|
||||||
|
|||||||
@ -7,6 +7,10 @@ static NOINLINE void fillBits(u64* dst, u64 sz, bool v) {
|
|||||||
u64 am = (sz+63)/64; assert(am>0);
|
u64 am = (sz+63)/64; assert(am>0);
|
||||||
for (usz i = 0; i < am; i++) dst[i] = x;
|
for (usz i = 0; i < am; i++) dst[i] = x;
|
||||||
}
|
}
|
||||||
|
static NOINLINE void fillBitsDec(u64* dst, u64 sz, bool v, u64 x) {
|
||||||
|
dec(b(x));
|
||||||
|
fillBits(dst, sz, v);
|
||||||
|
}
|
||||||
|
|
||||||
bool please_tail_call_cmp_err = 1;
|
bool please_tail_call_cmp_err = 1;
|
||||||
static NOINLINE void cmp_err() { if (please_tail_call_cmp_err) thrM("Invalid comparison"); }
|
static NOINLINE void cmp_err() { if (please_tail_call_cmp_err) thrM("Invalid comparison"); }
|
||||||
@ -58,11 +62,13 @@ static void* tyany_ptr(B x) {
|
|||||||
} \
|
} \
|
||||||
AL(w); \
|
AL(w); \
|
||||||
if (ria) lut_avx2_##NAME##AS [we](rp, (u8*)tyany_ptr(w), x.u, ria); \
|
if (ria) lut_avx2_##NAME##AS [we](rp, (u8*)tyany_ptr(w), x.u, ria); \
|
||||||
|
else dec(x); \
|
||||||
dec(w); return r; \
|
dec(w); return r; \
|
||||||
} else if (isArr(x)) { u8 xe = TI(x,elType); if (xe==el_B) goto end; AL(x); \
|
} else if (isArr(x)) { u8 xe = TI(x,elType); if (xe==el_B) goto end; AL(x); \
|
||||||
if (ria) lut_avx2_##RNAME##AS[xe](rp, (u8*)tyany_ptr(x), w.u, ria); \
|
if (ria) lut_avx2_##RNAME##AS[xe](rp, (u8*)tyany_ptr(x), w.u, ria); \
|
||||||
dec(x); return r; \
|
else dec(w); \
|
||||||
} \
|
dec(x); return r; \
|
||||||
|
} \
|
||||||
if (isF64(w)&isC32(x)) return m_i32(FC); \
|
if (isF64(w)&isC32(x)) return m_i32(FC); \
|
||||||
if (isC32(w)&isF64(x)) return m_i32(CF); \
|
if (isC32(w)&isF64(x)) return m_i32(CF); \
|
||||||
end:;
|
end:;
|
||||||
|
|||||||
@ -16,23 +16,21 @@ def cif{v, G} = { show{'cif argument not known at compile time!'}; G{} }
|
|||||||
def cif{v, G & match{v,0}} = 0
|
def cif{v, G & match{v,0}} = 0
|
||||||
def cif{v, G & match{v,1}} = G{0}
|
def cif{v, G & match{v,1}} = G{0}
|
||||||
|
|
||||||
def fillbits{dst:*u64, len:(Size), v} = {
|
def fillbits{dst:*u64, len:(Size), v } = { emit{void, 'fillBits', dst, len, v }; return{}; }
|
||||||
emit{void, 'fillBits', dst, len, v}
|
def fillbits{dst:*u64, len:(Size), v, x} = { emit{void, 'fillBitsDec', dst, len, v, x}; return{}; }
|
||||||
return{}
|
|
||||||
}
|
|
||||||
def cmp_err{x} = { emit{void, 'cmp_err'}; return{}; }
|
def cmp_err{x} = { emit{void, 'cmp_err'}; return{}; }
|
||||||
|
|
||||||
cmpIX(dst:*u64, len:Size, x:u64, v:u1) : void = {
|
cmpIX(dst:*u64, len:Size, x:u64, v:u1) : void = {
|
||||||
nan:u1 = q_f64{x}
|
nan:u1 = q_f64{x}
|
||||||
if (~(nan | q_chr{x})) cmp_err{x}
|
if (~(nan | q_chr{x})) cmp_err{x}
|
||||||
fillbits{dst, len, v & ~nan}
|
fillbits{dst, len, v & ~nan, x}
|
||||||
}
|
}
|
||||||
|
|
||||||
def eqne{op} = match{op,__eq}|match{op,__ne}
|
def eqne{op} = match{op,__eq}|match{op,__ne}
|
||||||
|
|
||||||
def pathAS{dst, len, T, op, x & issigned{T}} = {
|
def pathAS{dst, len, T, op, x & issigned{T}} = {
|
||||||
def R{f & eqne{op}} = {
|
def R{f & eqne{op}} = {
|
||||||
if (rare{floor{f}!=f}) fillbits{dst, len, op{0,1}} # also includes check for NaN/sNaN
|
if (rare{floor{f}!=f}) fillbits{dst, len, op{0,1}, x} # also includes check for NaN/sNaN
|
||||||
ftrunc_i64{f}
|
ftrunc_i64{f}
|
||||||
}
|
}
|
||||||
def R{f & match{op,__lt}|match{op,__ge}} = ftrunc_i64{ceil{f}}
|
def R{f & match{op,__lt}|match{op,__ge}} = ftrunc_i64{ceil{f}}
|
||||||
@ -53,7 +51,7 @@ def pathAS{dst, len, T, op, x & issigned{T}} = {
|
|||||||
def pathAS{dst, len, T, op, x & T==f64} = {
|
def pathAS{dst, len, T, op, x & T==f64} = {
|
||||||
if (rare{~q_f64{x}}) {
|
if (rare{~q_f64{x}}) {
|
||||||
cif{~eqne{op}, {_}=>{ if(~q_chr{x}) cmp_err{x}; }}
|
cif{~eqne{op}, {_}=>{ if(~q_chr{x}) cmp_err{x}; }}
|
||||||
fillbits{dst, len, op{0,1}}
|
fillbits{dst, len, op{0,1}, x}
|
||||||
}
|
}
|
||||||
from_B{T,x}
|
from_B{T,x}
|
||||||
}
|
}
|
||||||
@ -61,7 +59,7 @@ def pathAS{dst, len, T, op, x & T==f64} = {
|
|||||||
def pathAS{dst, len, T, op, x & isunsigned{T}} = {
|
def pathAS{dst, len, T, op, x & isunsigned{T}} = {
|
||||||
if (rare{~q_chr{x}}) {
|
if (rare{~q_chr{x}}) {
|
||||||
cif{~eqne{op}, {_}=>{ if(~q_f64{x}) cmp_err{x}; }}
|
cif{~eqne{op}, {_}=>{ if(~q_f64{x}) cmp_err{x}; }}
|
||||||
fillbits{dst, len, op{1,0}}
|
fillbits{dst, len, op{1,0}, x}
|
||||||
}
|
}
|
||||||
xc32:u32 = from_B{u32,x}
|
xc32:u32 = from_B{u32,x}
|
||||||
if (xc32 > maxvalue{T}) fillbits{dst, len, op{0,1}}
|
if (xc32 > maxvalue{T}) fillbits{dst, len, op{0,1}}
|
||||||
@ -110,9 +108,10 @@ bitAS{op}(dst:*u64, wr:*u8, x:u64, len:Size) : void = { # show{'bitAS'}
|
|||||||
r0:u1 = op{0,xf}
|
r0:u1 = op{0,xf}
|
||||||
r1:u1 = op{1,xf}
|
r1:u1 = op{1,xf}
|
||||||
if (r0==r1) {
|
if (r0==r1) {
|
||||||
cif{~eqne{op}, {_}=>{
|
if (rare{isNaN{xf}}) {
|
||||||
if (rare{isNaN{xf}}) { call{cmpIX, dst, len, x, op{0,1}}; return{}; }
|
if (eqne{op}) fillbits{dst, len, r0, x}
|
||||||
}}
|
else { call{cmpIX, dst, len, x, op{0,1}}; return{}; }
|
||||||
|
}
|
||||||
fillbits{dst, len, r0}
|
fillbits{dst, len, r0}
|
||||||
return{}
|
return{}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user