use mm_heapUsed() instead of allocB
This commit is contained in:
parent
9982c62526
commit
1b31c88e4c
@ -1,15 +1,5 @@
|
|||||||
#include "../core.h"
|
#include "../core.h"
|
||||||
|
|
||||||
u64 heapUsed_ctr;
|
|
||||||
static void heapUsedFn(Value* p) { heapUsed_ctr+= mm_size(p); }
|
|
||||||
u64 mm_heapUsed() {
|
|
||||||
heapUsed_ctr = 0;
|
|
||||||
mm_forHeap(heapUsedFn);
|
|
||||||
return heapUsed_ctr;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef HEAP_VERIFY
|
#ifdef HEAP_VERIFY
|
||||||
u32 heapVerify_mode = -1;
|
u32 heapVerify_mode = -1;
|
||||||
|
|
||||||
|
|||||||
@ -61,20 +61,21 @@ void gc_forceGC() {
|
|||||||
u64 start = nsTime();
|
u64 start = nsTime();
|
||||||
gc_visitBytes = 0; gc_freedBytes = 0;
|
gc_visitBytes = 0; gc_freedBytes = 0;
|
||||||
gc_visitCount = 0; gc_freedCount = 0;
|
gc_visitCount = 0; gc_freedCount = 0;
|
||||||
u64 startAllocB = allocB;
|
u64 startSize = mm_heapUsed();
|
||||||
#endif
|
#endif
|
||||||
gc_visitRoots();
|
gc_visitRoots();
|
||||||
mm_forHeap(gc_tryFree);
|
mm_forHeap(gc_tryFree);
|
||||||
gc_tagNew = gc_tagCurr;
|
gc_tagNew = gc_tagCurr;
|
||||||
gc_tagCurr^= 0x80;
|
gc_tagCurr^= 0x80;
|
||||||
|
u64 endSize = mm_heapUsed();
|
||||||
#ifdef LOG_GC
|
#ifdef LOG_GC
|
||||||
fprintf(stderr, "GC kept "N64d"B from "N64d" objects, freed "N64d"B, including directly "N64d"B from "N64d" objects; took %.3fms\n", gc_visitBytes, gc_visitCount, startAllocB-allocB, gc_freedBytes, gc_freedCount, (nsTime()-start)/1e6);
|
fprintf(stderr, "GC kept "N64d"B from "N64d" objects, freed "N64d"B, including directly "N64d"B from "N64d" objects; took %.3fms\n", gc_visitBytes, gc_visitCount, startSize-endSize, gc_freedBytes, gc_freedCount, (nsTime()-start)/1e6);
|
||||||
#endif
|
#endif
|
||||||
gc_lastAlloc = allocB;
|
gc_lastAlloc = endSize;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void gc_maybeGC() {
|
void gc_maybeGC() {
|
||||||
if (!gc_depth && allocB > gc_lastAlloc*2) gc_forceGC();
|
if (!gc_depth && mm_heapUsed() > gc_lastAlloc*2) gc_forceGC();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,3 +26,7 @@ void mm_forHeap(V2v f) {
|
|||||||
b1_forHeap(f);
|
b1_forHeap(f);
|
||||||
b3_forHeap(f);
|
b3_forHeap(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u64 mm_heapUsed() {
|
||||||
|
return allocB;
|
||||||
|
}
|
||||||
|
|||||||
@ -12,3 +12,7 @@ EmptyValue* mm_buckets[64];
|
|||||||
#include "mm_buddyTemplate.c"
|
#include "mm_buddyTemplate.c"
|
||||||
#undef BN
|
#undef BN
|
||||||
#undef BSZ
|
#undef BSZ
|
||||||
|
|
||||||
|
u64 mm_heapUsed() {
|
||||||
|
return allocB;
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user