diff options
author | Jo-Philipp Wich <jo@mein.io> | 2022-08-12 00:19:50 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2022-08-12 01:03:00 +0200 |
commit | 47528f02e7376f1fbb205c5cf69d17d55619fcb1 (patch) | |
tree | 4a6255f3c741cbcbb33b42605177e200122e1ff2 /types.c | |
parent | 381cc7508f797e5158bbd1620d6154ef4a11b76c (diff) |
vm: support automatic periodic GC runs
Introduce two new VM api functions uc_vm_gc_start() and uc_vm_gc_stop()
which allow starting and stopping automatic periodic garbage collection
of cyclic objects in the VM context.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'types.c')
-rw-r--r-- | types.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -705,8 +705,10 @@ ucv_array_new_length(uc_vm_t *vm, size_t length) uc_vector_grow(array); - if (vm) + if (vm) { ucv_ref(&vm->values, &array->ref); + vm->alloc_refs++; + } return &array->header; } @@ -901,8 +903,10 @@ ucv_object_new(uc_vm_t *vm) object->header.refcount = 1; object->table = table; - if (vm) + if (vm) { ucv_ref(&vm->values, &object->ref); + vm->alloc_refs++; + } return &object->header; } @@ -1022,8 +1026,10 @@ ucv_closure_new(uc_vm_t *vm, uc_function_t *function, bool arrow_fn) closure->is_arrow = arrow_fn; closure->upvals = function->nupvals ? (uc_upvalref_t **)((uintptr_t)closure + ALIGN(sizeof(*closure))) : NULL; - if (vm) + if (vm) { ucv_ref(&vm->values, &closure->ref); + vm->alloc_refs++; + } uc_program_get(function->program); |