bug fixes with threading
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 23 Nov 2021 03:44:34 +0000 (21:44 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 23 Nov 2021 03:44:34 +0000 (21:44 -0600)
core/runtime/common.onyx
src/wasm_emit.c

index fe4f8fc86d25eb11d4dad63c24809ce1575b59c3..0aa87931aafec8a72362ac194cd9ff818ae98e6f 100644 (file)
@@ -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
index 6a133ba289472ca66053c90270d0f26b6ef4682f..3dbe6e02ff3ca9c6d55e5d22cb9f84dfe503527d 100644 (file)
@@ -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",