don't read mmInfo from RAM

This commit is contained in:
dzaima 2021-07-11 23:23:51 +03:00
parent 2a0b91e7b4
commit 8f3f9ba114
5 changed files with 11 additions and 11 deletions

View File

@ -27,7 +27,7 @@ u64* mmX_ctrs[64];
#define PROT PROT_READ|PROT_WRITE|PROT_EXEC
#define FLAGS MAP_NORESERVE|MAP_PRIVATE|MAP_ANON|MAP_32BIT
#include "../opt/mm_buddyTemplate.c"
static void* mmX_allocN(usz sz, u8 type) { assert(sz>=16); return mmX_allocL(64-__builtin_clzl(sz-1ull), type); }
static void* mmX_allocN(usz sz, u8 type) { assert(sz>=16); u64 b = 64-__builtin_clzl(sz-1ull); return mmX_allocL(b, b, type); }
#undef BN
#undef BSZ

View File

@ -33,8 +33,8 @@ static void* mm_alloc(usz sz, u8 type) {
assert(sz>=16);
onAlloc(sz, type);
u8 b1 = 64-__builtin_clzl(sz-1ull);
if (sz <= (3ull<<(b1-2))) return b3_allocL(b1-2, type);
else return b1_allocL(b1, type);
if (sz <= (3ull<<(b1-2))) return b3_allocL(b1-2, b1-2|64, type);
else return b1_allocL(b1, b1, type);
}
static void mm_free(Value* x) {
if (x->mmInfo&64) b3_free(x);

View File

@ -23,7 +23,8 @@ extern EmptyValue* mm_buckets[64];
static void* mm_alloc(usz sz, u8 type) {
assert(sz>=16);
onAlloc(sz, type);
Value* r = mm_allocL(BSZI(sz), type);
u64 b = BSZI(sz);
Value* r = mm_allocL(b, b, type);
return r;
}

View File

@ -63,9 +63,9 @@ static void BN(guaranteeEmpty)(u8 bucket) {
c->next = buckets[cb];
buckets[cb] = c;
}
NOINLINE void* BN(allocS)(i64 bucket, u8 type) {
NOINLINE void* BN(allocS)(i64 bucket, i64 info, u8 type) {
BN(guaranteeEmpty)(bucket);
return BN(allocL)(bucket, type);
return BN(allocL)(bucket, info, type);
}
void BN(forHeap)(V2v f) {

View File

@ -17,20 +17,19 @@ static void BN(free)(Value* x) {
x->type = t_empty;
}
NOINLINE void* BN(allocS)(i64 bucket, u8 type);
static void* BN(allocL)(i64 bucket, u8 type) {
NOINLINE void* BN(allocS)(i64 bucket, i64 info, u8 type);
static void* BN(allocL)(i64 bucket, i64 info, u8 type) {
EmptyValue* x = buckets[bucket];
if (RARE(x==NULL)) return BN(allocS)(bucket, type);
if (RARE(x==NULL)) return BN(allocS)(bucket, info, type);
buckets[bucket] = x->next;
#ifdef USE_VALGRIND
VALGRIND_MAKE_MEM_UNDEFINED(x, BSZ(bucket));
VALGRIND_MAKE_MEM_DEFINED(&x->mmInfo, 1);
#endif
BN(ctrs)[bucket]++;
u8 mmInfo = x->mmInfo;
x->flags = x->extra = x->type = x->mmInfo = 0;
x->refc = 1;
x->mmInfo = (mmInfo&0x7f) | gc_tagCurr;
x->mmInfo = info | gc_tagCurr;
x->type = type;
#if defined(DEBUG) && !defined(DONT_FREE)
u64* p = (u64*)x;