[wasm] Disable posix threading backend and fix wasm's.
authorRodrigo Kumpera <kumpera@gmail.com>
Thu, 31 Aug 2017 18:18:52 +0000 (11:18 -0700)
committerRodrigo Kumpera <kumpera@gmail.com>
Fri, 1 Sep 2017 21:52:53 +0000 (14:52 -0700)
mono/utils/mono-threads-coop.c
mono/utils/mono-threads-wasm.c

index 440eff85125121729d9c330de899bf5d74e43d0f..1b9849fe5aff24f0672b6d232e28c526827f8525 100644 (file)
@@ -37,6 +37,9 @@
 #ifdef _MSC_VER
 // TODO: Find MSVC replacement for __builtin_unwind_init
 #define SAVE_REGS_ON_STACK g_assert_not_reached ();
+#elif defined (HOST_WASM)
+//TODO: figure out wasm stack scanning
+#define SAVE_REGS_ON_STACK do {} while (0)
 #else 
 #define SAVE_REGS_ON_STACK __builtin_unwind_init ();
 #endif
index 6ef8a9c5e843d7b84415ffdb13d71121930dc3ba..60816ed8d578d1cfbf9fc4d37c8688521f297833 100644 (file)
@@ -7,13 +7,13 @@
 
 #define round_down(addr, val) ((void*)((addr) & ~((val) - 1)))
 
-void
-mono_threads_platform_get_stack_bounds (guint8 **staddr, size_t *stsize)
+int
+mono_threads_get_max_stack_size (void)
 {
-       *staddr = round_down ((size_t)&staddr, 65536); //WASM pagesize is 64k
-       *stsize = 65536 * 4; //we say it's 4 pages, there isn't much that uses this beyond the GC
+       return 65536 * 8; //totally arbitrary, this value is actually useless until WASM supports multiple threads.
 }
 
+
 void
 mono_threads_suspend_init_signals (void)
 {
@@ -57,4 +57,79 @@ mono_threads_suspend_abort_syscall (MonoThreadInfo *info)
 {
 }
 
+//----
+
+gboolean
+mono_native_thread_id_equals (MonoNativeThreadId id1, MonoNativeThreadId id2)
+{
+       return id1 == id2;
+}
+
+
+MonoNativeThreadId
+mono_native_thread_id_get (void)
+{
+       return (MonoNativeThreadId)1;
+}
+
+MONO_API gboolean
+mono_native_thread_create (MonoNativeThreadId *tid, gpointer func, gpointer arg)
+{
+       g_error ("WASM doesn't support threading");
+}
+
+static const char *thread_name;
+
+void
+mono_native_thread_set_name (MonoNativeThreadId tid, const char *name)
+{
+       thread_name = g_strdup (name);
+}
+
+gboolean
+mono_native_thread_join (MonoNativeThreadId tid)
+{
+       g_error ("WASM doesn't support threading");
+       return FALSE;
+}
+
+//----
+
+gboolean
+mono_threads_platform_yield (void)
+{
+       return TRUE;
+}
+
+void
+mono_threads_platform_get_stack_bounds (guint8 **staddr, size_t *stsize)
+{
+       *staddr = round_down ((size_t)&staddr, 65536); //WASM pagesize is 64k
+       *stsize = 65536 * 4; //we say it's 4 pages, there isn't much that uses this beyond the GC
+}
+
+
+gboolean
+mono_thread_platform_create_thread (MonoThreadStart thread_fn, gpointer thread_data, gsize* const stack_size, MonoNativeThreadId *tid)
+{
+       g_error ("WASM doesn't support threading");
+       return FALSE;
+}
+
+void mono_threads_platform_init (void)
+{
+}
+
+void
+mono_threads_platform_exit (gsize exit_code)
+{
+       g_error ("WASM doesn't support threading");
+}
+
+gboolean
+mono_threads_platform_in_critical_region (MonoNativeThreadId tid)
+{
+       return FALSE;
+}
+
 #endif