From 2e838373a4026d65d6e30276bdd37e7a8ccf0fd7 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Mon, 20 Jan 2020 17:32:07 -0500 Subject: [PATCH] Cleanup and bug fixes --- runtime.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/runtime.c b/runtime.c index fe35656e..2a79fa99 100644 --- a/runtime.c +++ b/runtime.c @@ -508,28 +508,24 @@ object share_object(gc_thread_data *data, object var, object value, int *run_gc) // Nothing needs to be done unless we are mutating // a heap variable to point to a stack var. if (!gc_is_stack_obj(&tmp, data, var) && gc_is_stack_obj(&tmp, data, value)) { - /* TODO: - - need to transport value to heap - - if value is mutable or has children, may need to do minor GC to transport - - else can just copy it - return obj (copied) or boolean_f (need minor GC; - */ - + // Must move `value` to the heap to allow use by other threads switch(type_of(value)) { case string_tag: case bytevector_tag: if (immutable(value)) { - // Safe to transport + // Safe to transport now object hp = gc_alloc(heap, gc_allocated_bytes(value, NULL, NULL), value, data, heap_grown); return hp; } // Need to GC if obj is mutable, EG: a string could be mutated so we can't // have multiple copies of the object running around - return boolean_f; + *run_gc = 1; + return value; case double_tag: case port_tag: case c_opaque_tag: case complex_num_tag: { + // These objects are immutable, transport now object hp = gc_alloc(heap, gc_allocated_bytes(value, NULL, NULL), value, data, heap_grown); return hp; }