[wasm] Use the functions in emscripten/stack.h to compute stack bounds. (#44819)
authormonojenkins <jo.shields+jenkins@xamarin.com>
Wed, 18 Nov 2020 01:38:57 +0000 (20:38 -0500)
committerGitHub <noreply@github.com>
Wed, 18 Nov 2020 01:38:57 +0000 (19:38 -0600)
Co-authored-by: vargaz <vargaz@users.noreply.github.com>
src/mono/mono/utils/mono-threads-wasm.c

index 33f4688..dc792e8 100644 (file)
@@ -10,6 +10,7 @@
 #include <mono/utils/mono-mmap.h>
 
 #include <emscripten.h>
+#include <emscripten/stack.h>
 #include <glib.h>
 
 #define round_down(addr, val) ((void*)((addr) & ~((val) - 1)))
@@ -18,19 +19,14 @@ EMSCRIPTEN_KEEPALIVE
 static int
 wasm_get_stack_base (void)
 {
-       // Return the bottom limit of the stack
-       return EM_ASM_INT ({
-               return STACK_MAX;
-       });
+       return emscripten_stack_get_end ();
 }
 
 EMSCRIPTEN_KEEPALIVE
 static int
 wasm_get_stack_size (void)
 {
-       return EM_ASM_INT ({
-               return TOTAL_STACK;
-       });
+       return (guint8*)emscripten_stack_get_base () - (guint8*)emscripten_stack_get_end ();
 }
 
 int