don't read mmInfo from RAM
This commit is contained in:
parent
2a0b91e7b4
commit
8f3f9ba114
@ -27,7 +27,7 @@ u64* mmX_ctrs[64];
|
|||||||
#define PROT PROT_READ|PROT_WRITE|PROT_EXEC
|
#define PROT PROT_READ|PROT_WRITE|PROT_EXEC
|
||||||
#define FLAGS MAP_NORESERVE|MAP_PRIVATE|MAP_ANON|MAP_32BIT
|
#define FLAGS MAP_NORESERVE|MAP_PRIVATE|MAP_ANON|MAP_32BIT
|
||||||
#include "../opt/mm_buddyTemplate.c"
|
#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 BN
|
||||||
#undef BSZ
|
#undef BSZ
|
||||||
|
|
||||||
|
|||||||
@ -33,8 +33,8 @@ static void* mm_alloc(usz sz, u8 type) {
|
|||||||
assert(sz>=16);
|
assert(sz>=16);
|
||||||
onAlloc(sz, type);
|
onAlloc(sz, type);
|
||||||
u8 b1 = 64-__builtin_clzl(sz-1ull);
|
u8 b1 = 64-__builtin_clzl(sz-1ull);
|
||||||
if (sz <= (3ull<<(b1-2))) return b3_allocL(b1-2, type);
|
if (sz <= (3ull<<(b1-2))) return b3_allocL(b1-2, b1-2|64, type);
|
||||||
else return b1_allocL(b1, type);
|
else return b1_allocL(b1, b1, type);
|
||||||
}
|
}
|
||||||
static void mm_free(Value* x) {
|
static void mm_free(Value* x) {
|
||||||
if (x->mmInfo&64) b3_free(x);
|
if (x->mmInfo&64) b3_free(x);
|
||||||
|
|||||||
@ -23,7 +23,8 @@ extern EmptyValue* mm_buckets[64];
|
|||||||
static void* mm_alloc(usz sz, u8 type) {
|
static void* mm_alloc(usz sz, u8 type) {
|
||||||
assert(sz>=16);
|
assert(sz>=16);
|
||||||
onAlloc(sz, type);
|
onAlloc(sz, type);
|
||||||
Value* r = mm_allocL(BSZI(sz), type);
|
u64 b = BSZI(sz);
|
||||||
|
Value* r = mm_allocL(b, b, type);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -63,9 +63,9 @@ static void BN(guaranteeEmpty)(u8 bucket) {
|
|||||||
c->next = buckets[cb];
|
c->next = buckets[cb];
|
||||||
buckets[cb] = c;
|
buckets[cb] = c;
|
||||||
}
|
}
|
||||||
NOINLINE void* BN(allocS)(i64 bucket, u8 type) {
|
NOINLINE void* BN(allocS)(i64 bucket, i64 info, u8 type) {
|
||||||
BN(guaranteeEmpty)(bucket);
|
BN(guaranteeEmpty)(bucket);
|
||||||
return BN(allocL)(bucket, type);
|
return BN(allocL)(bucket, info, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BN(forHeap)(V2v f) {
|
void BN(forHeap)(V2v f) {
|
||||||
|
|||||||
@ -17,20 +17,19 @@ static void BN(free)(Value* x) {
|
|||||||
x->type = t_empty;
|
x->type = t_empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
NOINLINE void* BN(allocS)(i64 bucket, u8 type);
|
NOINLINE void* BN(allocS)(i64 bucket, i64 info, u8 type);
|
||||||
static void* BN(allocL)(i64 bucket, u8 type) {
|
static void* BN(allocL)(i64 bucket, i64 info, 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, info, type);
|
||||||
buckets[bucket] = x->next;
|
buckets[bucket] = x->next;
|
||||||
#ifdef USE_VALGRIND
|
#ifdef USE_VALGRIND
|
||||||
VALGRIND_MAKE_MEM_UNDEFINED(x, BSZ(bucket));
|
VALGRIND_MAKE_MEM_UNDEFINED(x, BSZ(bucket));
|
||||||
VALGRIND_MAKE_MEM_DEFINED(&x->mmInfo, 1);
|
VALGRIND_MAKE_MEM_DEFINED(&x->mmInfo, 1);
|
||||||
#endif
|
#endif
|
||||||
BN(ctrs)[bucket]++;
|
BN(ctrs)[bucket]++;
|
||||||
u8 mmInfo = x->mmInfo;
|
|
||||||
x->flags = x->extra = x->type = x->mmInfo = 0;
|
x->flags = x->extra = x->type = x->mmInfo = 0;
|
||||||
x->refc = 1;
|
x->refc = 1;
|
||||||
x->mmInfo = (mmInfo&0x7f) | gc_tagCurr;
|
x->mmInfo = info | gc_tagCurr;
|
||||||
x->type = type;
|
x->type = type;
|
||||||
#if defined(DEBUG) && !defined(DONT_FREE)
|
#if defined(DEBUG) && !defined(DONT_FREE)
|
||||||
u64* p = (u64*)x;
|
u64* p = (u64*)x;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user