diff options
Diffstat (limited to 'runtime/src/gc.c')
| -rw-r--r-- | runtime/src/gc.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/runtime/src/gc.c b/runtime/src/gc.c new file mode 100644 index 00000000..5c485b26 --- /dev/null +++ b/runtime/src/gc.c @@ -0,0 +1,18 @@ +#include <stdbool.h> + +#include "./patio/patio.h" +#include "./gc.h" + +// The mark value for each object is initialized to 0. Each mark phase +// alternates between using 0b010 and 0b100 as the mark value. We check only for +// the bit set to 1, meaning static values can have a mark value of 0b110 to be +// considered always marked. +PatioInt current_mark_value = 0b010; + +void alternate_mark_value() { + current_mark_value ^= 0b110; +} + +bool is_marked(struct ShedGcObjectHeader* object) { + return (object->mark & current_mark_value) == current_mark_value; +} |
