From ed29f03998eebf2dcead2eeab148264dd7b42aa1 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Mon, 22 Nov 2021 21:44:34 -0600 Subject: [PATCH] bug fixes with threading --- core/runtime/common.onyx | 27 +++++++++++++++------------ src/wasm_emit.c | 2 +- 2 files changed, 16 insertions(+), 13 deletions(-) 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", -- 2.25.1