summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--main.c13
-rw-r--r--tests/cram/test_basic.t4
2 files changed, 16 insertions, 1 deletions
diff --git a/main.c b/main.c
index 02df3b1..03549fe 100644
--- a/main.c
+++ b/main.c
@@ -54,6 +54,10 @@ print_usage(const char *app)
"-t\n"
" Enable VM execution tracing.\n\n"
+ "-g interval\n"
+ " Perform periodic garbage collection every `interval` object\n"
+ " allocations.\n\n"
+
"-S\n"
" Enable strict mode.\n\n"
@@ -130,6 +134,9 @@ compile(uc_vm_t *vm, uc_source_t *src, FILE *precompile, bool strip, char *inter
goto out;
}
+ if (vm->gc_interval)
+ uc_vm_gc_start(vm, vm->gc_interval);
+
rc = uc_vm_execute(vm, program, &res);
switch (rc) {
@@ -468,7 +475,7 @@ appname(const char *argv0)
int
main(int argc, char **argv)
{
- const char *optspec = "he:tST::RD:F:U:l:L:c::o:s";
+ const char *optspec = "he:tg:ST::RD:F:U:l:L:c::o:s";
char *interp = "/usr/bin/env ucode";
uc_source_t *source = NULL;
FILE *precompile = NULL;
@@ -554,6 +561,10 @@ main(int argc, char **argv)
uc_vm_trace_set(&vm, 1);
break;
+ case 'g':
+ vm.gc_interval = atoi(optarg);
+ break;
+
case 'D':
if (!parse_define_string(optarg, uc_vm_scope_get(&vm))) {
rv = 1;
diff --git a/tests/cram/test_basic.t b/tests/cram/test_basic.t
index 5911ac9..c33dee9 100644
--- a/tests/cram/test_basic.t
+++ b/tests/cram/test_basic.t
@@ -25,6 +25,10 @@ check that ucode provides exepected help:
-t
Enable VM execution tracing.
+ -g interval
+ Perform periodic garbage collection every `interval` object
+ allocations.
+
-S
Enable strict mode.