commented-out heap alignment
This commit is contained in:
parent
ebd6d9d889
commit
9780cacacd
@ -61,9 +61,9 @@ static void* mmap_nvm(u64 sz) {
|
||||
|
||||
#define MMAP(SZ) mmap_nvm(sz);
|
||||
#define MUL 1
|
||||
#define BUDDY_NO_GC 1
|
||||
#define ALLOC_MODE 1
|
||||
#include "../opt/mm_buddyTemplate.c"
|
||||
#undef BUDDY_NO_GC
|
||||
#undef ALLOC_MODE
|
||||
static void* mmX_allocN(usz sz, u8 type) { assert(sz>=16); return mmX_allocL(64-CLZ(sz-1ull), type); }
|
||||
#undef BN
|
||||
#undef BSZ
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
#error MM=2 doesn't support VERIFY_TAIL
|
||||
#endif
|
||||
|
||||
#define ALLOC_MODE 0
|
||||
u64 mm_ctrs[128];
|
||||
EmptyValue* mm_buckets[128];
|
||||
#define b1_buckets mm_buckets
|
||||
@ -34,6 +35,7 @@ EmptyValue* mm_buckets[128];
|
||||
#include "mm_buddyTemplate.c"
|
||||
#undef BN
|
||||
#undef BSZ
|
||||
#undef ALLOC_MODE
|
||||
|
||||
NOINLINE void* mm_allocS(i64 bucket, u8 type) {
|
||||
return bucket&64? b3_allocS(bucket, type) : b1_allocS(bucket, type);
|
||||
|
||||
@ -36,7 +36,7 @@ FORCE_INLINE void BN(splitTo)(EmptyValue* c, i64 from, i64 to, bool notEqual) {
|
||||
buckets[from] = c;
|
||||
}
|
||||
|
||||
#if !BUDDY_NO_GC && ENABLE_GC
|
||||
#if ALLOC_MODE==0 && ENABLE_GC
|
||||
static bool BN(allocMore_rec);
|
||||
#endif
|
||||
|
||||
@ -44,12 +44,12 @@ static NOINLINE void* BN(allocateMore)(i64 bucket, u8 type, i64 from, i64 to) {
|
||||
u64 sz = BSZ(from);
|
||||
CHECK_INTERRUPT;
|
||||
|
||||
#if !BUDDY_NO_GC && ENABLE_GC
|
||||
#if ALLOC_MODE==0 && ENABLE_GC
|
||||
if (gc_maybeGC(false)) goto alloc_rec;
|
||||
#endif
|
||||
|
||||
if (mm_heapAlloc+sz >= mm_heapMax) {
|
||||
#if !BUDDY_NO_GC && ENABLE_GC
|
||||
#if ALLOC_MODE==0 && ENABLE_GC
|
||||
if (!BN(allocMore_rec)) {
|
||||
gc_forceGC(false);
|
||||
BN(allocMore_rec) = true;
|
||||
@ -67,8 +67,13 @@ static NOINLINE void* BN(allocateMore)(i64 bucket, u8 type, i64 from, i64 to) {
|
||||
#if NO_MMAP
|
||||
EmptyValue* c = calloc(sz+getPageSize(), 1);
|
||||
#else
|
||||
EmptyValue* c = MMAP(sz);
|
||||
if (c==MAP_FAILED) thrOOM();
|
||||
u8* mem = MMAP(sz);
|
||||
if (mem==MAP_FAILED) thrOOM();
|
||||
#if ALLOC_MODE==0
|
||||
// ux off = offsetof(TyArr,a);
|
||||
// if (off&31) mem+= 32-(off&31); // align heap such that arr->a is 32-byte-aligned
|
||||
#endif
|
||||
EmptyValue* c = (void*)mem;
|
||||
#endif
|
||||
mm_heapAlloc+= sz;
|
||||
|
||||
@ -130,7 +135,7 @@ void BN(forFreedHeap)(V2v f) {
|
||||
}
|
||||
}
|
||||
}
|
||||
#if !BUDDY_NO_GC && ENABLE_GC
|
||||
#if ALLOC_MODE==0 && ENABLE_GC
|
||||
static void BN(freeFreedAndMerge)() {
|
||||
for (u64 i = 0; i < 64; i++) buckets[i] = NULL;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user