GC for opaques

This commit is contained in:
Justin Ethier 2016-04-19 22:11:31 -04:00
parent af76a13116
commit 7815cebd5a
2 changed files with 13 additions and 2 deletions

8
gc.c
View file

@ -347,6 +347,13 @@ char *gc_copy_obj(object dest, char *obj, gc_thread_data *thd)
hp->pvar = ((cvar_type *) obj)->pvar;
return (char *)hp;
}
case c_opaque_tag: {
c_opaque_type *hp = dest;
mark(hp) = thd->gc_alloc_color;
type_of(hp) = c_opaque_tag;
hp->ptr = ((c_opaque_type *) obj)->ptr;
return (char *)hp;
}
case mutex_tag: {
mutex_type *hp = dest;
mark(hp) = thd->gc_alloc_color;
@ -527,6 +534,7 @@ size_t gc_allocated_bytes(object obj, gc_free_list *q, gc_free_list *r)
if (t == double_tag) return gc_heap_align(sizeof(double_type));
if (t == port_tag) return gc_heap_align(sizeof(port_type));
if (t == cvar_tag) return gc_heap_align(sizeof(cvar_type));
if (t == c_opaque_tag) return gc_heap_align(sizeof(c_opaque_type));
if (t == mutex_tag) return gc_heap_align(sizeof(mutex_type));
if (t == cond_var_tag) return gc_heap_align(sizeof(cond_var_type));

View file

@ -2831,9 +2831,12 @@ char *gc_move(char *obj, gc_thread_data *thd, int *alloci, int *heap_grown) {
cvar_type *hp = gc_alloc(Cyc_heap, sizeof(cvar_type), obj, thd, heap_grown);
return gc_fixup_moved_obj(thd, alloci, obj, hp);
}
case c_opaque_tag: {
c_opaque_type *hp = gc_alloc(Cyc_heap, sizeof(c_opaque_type), obj, thd, heap_grown);
return gc_fixup_moved_obj(thd, alloci, obj, hp);
}
case forward_tag:
return (char *)forward(obj);
case c_opaque_tag: break;
case eof_tag: break;
case primitive_tag: break;
case boolean_tag: break;
@ -2965,9 +2968,9 @@ int gc_minor(void *data, object low_limit, object high_limit, closure cont, obje
case double_tag:
case port_tag:
case cvar_tag:
case c_opaque_tag:
break;
// These types are not heap-allocated
case c_opaque_tag:
case eof_tag:
case primitive_tag:
case symbol_tag: