i64 → ux for bucket indices
This commit is contained in:
parent
9371fa0fbc
commit
d640931c02
@ -416,7 +416,7 @@ FORCE_INLINE void preAlloc(usz sz, u8 type) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#if VERIFY_TAIL
|
#if VERIFY_TAIL
|
||||||
void tailVerifyAlloc(void* ptr, u64 origSz, i64 logAlloc, u8 type);
|
void tailVerifyAlloc(void* ptr, u64 origSz, ux logAlloc, u8 type);
|
||||||
void tailVerifyFree(void* ptr);
|
void tailVerifyFree(void* ptr);
|
||||||
void tailVerifyReinit(void* ptr, u64 s, u64 e);
|
void tailVerifyReinit(void* ptr, u64 s, u64 e);
|
||||||
#define FINISH_OVERALLOC(P, S, E) tailVerifyReinit(P, S, E)
|
#define FINISH_OVERALLOC(P, S, E) tailVerifyReinit(P, S, E)
|
||||||
|
|||||||
@ -215,7 +215,7 @@ void gc_forceGC(bool toplevel) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
STATIC_GLOBAL bool gc_wantTopLevelGC;
|
STATIC_GLOBAL bool gc_wantTopLevelGC;
|
||||||
bool gc_maybeGC(bool toplevel) {
|
NOINLINE bool gc_maybeGC(bool toplevel) {
|
||||||
if (gc_depth) return false;
|
if (gc_depth) return false;
|
||||||
u64 used = tot_heapUsed();
|
u64 used = tot_heapUsed();
|
||||||
if (used > gc_lastAlloc*2 || (toplevel && gc_wantTopLevelGC)) {
|
if (used > gc_lastAlloc*2 || (toplevel && gc_wantTopLevelGC)) {
|
||||||
|
|||||||
@ -39,7 +39,7 @@ GLOBAL EmptyValue* mm_buckets[128];
|
|||||||
#undef BSZ
|
#undef BSZ
|
||||||
#undef ALLOC_MODE
|
#undef ALLOC_MODE
|
||||||
|
|
||||||
NOINLINE void* mm_allocS(i64 bucket, u8 type) {
|
NOINLINE void* mm_allocS(ux bucket, u8 type) {
|
||||||
return bucket&64? b3_allocS(bucket, type) : b1_allocS(bucket, type);
|
return bucket&64? b3_allocS(bucket, type) : b1_allocS(bucket, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -52,7 +52,7 @@ static void tailVerifyInit(void* ptr, u64 filled, u64 end, u64 allocEnd) {
|
|||||||
ITER_TAIL(F)
|
ITER_TAIL(F)
|
||||||
#undef F
|
#undef F
|
||||||
}
|
}
|
||||||
void tailVerifyAlloc(void* ptr, u64 filled, i64 logAlloc, u8 type) {
|
void tailVerifyAlloc(void* ptr, u64 filled, ux logAlloc, u8 type) {
|
||||||
u64 end = 1ULL<<logAlloc;
|
u64 end = 1ULL<<logAlloc;
|
||||||
tailVerifyInit(ptr, sizeof(Value), end, end); // `sizeof(Value)` instead of `filled` to permit, without reinit, decreasing used size without having written anything to the space
|
tailVerifyInit(ptr, sizeof(Value), end, end); // `sizeof(Value)` instead of `filled` to permit, without reinit, decreasing used size without having written anything to the space
|
||||||
if (type==t_talloc) ((u64*)((u8*)ptr + end - 8))[0] = filled-8; // -8 because TALLOCP does a +8
|
if (type==t_talloc) ((u64*)((u8*)ptr + end - 8))[0] = filled-8; // -8 because TALLOCP does a +8
|
||||||
|
|||||||
@ -26,9 +26,9 @@ ALLOC_FN void* mm_alloc(u64 sz, u8 type) {
|
|||||||
NOGC_CHECK("allocating during noalloc");
|
NOGC_CHECK("allocating during noalloc");
|
||||||
preAlloc(sz, type);
|
preAlloc(sz, type);
|
||||||
#if VERIFY_TAIL
|
#if VERIFY_TAIL
|
||||||
i64 logAlloc = LOG2(sz + VERIFY_TAIL);
|
ux logAlloc = LOG2(sz + VERIFY_TAIL);
|
||||||
#else
|
#else
|
||||||
i64 logAlloc = LOG2(sz);
|
ux logAlloc = LOG2(sz);
|
||||||
#endif
|
#endif
|
||||||
void* res = mm_allocL(logAlloc, type);
|
void* res = mm_allocL(logAlloc, type);
|
||||||
#if VERIFY_TAIL && !ALLOC_IMPL_MMX
|
#if VERIFY_TAIL && !ALLOC_IMPL_MMX
|
||||||
|
|||||||
@ -13,7 +13,7 @@ GLOBAL AllocInfo* al;
|
|||||||
GLOBAL u64 alCap;
|
GLOBAL u64 alCap;
|
||||||
GLOBAL u64 alSize;
|
GLOBAL u64 alSize;
|
||||||
|
|
||||||
FORCE_INLINE void BN(splitTo)(EmptyValue* c, i64 from, i64 to, bool notEqual) {
|
FORCE_INLINE void BN(splitTo)(EmptyValue* c, ux from, ux to, bool notEqual) {
|
||||||
c->mmInfo = MMI(to);
|
c->mmInfo = MMI(to);
|
||||||
PLAINLOOP while (from != to) {
|
PLAINLOOP while (from != to) {
|
||||||
from--;
|
from--;
|
||||||
@ -33,7 +33,7 @@ FORCE_INLINE void BN(splitTo)(EmptyValue* c, i64 from, i64 to, bool notEqual) {
|
|||||||
STATIC_GLOBAL bool BN(allocMore_rec);
|
STATIC_GLOBAL bool BN(allocMore_rec);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static NOINLINE void* BN(allocateMore)(i64 bucket, u8 type, i64 from, i64 to) {
|
static NOINLINE void* BN(allocateMore)(ux bucket, u8 type, ux from, ux to) {
|
||||||
if (from >= ALSZ) from = ALSZ;
|
if (from >= ALSZ) from = ALSZ;
|
||||||
if (from < (bucket&63)) from = bucket&63;
|
if (from < (bucket&63)) from = bucket&63;
|
||||||
u64 sz = BSZ(from);
|
u64 sz = BSZ(from);
|
||||||
@ -96,9 +96,9 @@ static NOINLINE void* BN(allocateMore)(i64 bucket, u8 type, i64 from, i64 to) {
|
|||||||
return BN(allocL)(bucket, type);
|
return BN(allocL)(bucket, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
NOINLINE void* BN(allocS)(i64 bucket, u8 type) {
|
NOINLINE void* BN(allocS)(ux bucket, u8 type) {
|
||||||
i64 to = bucket&63;
|
ux to = bucket&63;
|
||||||
i64 from = to;
|
ux from = to;
|
||||||
EmptyValue* c;
|
EmptyValue* c;
|
||||||
while (true) {
|
while (true) {
|
||||||
if (from >= 63) return BN(allocateMore)(bucket, type, from, to);
|
if (from >= 63) return BN(allocateMore)(bucket, type, from, to);
|
||||||
|
|||||||
@ -26,8 +26,8 @@ ALLOC_FN void BN(free)(Value* x) {
|
|||||||
BN(freeLink)(x, true);
|
BN(freeLink)(x, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
NOINLINE void* BN(allocS)(i64 bucket, u8 type);
|
NOINLINE void* BN(allocS)(ux bucket, u8 type);
|
||||||
static void* BN(allocL)(i64 bucket, u8 type) {
|
static void* BN(allocL)(ux bucket, u8 type) {
|
||||||
EmptyValue* x = buckets[bucket];
|
EmptyValue* x = buckets[bucket];
|
||||||
if (RARE(x==NULL)) return BN(allocS)(bucket, type);
|
if (RARE(x==NULL)) return BN(allocS)(bucket, type);
|
||||||
buckets[bucket] = vg_def_v(x->next);
|
buckets[bucket] = vg_def_v(x->next);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user