Refine aot call_indirect opcode translation (#492)
Re-implement aot call_indirect opcode translation: when calling non-import function, translate it by LLVM call IR to call the function in AOTed code, so as to avoid calling runtime aot_call_indirect API which is much slower. For import function, keep calling aot_call_indirect API due to the possible pointer/string argument conversion. And add prompt info while app heap is corrupted, change emit_leb to emit_uint32 inter fast-interp to refine footprint. Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
This commit is contained in:
@ -1381,7 +1381,17 @@ aot_module_malloc(AOTModuleInstance *module_inst, uint32 size,
|
||||
}
|
||||
|
||||
if (!addr) {
|
||||
aot_set_exception(module_inst, "out of memory");
|
||||
if (memory_inst->heap_handle.ptr
|
||||
&& mem_allocator_is_heap_corrupted(memory_inst->heap_handle.ptr)) {
|
||||
LOG_ERROR("Error: app heap is corrupted, if the wasm file "
|
||||
"is compiled by wasi-sdk-12.0 or larger version, "
|
||||
"please add -Wl,--export=malloc -Wl,--export=free "
|
||||
" to export malloc and free functions.");
|
||||
aot_set_exception(module_inst, "app heap corrupted");
|
||||
}
|
||||
else {
|
||||
aot_set_exception(module_inst, "out of memory");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if (p_native_addr)
|
||||
@ -1804,7 +1814,6 @@ aot_invoke_native(WASMExecEnv *exec_env, uint32 func_idx,
|
||||
|
||||
bool
|
||||
aot_call_indirect(WASMExecEnv *exec_env,
|
||||
bool check_func_type, uint32 func_type_idx,
|
||||
uint32 table_elem_idx,
|
||||
uint32 argc, uint32 *argv)
|
||||
{
|
||||
@ -1816,8 +1825,7 @@ aot_call_indirect(WASMExecEnv *exec_env,
|
||||
AOTFuncType *func_type;
|
||||
void **func_ptrs = (void**)module_inst->func_ptrs.ptr, *func_ptr;
|
||||
uint32 table_size = module_inst->table_size;
|
||||
uint32 func_idx, func_type_idx1;
|
||||
uint32 ext_ret_count;
|
||||
uint32 func_type_idx, func_idx, ext_ret_count;
|
||||
AOTImportFunc *import_func;
|
||||
const char *signature = NULL;
|
||||
void *attachment = NULL;
|
||||
@ -1844,15 +1852,8 @@ aot_call_indirect(WASMExecEnv *exec_env,
|
||||
return false;
|
||||
}
|
||||
|
||||
func_type_idx1 = func_type_indexes[func_idx];
|
||||
if (check_func_type
|
||||
&& !aot_is_wasm_type_equal(module_inst, func_type_idx,
|
||||
func_type_idx1)) {
|
||||
aot_set_exception_with_id(module_inst,
|
||||
EXCE_INVALID_FUNCTION_TYPE_INDEX);
|
||||
return false;
|
||||
}
|
||||
func_type = aot_module->func_types[func_type_idx1];
|
||||
func_type_idx = func_type_indexes[func_idx];
|
||||
func_type = aot_module->func_types[func_type_idx];
|
||||
|
||||
if (!(func_ptr = func_ptrs[func_idx])) {
|
||||
bh_assert(func_idx < aot_module->import_func_count);
|
||||
|
||||
Reference in New Issue
Block a user