option to noinline mm_alloc & mm_free
This commit is contained in:
parent
5e94de7983
commit
360aabb7cc
@ -1,3 +1,7 @@
|
|||||||
|
#if ALLOC_NOINLINE
|
||||||
|
#define ALLOC_IMPL 1
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "../core.h"
|
#include "../core.h"
|
||||||
|
|
||||||
#if MM==0
|
#if MM==0
|
||||||
|
|||||||
12
src/h.h
12
src/h.h
@ -104,6 +104,14 @@
|
|||||||
#if defined(OBJ_TRACK)
|
#if defined(OBJ_TRACK)
|
||||||
#define OBJ_COUNTER 1
|
#define OBJ_COUNTER 1
|
||||||
#endif
|
#endif
|
||||||
|
#if ALLOC_STAT
|
||||||
|
#define ALLOC_NOINLINE
|
||||||
|
#endif
|
||||||
|
#if ALLOC_NOINLINE
|
||||||
|
#define ALLOC_FN
|
||||||
|
#else
|
||||||
|
#define ALLOC_FN static
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef int8_t i8;
|
typedef int8_t i8;
|
||||||
typedef uint8_t u8;
|
typedef uint8_t u8;
|
||||||
@ -327,8 +335,8 @@ extern B bi_emptyHVec, bi_emptyIVec, bi_emptyCVec, bi_emptySVec;
|
|||||||
#define emptyIVec() incG(bi_emptyIVec)
|
#define emptyIVec() incG(bi_emptyIVec)
|
||||||
#define emptyCVec() incG(bi_emptyCVec)
|
#define emptyCVec() incG(bi_emptyCVec)
|
||||||
#define emptySVec() incG(bi_emptySVec)
|
#define emptySVec() incG(bi_emptySVec)
|
||||||
static void* mm_alloc(u64 sz, u8 type);
|
ALLOC_FN void* mm_alloc(u64 sz, u8 type);
|
||||||
static void mm_free(Value* x);
|
ALLOC_FN void mm_free(Value* x);
|
||||||
static u64 mm_size(Value* x);
|
static u64 mm_size(Value* x);
|
||||||
static void mm_visit(B x);
|
static void mm_visit(B x);
|
||||||
static void mm_visitP(void* x);
|
static void mm_visitP(void* x);
|
||||||
|
|||||||
@ -15,6 +15,7 @@
|
|||||||
#endif // objdump -b binary -m i386 -M x86-64,intel --insn-width=10 -D --adjust-vma=$(cat asm_off) asm_bin | tail -n+8 | sed "$(cat asm_sed);s/\\t/ /g;s/.*: //"
|
#endif // objdump -b binary -m i386 -M x86-64,intel --insn-width=10 -D --adjust-vma=$(cat asm_off) asm_bin | tail -n+8 | sed "$(cat asm_sed);s/\\t/ /g;s/.*: //"
|
||||||
|
|
||||||
|
|
||||||
|
#define ALLOC_IMPL_ALWAYS 1
|
||||||
// separate memory management system for executable code; isn't garbage-collected
|
// separate memory management system for executable code; isn't garbage-collected
|
||||||
EmptyValue* mmX_buckets[64];
|
EmptyValue* mmX_buckets[64];
|
||||||
u64 mmX_ctrs[64];
|
u64 mmX_ctrs[64];
|
||||||
@ -63,6 +64,7 @@ static void* mmap_nvm(u64 sz) {
|
|||||||
static void* mmX_allocN(usz sz, u8 type) { assert(sz>=16); return mmX_allocL(64-CLZ(sz-1ull), type); }
|
static void* mmX_allocN(usz sz, u8 type) { assert(sz>=16); return mmX_allocL(64-CLZ(sz-1ull), type); }
|
||||||
#undef BN
|
#undef BN
|
||||||
#undef BSZ
|
#undef BSZ
|
||||||
|
#undef ALLOC_IMPL_ALWAYS
|
||||||
|
|
||||||
|
|
||||||
// all the instructions to be called by the generated code
|
// all the instructions to be called by the generated code
|
||||||
|
|||||||
@ -19,11 +19,14 @@ extern EmptyValue* mm_buckets[64];
|
|||||||
|
|
||||||
|
|
||||||
#define LOG2(X) ((u8)(64-CLZ((X)-1ull)))
|
#define LOG2(X) ((u8)(64-CLZ((X)-1ull)))
|
||||||
static void* mm_alloc(u64 sz, u8 type) {
|
|
||||||
|
#if !ALLOC_NOINLINE || ALLOC_IMPL || ALLOC_IMPL_ALWAYS
|
||||||
|
ALLOC_FN void* mm_alloc(u64 sz, u8 type) {
|
||||||
assert(sz>=16);
|
assert(sz>=16);
|
||||||
onAlloc(sz, type);
|
onAlloc(sz, type);
|
||||||
return mm_allocL(LOG2(sz), type);
|
return mm_allocL(LOG2(sz), type);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static u64 mm_round(usz sz) {
|
static u64 mm_round(usz sz) {
|
||||||
return BSZ(LOG2(sz));
|
return BSZ(LOG2(sz));
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
#define buckets BN(buckets)
|
#define buckets BN(buckets)
|
||||||
static void BN(free)(Value* x) {
|
|
||||||
|
#if !ALLOC_NOINLINE || ALLOC_IMPL || ALLOC_IMPL_ALWAYS
|
||||||
|
ALLOC_FN void BN(free)(Value* x) {
|
||||||
onFree(x);
|
onFree(x);
|
||||||
#ifdef DONT_FREE
|
#ifdef DONT_FREE
|
||||||
if (x->type!=t_freed) x->flags = x->type;
|
if (x->type!=t_freed) x->flags = x->type;
|
||||||
@ -45,4 +47,5 @@ static void* BN(allocL)(i64 bucket, u8 type) {
|
|||||||
#endif
|
#endif
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
#undef buckets
|
#undef buckets
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user