From f54faf130e4a1f6fb75eba1634bb07a9adc038a6 Mon Sep 17 00:00:00 2001 From: Nathan Ringo Date: Fri, 29 Nov 2024 15:37:04 -0600 Subject: mop note --- src/platform/linux.c | 44 ++++---------------------------------------- 1 file changed, 4 insertions(+), 40 deletions(-) (limited to 'src/platform') 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 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; } -- cgit v1.2.3