浏览代码

fix GC issues

master
Martin Dørum 3 年前
父节点
当前提交
19d87ad18c
共有 1 个文件被更改,包括 10 次插入1 次删除
  1. 10
    1
      lib/vm/vm.c

+ 10
- 1
lib/vm/vm.c 查看文件

@@ -122,6 +122,13 @@ static size_t gc_sweep(struct l2_vm *vm) {
val->flags &= ~L2_VAL_MARKED;
}
}

// Normal variables are unmarked by the above loop,
// but builtins don't go through that loop
for (size_t i = 0; i < vm->gc_start; ++i) {
vm->values[i].flags &= ~L2_VAL_MARKED;
}

return freed;
}

@@ -275,7 +282,9 @@ size_t l2_vm_gc(struct l2_vm *vm) {
gc_mark(vm, vm->stack[sptr]);
}

for (l2_word fsptr = 0; fsptr < vm->fsptr; ++fsptr) {
// Don't need to mark the first stack frame, since that's where all the
// builtins live, and they aren't sweeped anyways
for (l2_word fsptr = 1; fsptr < vm->fsptr; ++fsptr) {
gc_mark(vm, vm->fstack[fsptr].ns);
}


正在加载...
取消
保存