summaryrefslogtreecommitdiff
path: root/src/platform
diff options
context:
space:
mode:
Diffstat (limited to 'src/platform')
-rw-r--r--src/platform/linux.c44
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;
}