GC bytevectors

This commit is contained in:
Justin Ethier 2016-03-23 03:53:04 -04:00
parent e92bd6cf7c
commit d73686194b
2 changed files with 20 additions and 0 deletions

13
gc.c
View file

@ -278,6 +278,16 @@ char *gc_copy_obj(object dest, char *obj, gc_thread_data *thd)
} }
return (char *)hp; return (char *)hp;
} }
case bytevector_tag: {
int i;
bytevector_type *hp = dest;
mark(hp) = thd->gc_alloc_color;
type_of(hp) = bytevector_tag;
hp->len = ((bytevector) obj)->len;
hp->data = (((char *)hp) + sizeof(bytevector_type));
memcpy(hp->data, ((bytevector) obj)->data, hp->len);
return (char *)hp;
}
case string_tag: { case string_tag: {
char *s; char *s;
string_type *hp = dest; string_type *hp = dest;
@ -449,6 +459,9 @@ size_t gc_allocated_bytes(object obj, gc_free_list *q, gc_free_list *r)
if (t == vector_tag){ if (t == vector_tag){
return gc_heap_align(sizeof(vector_type) + sizeof(object) * ((vector_type *)obj)->num_elt); return gc_heap_align(sizeof(vector_type) + sizeof(object) * ((vector_type *)obj)->num_elt);
} }
if (t == bytevector_tag) {
return gc_heap_align(sizeof(bytevector_type) + sizeof(char) * ((bytevector)obj)->len);
}
if (t == string_tag){ if (t == string_tag){
return gc_heap_align(sizeof(string_type) + string_len(obj) + 1); return gc_heap_align(sizeof(string_type) + string_len(obj) + 1);
} }

View file

@ -2366,6 +2366,12 @@ char *gc_move(char *obj, gc_thread_data *thd, int *alloci, int *heap_grown) {
obj, thd, heap_grown); obj, thd, heap_grown);
return gc_fixup_moved_obj(thd, alloci, obj, hp); return gc_fixup_moved_obj(thd, alloci, obj, hp);
} }
case bytevector_tag: {
bytevector_type *hp = gc_alloc(Cyc_heap,
sizeof(bytevector_type) + sizeof(char) * (((bytevector) obj)->len),
obj, thd, heap_grown);
return gc_fixup_moved_obj(thd, alloci, obj, hp);
}
case string_tag: { case string_tag: {
string_type *hp = gc_alloc(Cyc_heap, string_type *hp = gc_alloc(Cyc_heap,
sizeof(string_type) + ((string_len(obj) + 1)), sizeof(string_type) + ((string_len(obj) + 1)),
@ -2510,6 +2516,7 @@ int gc_minor(void *data, object low_limit, object high_limit, closure cont, obje
// No child objects to move // No child objects to move
case closure0_tag: case closure0_tag:
case macro_tag: case macro_tag:
case bytevector_tag:
case string_tag: case string_tag:
case integer_tag: case integer_tag:
case double_tag: case double_tag: