Browse Source

don't GC builtins

master
Martin Dørum 3 years ago
parent
commit
c080f561d7
2 changed files with 4 additions and 2 deletions
  1. 1
    0
      include/lang2/vm/vm.h
  2. 3
    2
      lib/vm/vm.c

+ 1
- 0
include/lang2/vm/vm.h View File

l2_word fsptr; l2_word fsptr;


l2_word knone, ktrue, kfalse; l2_word knone, ktrue, kfalse;
l2_word gc_start;
}; };


void l2_vm_init(struct l2_vm *vm, l2_word *ops, size_t opcount); void l2_vm_init(struct l2_vm *vm, l2_word *ops, size_t opcount);

+ 3
- 2
lib/vm/vm.c View File



static size_t gc_sweep(struct l2_vm *vm) { static size_t gc_sweep(struct l2_vm *vm) {
size_t freed = 0; size_t freed = 0;
// Skip ID 0, because that should always exist
for (size_t i = 1; i < vm->valuessize; ++i) {
for (size_t i = vm->gc_start; i < vm->valuessize; ++i) {
if (!l2_bitset_get(&vm->valueset, i)) { if (!l2_bitset_get(&vm->valueset, i)) {
continue; continue;
} }
#include "builtins.x.h" #include "builtins.x.h"
#undef Y #undef Y
#undef X #undef X

vm->gc_start = id + 1;
} }


l2_word l2_vm_alloc(struct l2_vm *vm, enum l2_value_type typ, enum l2_value_flags flags) { l2_word l2_vm_alloc(struct l2_vm *vm, enum l2_value_type typ, enum l2_value_flags flags) {

Loading…
Cancel
Save