diff options
author | Nathan Ringo <nathan@remexre.com> | 2024-11-29 15:37:04 -0600 |
---|---|---|
committer | Nathan Ringo <nathan@remexre.com> | 2024-11-29 15:37:04 -0600 |
commit | f54faf130e4a1f6fb75eba1634bb07a9adc038a6 (patch) | |
tree | c9360513bc5edbc5df0ad4f23875ccf32030d64e /src/platform | |
parent | b3149099a17d392289db9699b5b5d83444d25173 (diff) |
Diffstat (limited to 'src/platform')
-rw-r--r-- | src/platform/linux.c | 44 |
1 files changed, 4 insertions, 40 deletions
diff --git a/src/platform/linux.c b/src/platform/linux.c index 3305869..052c00c 100644 --- a/src/platform/linux.c +++ b/src/platform/linux.c @@ -11,49 +11,13 @@ #include <unistd.h> int main(int argc, char **argv) { - // As a test of the garbage collector, we're doing a bunch of random - // mutations. gc_init(); - srand(0); - gc_debug(); - - const struct value ZERO = {.bits = (0 << 2) | TAG_FIXNUM}; - - struct object *values = gc_alloc(64, 0); - struct object *value_slot_counts = gc_alloc(64, 0); - gc_root_push(&values); - gc_root_push(&value_slot_counts); - - for (size_t i = 0; i < 1000000; i++) { - if ((rand() & 0b11) == 0) { - size_t value_slot_count = 3; - if (!value_slot_count) - value_slot_count = 1; - size_t untraced_slot_count = rand() & 255; - struct value value = - alloc_builtin_object(ZERO, value_slot_count, untraced_slot_count); - size_t i = rand() % 63; - gc_write_value_slot(values, i, value); - gc_write_value_slot(value_slot_counts, i, - integer_of_int(value_slot_count)); - } else { - size_t i = rand() & 63; - struct value value = gc_read_value_slot(values, i); - struct value value_slot_count_value = - gc_read_value_slot(value_slot_counts, i); - if (!value.bits) - continue; - assume(get_tag(value) == TAG_BUILTIN_OBJECT); - assume(get_tag(value_slot_count_value) == TAG_FIXNUM); - struct object *obj = untag_ptr(value); - intptr_t value_slot_count = untag_fixnum(value_slot_count_value); - size_t j = rand() % value_slot_count; - size_t k = rand() % 63; - gc_write_value_slot(obj, j, gc_read_value_slot(values, k)); - } - } + bootstrap(); gc_debug(); + gc_collect(GC_COLLECT_MANUAL); + gc_debug(); + return 0; } |