Add callback to handle memory.grow failures (#2522)
When embedding WAMR, this PR allows to register a callback that is invoked when memory.grow fails. In case of memory allocation failures, some languages allow to handle the error (e.g. by checking the return code of malloc/calloc in C), some others (e.g. Rust) just panic.
This commit is contained in:
@ -2400,6 +2400,9 @@ wasm_call_function(WASMExecEnv *exec_env, WASMFunctionInstance *function,
|
||||
/* set thread handle and stack boundary */
|
||||
wasm_exec_env_set_thread_info(exec_env);
|
||||
|
||||
/* set exec env so it can be later retrieved from instance */
|
||||
module_inst->e->common.cur_exec_env = exec_env;
|
||||
|
||||
interp_call_wasm(module_inst, exec_env, function, argc, argv);
|
||||
return !wasm_copy_exception(module_inst, NULL);
|
||||
}
|
||||
|
||||
@ -213,6 +213,8 @@ typedef struct CApiFuncImport {
|
||||
/* The common part of WASMModuleInstanceExtra and AOTModuleInstanceExtra */
|
||||
typedef struct WASMModuleInstanceExtraCommon {
|
||||
CApiFuncImport *c_api_func_imports;
|
||||
/* pointer to the exec env currently used */
|
||||
WASMExecEnv *cur_exec_env;
|
||||
#if WASM_CONFIGUABLE_BOUNDS_CHECKS != 0
|
||||
/* Disable bounds checks or not */
|
||||
bool disable_bounds_checks;
|
||||
|
||||
Reference in New Issue
Block a user