Normalize wasm types (#1378)

Normalize wasm types, for the two wasm types, if their parameter types
and result types are the same, we only save one copy, so as to reduce
the footprint and simplify the type comparison in opcode CALL_INDIRECT.

And fix issue in interpreter globals_instantiate, and remove used codes.
This commit is contained in:
FromLiQg
2022-08-18 17:52:02 +08:00
committed by GitHub
parent 9cf7b88bad
commit 88bb4f3c81
8 changed files with 75 additions and 35 deletions

View File

@ -1316,7 +1316,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
val = GET_OPERAND(uint32, I32, 0);
frame_ip += 2;
if (val < 0 || val >= (int32)tbl_inst->cur_size) {
if ((uint32)val >= tbl_inst->cur_size) {
wasm_set_exception(module, "undefined element");
goto got_exception;
}
@ -1344,10 +1344,12 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
cur_func_type = cur_func->u.func_import->func_type;
else
cur_func_type = cur_func->u.func->func_type;
if (!wasm_type_equal(cur_type, cur_func_type)) {
if (cur_type != cur_func_type) {
wasm_set_exception(module, "indirect call type mismatch");
goto got_exception;
}
#if WASM_ENABLE_TAIL_CALL != 0
if (opcode == WASM_OP_RETURN_CALL_INDIRECT)
goto call_func_from_return_call;