Skip to content

Commit 24e1a12

Browse files
committed
fix: store and retrieve exec env from module instance
1 parent c3cd8ae commit 24e1a12

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

core/iwasm/aot/aot_runtime.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,6 +1413,8 @@ aot_call_function(WASMExecEnv *exec_env, AOTFunctionInstance *function,
14131413
unsigned argc, uint32 argv[])
14141414
{
14151415
AOTModuleInstance *module_inst = (AOTModuleInstance *)exec_env->module_inst;
1416+
module_inst->e->common.exec_env = exec_env;
1417+
14161418
AOTFuncType *func_type = function->u.func.func_type;
14171419
uint32 result_count = func_type->result_count;
14181420
uint32 ext_ret_count = result_count > 1 ? result_count - 1 : 0;

core/iwasm/common/wasm_memory.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -703,8 +703,7 @@ wasm_enlarge_memory_internal(WASMModuleInstance *module, uint32 inc_page_count)
703703
if (!ret && enlarge_memory_error_cb)
704704
enlarge_memory_error_cb(inc_page_count, total_size_old, 0,
705705
failure_reason, (wasm_module_inst_t)module,
706-
wasm_runtime_get_exec_env_singleton(
707-
(WASMModuleInstanceCommon *)module));
706+
module->e->common.exec_env);
708707

709708
return ret;
710709
}
@@ -796,8 +795,7 @@ wasm_enlarge_memory_internal(WASMModuleInstance *module, uint32 inc_page_count)
796795
if (!ret && enlarge_memory_error_cb)
797796
enlarge_memory_error_cb(inc_page_count, total_size_old, 0,
798797
failure_reason, (wasm_module_inst_t)module,
799-
wasm_runtime_get_exec_env_singleton(
800-
(WASMModuleInstanceCommon *)module));
798+
module->e->common.exec_env);
801799

802800
return ret;
803801
}

core/iwasm/interpreter/wasm_runtime.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2396,6 +2396,7 @@ wasm_call_function(WASMExecEnv *exec_env, WASMFunctionInstance *function,
23962396
{
23972397
WASMModuleInstance *module_inst =
23982398
(WASMModuleInstance *)exec_env->module_inst;
2399+
module_inst->e->common.exec_env = exec_env;
23992400

24002401
/* set thread handle and stack boundary */
24012402
wasm_exec_env_set_thread_info(exec_env);

core/iwasm/interpreter/wasm_runtime.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ typedef struct CApiFuncImport {
213213
/* The common part of WASMModuleInstanceExtra and AOTModuleInstanceExtra */
214214
typedef struct WASMModuleInstanceExtraCommon {
215215
CApiFuncImport *c_api_func_imports;
216+
WASMExecEnv *exec_env;
216217
#if WASM_CONFIGUABLE_BOUNDS_CHECKS != 0
217218
/* Disable bounds checks or not */
218219
bool disable_bounds_checks;

0 commit comments

Comments
 (0)