#ifndef SHED_GC_H #define SHED_GC_H #include #include "../patio/patio.h" #include "./std/unistd.h" #include "./primitives.h" // == Runtime types == struct RuntimeType { uint32_t children_offset; uint32_t children_count; }; extern struct RuntimeType shed__rtti[]; // == GC objects == struct ShedGcObjectHeader { struct ShedGcObjectHeader* next; uint32_t mark; uint32_t runtime_type_tag; }; bool shed__runtime__gc_is_gc_object(ShedObject object); // == Roots == typedef size_t ShedGcRootIndex; extern ShedGcRootIndex shed__runtime__gc_root_stack_index; extern struct ShedGcObjectHeader* shed__runtime__gc_root_stack[]; void shed__runtime__gc_push_root_gc_object(struct ShedGcObjectHeader* gc_root); // == Initialization == void shed__runtime__gc_init(void); // == Allocation == void* shed__runtime__gc_alloc(size_t size, uint32_t runtime_type_tag); // == Collection == void shed__runtime__gc_collect(void); // == Clearing == void shed__runtime__gc_clear(void); void shed__runtime__gc_clear_roots(void); #endif