store Value* as gc roots
This commit is contained in:
parent
94e38e7162
commit
4af5f3d4a6
@ -638,7 +638,7 @@ B import_c2(B d, B w, B x) {
|
|||||||
|
|
||||||
// defined in fns.c
|
// defined in fns.c
|
||||||
i32 getPrevImport(B path);
|
i32 getPrevImport(B path);
|
||||||
i32 setPrevImport(B path, i32 pos);
|
void setPrevImport(B path, i32 pos);
|
||||||
|
|
||||||
static B importKeyList; // exists for GC roots as the hashmap doesn't
|
static B importKeyList; // exists for GC roots as the hashmap doesn't
|
||||||
static B importValList;
|
static B importValList;
|
||||||
|
|||||||
@ -9,11 +9,12 @@ void gc_addFn(vfn f) {
|
|||||||
gc_roots[gc_rootSz++] = f;
|
gc_roots[gc_rootSz++] = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
B gc_rootObjs[256];
|
Value* gc_rootObjs[256];
|
||||||
u32 gc_rootObjSz;
|
u32 gc_rootObjSz;
|
||||||
void gc_add(B x) {
|
void gc_add(B x) {
|
||||||
|
assert(isVal(x));
|
||||||
if (gc_rootObjSz>=256) err("Too many GC root objects");
|
if (gc_rootObjSz>=256) err("Too many GC root objects");
|
||||||
gc_rootObjs[gc_rootObjSz++] = x;
|
gc_rootObjs[gc_rootObjSz++] = v(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -53,7 +54,7 @@ static void gc_resetTag(Value* x) {
|
|||||||
|
|
||||||
void gc_visitRoots() {
|
void gc_visitRoots() {
|
||||||
for (u32 i = 0; i < gc_rootSz; i++) gc_roots[i]();
|
for (u32 i = 0; i < gc_rootSz; i++) gc_roots[i]();
|
||||||
for (u32 i = 0; i < gc_rootObjSz; i++) mm_visit(gc_rootObjs[i]);
|
for (u32 i = 0; i < gc_rootObjSz; i++) mm_visitP(gc_rootObjs[i]);
|
||||||
}
|
}
|
||||||
u64 gc_lastAlloc;
|
u64 gc_lastAlloc;
|
||||||
void gc_forceGC() {
|
void gc_forceGC() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user