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

This commit is contained in:
Wenyong Huang 2021-05-13 15:13:52 +08:00 committed by GitHub
parent 64b5459066
commit 17a2167485
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 16 deletions

View File

@ -97,7 +97,6 @@ endif ()
set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake) 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") set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections -pie -fPIE")

View File

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

View File

@ -4530,7 +4530,7 @@ wasm_runtime_get_memory_data(const WASMModuleInstanceCommon *module_inst_comm,
if (module_inst_comm->module_type == Wasm_Module_AoT) { if (module_inst_comm->module_type == Wasm_Module_AoT) {
AOTModuleInstance *module_inst = (AOTModuleInstance *)module_inst_comm; AOTModuleInstance *module_inst = (AOTModuleInstance *)module_inst_comm;
AOTMemoryInstance *memory_inst = 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; return memory_inst->memory_data.ptr;
} }
#endif #endif
@ -4556,7 +4556,7 @@ wasm_runtime_get_memory_data_size(
if (module_inst_comm->module_type == Wasm_Module_AoT) { if (module_inst_comm->module_type == Wasm_Module_AoT) {
AOTModuleInstance *module_inst = (AOTModuleInstance *)module_inst_comm; AOTModuleInstance *module_inst = (AOTModuleInstance *)module_inst_comm;
AOTMemoryInstance *memory_inst = 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; return memory_inst->cur_page_count * memory_inst->num_bytes_per_page;
} }
#endif #endif