Explorar el Código

don't GC builtins

master
Martin Dørum hace 3 años
padre
commit
c080f561d7
Se han modificado 2 ficheros con 4 adiciones y 2 borrados
  1. 1
    0
      include/lang2/vm/vm.h
  2. 3
    2
      lib/vm/vm.c

+ 1
- 0
include/lang2/vm/vm.h Ver fichero

@@ -115,6 +115,7 @@ struct l2_vm {
l2_word fsptr;

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

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

+ 3
- 2
lib/vm/vm.c Ver fichero

@@ -108,8 +108,7 @@ static void gc_free(struct l2_vm *vm, l2_word id) {

static size_t gc_sweep(struct l2_vm *vm) {
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)) {
continue;
}
@@ -212,6 +211,8 @@ void l2_vm_init(struct l2_vm *vm, l2_word *ops, size_t opcount) {
#include "builtins.x.h"
#undef Y
#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) {

Cargando…
Cancelar
Guardar