mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-11 23:07:36 +02:00
Cleanup and bug fixes
This commit is contained in:
parent
c95b066b0a
commit
2e838373a4
1 changed files with 5 additions and 9 deletions
14
runtime.c
14
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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue