mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-23 20:15:05 +02:00
Finished adding types to new GC functions
This commit is contained in:
parent
0f9ab2670d
commit
90e2fdb1f5
2 changed files with 34 additions and 2 deletions
20
gc.c
20
gc.c
|
@ -116,10 +116,28 @@ size_t gc_allocated_bytes(object obj)
|
|||
return gc_heap_align(1);
|
||||
t = type_of(obj);
|
||||
if (t == cons_tag) return gc_heap_align(sizeof(cons_type));
|
||||
if (t == macro_tag) return gc_heap_align(sizeof(macro_type));
|
||||
if (t == closure0_tag) return gc_heap_align(sizeof(closure0_type));
|
||||
if (t == closure1_tag) return gc_heap_align(sizeof(closure1_type));
|
||||
if (t == closure2_tag) return gc_heap_align(sizeof(closure2_type));
|
||||
if (t == closure3_tag) return gc_heap_align(sizeof(closure3_type));
|
||||
if (t == closure4_tag) return gc_heap_align(sizeof(closure4_type));
|
||||
if (t == closureN_tag){
|
||||
return gc_heap_align(sizeof(closureN_type) + sizeof(object) * ((closureN_type *)obj)->num_elt);
|
||||
}
|
||||
if (t == vector_tag){
|
||||
return gc_heap_align(sizeof(vector_type) + sizeof(object) * ((vector_type *)obj)->num_elt);
|
||||
}
|
||||
if (t == string_tag){
|
||||
return gc_heap_align(sizeof(string_type) + string_len(obj) + 1);
|
||||
}
|
||||
if (t == integer_tag) return gc_heap_align(sizeof(integer_type));
|
||||
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 GC_DEBUG_PRINTFS
|
||||
fprintf(stderr, "cannot get size of object %ld\n", t);
|
||||
fprintf(stderr, "gc_allocated_bytes: unexpected object %p of type %ld\n", obj, t);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
|
16
runtime.c
16
runtime.c
|
@ -2505,7 +2505,21 @@ char *gc_move(char *obj, gc_thread_data *thd, int *alloci, int *heap_grown) {
|
|||
gc_thr_add_to_move_buffer(thd, alloci, hobj);
|
||||
return (char *)hobj;
|
||||
}
|
||||
TODO case string_tag: {
|
||||
case string_tag: {
|
||||
char *s;
|
||||
string_type *hobj = gc_alloc(Cyc_heap,
|
||||
sizeof(string_type) + ((string_len(obj) + 1)),
|
||||
heap_grown);
|
||||
s = ((char *)hobj) + sizeof(string_type);
|
||||
memcpy(s, string_str(obj), string_len(obj) + 1);
|
||||
mark(hobj) = 0;
|
||||
type_of(hobj) = string_tag;
|
||||
string_len(hobj) = string_len(obj);
|
||||
string_str(hobj) = s;
|
||||
forward(obj) = hobj;
|
||||
type_of(obj) = forward_tag;
|
||||
gc_thr_add_to_move_buffer(thd, alloci, hobj);
|
||||
return (char *)hobj;
|
||||
}
|
||||
case integer_tag: {
|
||||
integer_type *hobj = gc_alloc(Cyc_heap, sizeof(integer_type), heap_grown);
|
||||
|
|
Loading…
Add table
Reference in a new issue