瀏覽代碼

Remove hardcoded stack size in thread_manager.c (#931)

Remove hardcoded stack size in thread_manager.c

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
Huang Qi 4 年之前
父節點
當前提交
9169eff8bb
共有 1 個文件被更改,包括 23 次插入1 次删除
  1. 23 1
      core/iwasm/libraries/thread-mgr/thread_manager.c

+ 23 - 1
core/iwasm/libraries/thread-mgr/thread_manager.c

@@ -5,6 +5,13 @@
 
 #include "thread_manager.h"
 
+#if WASM_ENABLE_INTERP != 0
+#include "../interpreter/wasm_runtime.h"
+#endif
+#if WASM_ENABLE_AOT != 0
+#include "../aot/aot_runtime.h"
+#endif
+
 #if WASM_ENABLE_DEBUG_INTERP != 0
 #include "debug_engine.h"
 #endif
@@ -341,13 +348,28 @@ wasm_cluster_spawn_exec_env(WASMExecEnv *exec_env)
     wasm_module_inst_t new_module_inst;
     WASMExecEnv *new_exec_env;
     uint32 aux_stack_start, aux_stack_size;
+    uint32 stack_size = 8192;
 
     if (!module) {
         return NULL;
     }
 
+#if WASM_ENABLE_INTERP != 0
+    if (module_inst->module_type == Wasm_Module_Bytecode) {
+        stack_size =
+            ((WASMModuleInstance *)module_inst)->default_wasm_stack_size;
+    }
+#endif
+
+#if WASM_ENABLE_AOT != 0
+    if (module_inst->module_type == Wasm_Module_AoT) {
+        stack_size =
+            ((AOTModuleInstance *)module_inst)->default_wasm_stack_size;
+    }
+#endif
+
     if (!(new_module_inst = wasm_runtime_instantiate_internal(
-              module, true, 8192, 0, NULL, 0))) {
+              module, true, stack_size, 0, NULL, 0))) {
         return NULL;
     }