diff --git a/libsuicmez/suicmez_gc.h b/libsuicmez/suicmez_gc.h index e21149d..274c9da 100644 --- a/libsuicmez/suicmez_gc.h +++ b/libsuicmez/suicmez_gc.h @@ -15,6 +15,8 @@ /* Forward declare Obj so ObjHeader can reference it */ typedef struct Obj Obj; +typedef struct TypeInfo TypeInfo; + /* Header must come first */ typedef struct ObjHeader { uint32_t size; // total object size incl header @@ -24,11 +26,11 @@ typedef struct ObjHeader { const TypeInfo *type; } ObjHeader; -typedef struct TypeInfo { +struct TypeInfo { uint16_t field_count; uint16_t pointer_count; const uint8_t *pointer_bitmap; -} TypeInfo; +}; /* Full object definition */ struct Obj { @@ -44,7 +46,7 @@ void gc_init(void); void gc_shutdown(void); // Allocate object in young generation -void* gc_alloc(size_t size); +void *gc_alloc(const TypeInfo *type, size_t payload_size); // Root management void gc_add_root(void **ptr); @@ -56,7 +58,13 @@ void gc_write_barrier(void *src, void *dst); // Minor GC slice (incremental) void gc_minor_collect_slice(size_t max_objects); -// Trigger major GC (async background) +// Trigger major GC void gc_major_collect(void); +static inline void scan_object_fields(Obj *obj); + +static void mark_obj(Obj *obj); + +void gc_collect_old(void); + #endif // SUICMEZ_GC_H \ No newline at end of file