removed some unnecessary debug output, also modified tests to recently changed gc_runtime.s

This commit is contained in:
Egor Sheremetov 2023-05-30 22:58:02 +02:00
parent 4eea9a7933
commit 5da89d0c2e
3 changed files with 16 additions and 30 deletions

View file

@ -10,19 +10,11 @@
#include <string.h>
#include <assert.h>
//#ifdef DEBUG_VERSION
#include <signal.h>
#include <unistd.h>
#include <execinfo.h>
//#endif
#ifndef DEBUG_VERSION
static const size_t INIT_HEAP_SIZE = MINIMUM_HEAP_CAPACITY;
#else
//static const size_t INIT_HEAP_SIZE = 1 << 28;
static const size_t INIT_HEAP_SIZE = 8;
#endif
#ifdef DEBUG_VERSION
size_t cur_id = 0;
@ -45,7 +37,6 @@ static memory_chunk heap;
void dump_heap();
#endif
//#ifdef DEBUG_VERSION
void handler(int sig) {
void *array[10];
size_t size;
@ -56,7 +47,6 @@ void handler(int sig) {
backtrace_symbols_fd(array, size, STDERR_FILENO);
exit(1);
}
//#endif
void *alloc(size_t size) {
#ifdef DEBUG_VERSION
@ -249,7 +239,6 @@ bool is_valid_pointer(const size_t *p) {
}
void mark(void *obj) {
fprintf(stderr, "obj ptr is %p, heap.begin is %p, heap.current is %p\n", obj, (void *) heap.begin, (void *) heap.current);
if (!is_valid_heap_pointer(obj)) {
return;
}
@ -284,14 +273,11 @@ void scan_global_area(void) {
#endif
extern void gc_test_and_mark_root(size_t **root) {
fprintf(stderr, "root ptr is %p, stack_top is %p, stack_bottom is %p\n", root, (void*) __gc_stack_top, (void*) __gc_stack_bottom);
mark((void *) *root);
}
extern void __init(void) {
//#ifdef DEBUG_VERSION
signal(SIGSEGV, handler);
//#endif
size_t space_size = INIT_HEAP_SIZE * sizeof(size_t);
srandom(time(NULL));

View file

@ -10,9 +10,9 @@
# define SET_FORWARD_ADDRESS(x, addr) (x = (GET_MARK_BIT(x) | ((int) (addr))))
# define EXTRA_ROOM_HEAP_COEFFICIENT 2 // TODO: tune this parameter
#ifdef DEBUG_VERSION
# define MINIMUM_HEAP_CAPACITY (8) // TODO: tune this parameter
# define MINIMUM_HEAP_CAPACITY (8)
#else
# define MINIMUM_HEAP_CAPACITY (1<<3) // TODO: tune this parameter
# define MINIMUM_HEAP_CAPACITY (1<<10)
#endif

View file

@ -46,7 +46,7 @@ virt_stack* init_test() {
__init();
virt_stack *st = vstack_create();
vstack_init(st);
__gc_stack_bottom = (size_t) vstack_top(st) - 4;
__gc_stack_bottom = (size_t) vstack_top(st);
return st;
}
@ -55,7 +55,7 @@ void cleanup_test(virt_stack *st) {
__shutdown();
}
void force_gc_cycle(virt_stack *st) {
__gc_stack_top = (size_t) vstack_top(st);
__gc_stack_top = (size_t) vstack_top(st) - 4;
gc_alloc(0);
__gc_stack_top = 0;
}
@ -67,7 +67,7 @@ void test_simple_string_alloc(void) {
vstack_push(st, BOX(i));
}
vstack_push(st, call_runtime_function(vstack_top(st), Bstring, 1, "abc"));
vstack_push(st, call_runtime_function(vstack_top(st) - 4, Bstring, 1, "abc"));
const int N = 10;
int ids[N];
@ -81,7 +81,7 @@ void test_simple_array_alloc(void) {
virt_stack* st = init_test();
// allocate array [ BOX(1) ] and push it onto the stack
vstack_push(st, call_runtime_function(vstack_top(st), Barray, 2, BOX(1), BOX(1)));
vstack_push(st, call_runtime_function(vstack_top(st) - 4, Barray, 2, BOX(1), BOX(1)));
const int N = 10;
int ids[N];
@ -96,7 +96,7 @@ void test_simple_sexp_alloc(void) {
// allocate sexp with one boxed field and push it onto the stack
// calling runtime function Bsexp(BOX(2), BOX(1), LtagHash("test"))
vstack_push(st, call_runtime_function(vstack_top(st), Bsexp, 3, BOX(2), BOX(1), LtagHash("test")));
vstack_push(st, call_runtime_function(vstack_top(st) - 4, Bsexp, 3, BOX(2), BOX(1), LtagHash("test")));
const int N = 10;
int ids[N];
@ -110,7 +110,7 @@ void test_simple_closure_alloc(void) {
virt_stack* st = init_test();
// allocate closure with boxed captured value and push it onto the stack
vstack_push(st, call_runtime_function(vstack_top(st), Bclosure, 3, BOX(1), NULL, BOX(1)));
vstack_push(st, call_runtime_function(vstack_top(st) - 4, Bclosure, 3, BOX(1), NULL, BOX(1)));
const int N = 10;
int ids[N];
@ -123,7 +123,7 @@ void test_simple_closure_alloc(void) {
void test_single_object_allocation_with_collection_virtual_stack(void) {
virt_stack *st = init_test();
vstack_push(st, call_runtime_function(vstack_top(st), Bstring, 1, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"));
vstack_push(st, call_runtime_function(vstack_top(st) - 4, Bstring, 1, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"));
const int N = 10;
int ids[N];
@ -136,7 +136,7 @@ void test_single_object_allocation_with_collection_virtual_stack(void) {
void test_garbage_is_reclaimed(void) {
virt_stack *st = init_test();
call_runtime_function(vstack_top(st), Bstring, 1, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
call_runtime_function(vstack_top(st) - 4, Bstring, 1, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
force_gc_cycle(st);
@ -151,7 +151,7 @@ void test_garbage_is_reclaimed(void) {
void test_alive_are_not_reclaimed(void) {
virt_stack *st = init_test();
vstack_push(st, call_runtime_function(vstack_top(st), Bstring, 1, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"));
vstack_push(st, call_runtime_function(vstack_top(st) - 4, Bstring, 1, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"));
force_gc_cycle(st);
@ -166,11 +166,11 @@ void test_alive_are_not_reclaimed(void) {
void test_small_tree_compaction(void) {
virt_stack *st = init_test();
// this one will increase heap size
call_runtime_function(vstack_top(st), Bstring, 1, "aaaaaaaaaaaaaaaaaaaaaa");
call_runtime_function(vstack_top(st) - 4, Bstring, 1, "aaaaaaaaaaaaaaaaaaaaaa");
vstack_push(st, call_runtime_function(vstack_top(st), Bstring, 1, "left-s"));
vstack_push(st, call_runtime_function(vstack_top(st), Bstring, 1, "right-s"));
vstack_push(st, call_runtime_function(vstack_top(st), Bsexp, 4, BOX(3), vstack_kth_from_start(st, 0), vstack_kth_from_start(st, 1), LtagHash("tree")));
vstack_push(st, call_runtime_function(vstack_top(st) - 4, Bstring, 1, "left-s"));
vstack_push(st, call_runtime_function(vstack_top(st) - 4, Bstring, 1, "right-s"));
vstack_push(st, call_runtime_function(vstack_top(st) - 4, Bsexp, 4, BOX(3), vstack_kth_from_start(st, 0), vstack_kth_from_start(st, 1), LtagHash("tree")));
force_gc_cycle(st);
const int SZ = 10;
int ids[SZ];
@ -206,7 +206,7 @@ size_t generate_random_obj_forest(virt_stack *st, int cnt, int seed) {
size_t obj;
if (rand() % 2) {
obj = call_runtime_function(vstack_top(st), Bsexp, 4, BOX(3), field[0], field[1], LtagHash("test"));
obj = call_runtime_function(vstack_top(st) - 4, Bsexp, 4, BOX(3), field[0], field[1], LtagHash("test"));
} else {
obj = BOX(1);
}