From: Brendan Hansen Date: Tue, 23 Nov 2021 03:44:34 +0000 (-0600) Subject: bug fixes with threading X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=ed29f03998eebf2dcead2eeab148264dd7b42aa1;p=onyx.git bug fixes with threading --- diff --git a/core/runtime/common.onyx b/core/runtime/common.onyx index fe4f8fc8..0aa87931 100644 --- a/core/runtime/common.onyx +++ b/core/runtime/common.onyx @@ -54,20 +54,23 @@ __thread_initialize :: macro () { __stdio_init(); } -_thread_start :: (id: i32, tls_base: rawptr, func: (data: rawptr) -> void, data: rawptr) { - __tls_base = tls_base; - context.thread_id = id; +#if Multi_Threading_Enabled { + _thread_start :: (id: i32, tls_base: rawptr, func: (data: rawptr) -> void, data: rawptr) { + __tls_base = tls_base; + context.thread_id = id; - __stack_top = raw_alloc(alloc.heap_allocator, 1 << 20); - __thread_initialize(); + __stack_top = raw_alloc(alloc.heap_allocator, 1 << 20); + __thread_initialize(); - func(data); + func(data); - __flush_stdio(); -} + __flush_stdio(); + } -_thread_exit :: (id: i32) { - raw_free(alloc.heap_allocator, __tls_base); + _thread_exit :: (id: i32) { + thread :: package core.thread - thread.__exited(id); -} + raw_free(alloc.heap_allocator, __tls_base); + thread.__exited(id); + } +} \ No newline at end of file diff --git a/src/wasm_emit.c b/src/wasm_emit.c index 6a133ba2..3dbe6e02 100644 --- a/src/wasm_emit.c +++ b/src/wasm_emit.c @@ -3712,7 +3712,7 @@ OnyxWasmModule onyx_wasm_module_create(bh_allocator alloc) { .kind = WASM_FOREIGN_MEMORY, .min = 1024, .max = 65536, // NOTE: Why not use all 4 Gigs of memory? - .shared = context.options->runtime != Runtime_Onyx, + .shared = context.options->runtime == Runtime_Js, .mod = "onyx", .name = "memory",