From: Brendan Hansen Date: Wed, 14 Apr 2021 16:20:37 +0000 (-0500) Subject: bug fixes; removed managed heap allocator X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=c0196bb8b934abcbf2c64c361d8802d6e58136d9;p=onyx.git bug fixes; removed managed heap allocator --- diff --git a/bin/onyx b/bin/onyx index 9d538e71..944d40c2 100755 Binary files a/bin/onyx and b/bin/onyx differ diff --git a/src/onyx.c b/src/onyx.c index f9db59a2..cbd19510 100644 --- a/src/onyx.c +++ b/src/onyx.c @@ -480,8 +480,11 @@ int main(int argc, char *argv[]) { bh_scratch_init(&global_scratch, bh_heap_allocator(), 256 * 1024); // NOTE: 256 KiB global_scratch_allocator = bh_scratch_allocator(&global_scratch); - bh_managed_heap_init(&global_heap); - global_heap_allocator = bh_managed_heap_allocator(&global_heap); + // SPEED: This used to be a managed heap allocator where all allocations + // were tracked and would be automatically freed at the end of execution. + // I don't know why I ever did that because that is the job of the operating + // system when a process exits. + global_heap_allocator = bh_heap_allocator(); CompileOptions compile_opts = compile_opts_parse(global_heap_allocator, argc, argv); context_init(&compile_opts); @@ -513,7 +516,7 @@ int main(int argc, char *argv[]) { context_free(); bh_scratch_free(&global_scratch); - bh_managed_heap_free(&global_heap); + // bh_managed_heap_free(&global_heap); return compiler_progress != ONYX_COMPILER_PROGRESS_SUCCESS; } diff --git a/src/onyxwasm.c b/src/onyxwasm.c index f4ae1fc3..8c2365fd 100644 --- a/src/onyxwasm.c +++ b/src/onyxwasm.c @@ -1009,7 +1009,7 @@ EMIT_FUNC(deferred_stmts, AstNode* node) { u64 depth = bh_arr_length(mod->structured_jump_target); - while (bh_arr_last(mod->deferred_stmts).depth == depth) { + while (bh_arr_length(mod->deferred_stmts) > 0 && bh_arr_last(mod->deferred_stmts).depth == depth) { emit_statement(mod, &code, bh_arr_last(mod->deferred_stmts).stmt); bh_arr_pop(mod->deferred_stmts); }