Ver código fonte

Fix wasm-c-api JIT issue and update makefile (#630)

Wenyong Huang 4 anos atrás
pai
commit
17a2167485

+ 0 - 1
CMakeLists.txt

@@ -97,7 +97,6 @@ endif ()
 set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
 
 include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake)
-add_library(vmlib ${WAMR_RUNTIME_LIB_SOURCE})
 
 set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections -pie -fPIE")
 

+ 10 - 13
core/iwasm/aot/aot_runtime.c

@@ -1483,25 +1483,24 @@ aot_create_exec_env_and_call_function(AOTModuleInstance *module_inst,
                                       AOTFunctionInstance *func,
                                       unsigned argc, uint32 argv[])
 {
-    WASMExecEnv *exec_env;
+    WASMExecEnv *exec_env = NULL, *existing_exec_env = NULL;
     bool ret;
 
 #if WASM_ENABLE_THREAD_MGR != 0
-    WASMExecEnv *existing_exec_env = NULL;
-
-    if (!(existing_exec_env = exec_env =
-        wasm_clusters_search_exec_env(
-            (WASMModuleInstanceCommon*)module_inst))) {
+    existing_exec_env = exec_env = wasm_clusters_search_exec_env(
+            (WASMModuleInstanceCommon*)module_inst);
+#elif defined(OS_ENABLE_HW_BOUND_CHECK)
+    existing_exec_env = exec_env = aot_exec_env;
 #endif
-        if (!(exec_env = wasm_exec_env_create((WASMModuleInstanceCommon*)module_inst,
-                                            module_inst->default_wasm_stack_size))) {
+
+    if (!existing_exec_env) {
+        if (!(exec_env =
+                wasm_exec_env_create((WASMModuleInstanceCommon *)module_inst,
+                                     module_inst->default_wasm_stack_size))) {
             aot_set_exception(module_inst, "allocate memory failed");
             return false;
         }
-
-#if WASM_ENABLE_THREAD_MGR != 0
     }
-#endif
 
 #if WASM_ENABLE_REF_TYPES != 0
     wasm_runtime_prepare_call_function(exec_env, func);
@@ -1513,10 +1512,8 @@ aot_create_exec_env_and_call_function(AOTModuleInstance *module_inst,
     wasm_runtime_finalize_call_function(exec_env, func, ret, argv);
 #endif
 
-#if WASM_ENABLE_THREAD_MGR != 0
     /* don't destroy the exec_env if it's searched from the cluster */
     if (!existing_exec_env)
-#endif
         wasm_exec_env_destroy(exec_env);
 
     return ret;

+ 2 - 2
core/iwasm/common/wasm_runtime_common.c

@@ -4530,7 +4530,7 @@ wasm_runtime_get_memory_data(const WASMModuleInstanceCommon *module_inst_comm,
     if (module_inst_comm->module_type == Wasm_Module_AoT) {
         AOTModuleInstance *module_inst = (AOTModuleInstance *)module_inst_comm;
         AOTMemoryInstance *memory_inst =
-          (AOTMemoryInstance*)module_inst->memories.ptr + memory_inst_idx;
+          ((AOTMemoryInstance**)module_inst->memories.ptr)[memory_inst_idx];
         return memory_inst->memory_data.ptr;
     }
 #endif
@@ -4556,7 +4556,7 @@ wasm_runtime_get_memory_data_size(
     if (module_inst_comm->module_type == Wasm_Module_AoT) {
         AOTModuleInstance *module_inst = (AOTModuleInstance *)module_inst_comm;
         AOTMemoryInstance *memory_inst =
-          (AOTMemoryInstance*)module_inst->memories.ptr + memory_inst_idx;
+          ((AOTMemoryInstance**)module_inst->memories.ptr)[memory_inst_idx];
         return memory_inst->cur_page_count * memory_inst->num_bytes_per_page;
     }
 #endif