bug fixes; removed managed heap allocator
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Wed, 14 Apr 2021 16:20:37 +0000 (11:20 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Wed, 14 Apr 2021 16:20:37 +0000 (11:20 -0500)
bin/onyx
src/onyx.c
src/onyxwasm.c

index 9d538e7114c141534849b16a50ec4b45c66c236f..944d40c2d01e56a375c1dbee4c5511f58b68b173 100755 (executable)
Binary files a/bin/onyx and b/bin/onyx differ
index f9db59a261c3414b1a1995bf1f4666475a685eaa..cbd195101f37c15623a0b4d078086bc3067a771f 100644 (file)
@@ -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;
 }
index f4ae1fc3a3655edaec451bfc5df97650577d2861..8c2365fdc4b296472a12faccf7403ed523953a0a 100644 (file)
@@ -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);
     }