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 /include | |
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 'include')
-rw-r--r-- | include/ucode/types.h | 4 | ||||
-rw-r--r-- | include/ucode/vm.h | 9 |
2 files changed, 12 insertions, 1 deletions
diff --git a/include/ucode/types.h b/include/ucode/types.h index e20f3d6..6041b22 100644 --- a/include/ucode/types.h +++ b/include/ucode/types.h @@ -303,8 +303,10 @@ struct uc_vm { uint8_t u8; int8_t s8; } arg; - size_t spread_values; + size_t alloc_refs; uint8_t trace; + uint8_t gc_flags; + uint16_t gc_interval; uc_stringbuf_t *strbuf; uc_exception_handler_t *exhandler; FILE *output; diff --git a/include/ucode/vm.h b/include/ucode/vm.h index 8562524..161f1ee 100644 --- a/include/ucode/vm.h +++ b/include/ucode/vm.h @@ -116,6 +116,12 @@ typedef enum { ERROR_RUNTIME } uc_vm_status_t; +typedef enum { + GC_ENABLED = (1 << 0) +} uc_vm_gc_flags_t; + +#define GC_DEFAULT_INTERVAL 1000 + extern uint32_t insns[__I_MAX]; void uc_vm_init(uc_vm_t *vm, uc_parse_config_t *config); @@ -139,6 +145,9 @@ void uc_vm_exception_handler_set(uc_vm_t *vm, uc_exception_handler_t *exhandler) uint32_t uc_vm_trace_get(uc_vm_t *vm); void uc_vm_trace_set(uc_vm_t *vm, uint32_t level); +bool uc_vm_gc_start(uc_vm_t *vm, uint16_t interval); +bool uc_vm_gc_stop(uc_vm_t *vm); + uc_exception_type_t uc_vm_call(uc_vm_t *vm, bool mcall, size_t nargs); void __attribute__((format(printf, 3, 0))) |