diff options
author | Nathan Ringo <nathan@remexre.com> | 2024-11-28 20:13:45 -0600 |
---|---|---|
committer | Nathan Ringo <nathan@remexre.com> | 2024-11-28 20:13:45 -0600 |
commit | 16e22f9cb39a254bccd20613f7c2cfef75ae15a7 (patch) | |
tree | 2f5ce4d1676b8a5d6e127b773e755c8d622724aa | |
parent | 6f9c0c5afb2877c0e95586a6db123029eba86b9b (diff) |
Fixes GC bug.
-rw-r--r-- | src/gc/sms.c | 3 | ||||
-rw-r--r-- | src/util.c | 9 | ||||
-rw-r--r-- | src/util.h | 5 |
3 files changed, 16 insertions, 1 deletions
diff --git a/src/gc/sms.c b/src/gc/sms.c index 6261dc1..a2ab18e 100644 --- a/src/gc/sms.c +++ b/src/gc/sms.c @@ -95,7 +95,7 @@ static void gc_mark(const struct value initial_value) { // - A black object has its mark bit set, but is not pointed to by obj, nor is // it in the prev linked list. struct object *prev = NULL; - while (obj) { + for (;;) { // INVARIANT: obj points to a white object that we're about to make gray. // Since it's white, none of its fields should have the tag TAG_GC_INTERNAL, // so it shouldn't have a saved tag either. @@ -199,6 +199,7 @@ static void gc_sweep(void) { while ((header = *head)) { if ((*head)->mark) { (*head)->mark = false; + (*head)->saved_tag = 0; head = &header->next; } else { *head = header->next; @@ -11,6 +11,15 @@ noreturn void assume__failed(const char *file, int line, const char *expr) { panic_end(); } +void debugf__impl(const char *file, int line, const char *fmt, ...) { + fprintf(stderr, "%s:%d: ", file, line); + va_list ap; + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + fprintf(stderr, "\n"); +} + noreturn void todo__impl(const char *file, int line, const char *fmt, ...) { panic_begin(); printf("%s:%d: TODO: ", file, line); @@ -23,6 +23,11 @@ static inline void assume__impl(bool cond, const char *file, int line, #define assume(COND) assume__impl(COND, __FILE__, __LINE__, #COND) +__attribute__((format(printf, 3, 4))) void +debugf__impl(const char *file, int line, const char *fmt, ...); + +#define debugf(...) debugf__impl(__FILE__, __LINE__, __VA_ARGS__) + __attribute__((format(printf, 3, 4))) noreturn void todo__impl(const char *file, int line, const char *fmt, ...); |