Refactor error/exception strings to reduce binary size (#359)

This commit is contained in:
Wenyong Huang
2020-08-21 15:11:31 +08:00
committed by GitHub
parent 89d2937cde
commit 0103f6429c
10 changed files with 321 additions and 505 deletions

View File

@ -903,7 +903,7 @@ ALLOC_FRAME(WASMExecEnv *exec_env, uint32 size, WASMInterpFrame *prev_frame)
frame->prev_frame = prev_frame;
else {
wasm_set_exception((WASMModuleInstance*)exec_env->module_inst,
"WASM interp failed: stack overflow.");
"stack overflow");
}
return frame;
@ -1244,8 +1244,7 @@ label_pop_csp_n:
uint64 total_size = sizeof(uint32) * (uint64)count;
if (total_size >= UINT32_MAX
|| !(depths = wasm_runtime_malloc((uint32)total_size))) {
wasm_set_exception(module,
"WASM interp failed: allocate memory failed.");
wasm_set_exception(module, "allocate memory failed");
goto got_exception;
}
}
@ -1303,7 +1302,7 @@ label_pop_csp_n:
*/
read_leb_uint32(frame_ip, frame_ip_end, tidx);
if (tidx >= module->module->type_count) {
wasm_set_exception(module, "type index is overflow");
wasm_set_exception(module, "unknown type");
goto got_exception;
}
cur_type = wasm_types[tidx];
@ -1839,10 +1838,6 @@ label_pop_csp_n:
if (!wasm_enlarge_memory(module, delta)) {
/* fail to memory.grow, return -1 */
PUSH_I32(-1);
if (wasm_get_exception(module)) {
os_printf("%s\n", wasm_get_exception(module));
wasm_set_exception(module, NULL);
}
}
else {
/* success, return previous page count */
@ -2762,7 +2757,7 @@ label_pop_csp_n:
}
#endif /* WASM_ENABLE_BULK_MEMORY */
default:
wasm_set_exception(module, "WASM interp failed: unsupported opcode.");
wasm_set_exception(module, "unsupported opcode");
goto got_exception;
break;
}
@ -3107,7 +3102,7 @@ label_pop_csp_n:
#if WASM_ENABLE_LABELS_AS_VALUES == 0
default:
wasm_set_exception(module, "WASM interp failed: unsupported opcode.");
wasm_set_exception(module, "unsupported opcode");
goto got_exception;
}
#endif
@ -3137,7 +3132,7 @@ label_pop_csp_n:
HANDLE_OP (EXT_OP_COPY_STACK_TOP_I64):
HANDLE_OP (EXT_OP_COPY_STACK_VALUES):
{
wasm_set_exception(module, "WASM interp failed: unsupported opcode.");
wasm_set_exception(module, "unsupported opcode");
goto got_exception;
}
#endif
@ -3192,7 +3187,7 @@ label_pop_csp_n:
+ (uint64)cur_wasm_func->max_stack_cell_num
+ ((uint64)cur_wasm_func->max_block_num) * sizeof(WASMBranchBlock) / 4;
if (all_cell_num >= UINT32_MAX) {
wasm_set_exception(module, "WASM interp failed: stack overflow.");
wasm_set_exception(module, "stack overflow");
goto got_exception;
}
@ -3288,7 +3283,7 @@ wasm_interp_call_wasm(WASMModuleInstance *module_inst,
if ((uint8*)&prev_frame < exec_env->native_stack_boundary) {
wasm_set_exception((WASMModuleInstance*)exec_env->module_inst,
"WASM interp failed: native stack overflow.");
"native stack overflow");
return;
}
@ -3310,20 +3305,16 @@ wasm_interp_call_wasm(WASMModuleInstance *module_inst,
#if WASM_ENABLE_MULTI_MODULE != 0
if (function->import_module_inst) {
LOG_DEBUG("it is a function of a sub module");
wasm_interp_call_func_import(module_inst,
exec_env,
function,
frame);
wasm_interp_call_func_import(module_inst, exec_env,
function, frame);
}
else
#endif
{
LOG_DEBUG("it is an native function");
/* it is a native function */
wasm_interp_call_func_native(module_inst,
exec_env,
function,
frame);
wasm_interp_call_func_native(module_inst, exec_env,
function, frame);
}
}
else {
@ -3339,10 +3330,12 @@ wasm_interp_call_wasm(WASMModuleInstance *module_inst,
if (function->ret_cell_num) {
LOG_DEBUG("first return value argv[0]=%d", argv[0]);
} else {
}
else {
LOG_DEBUG("no return value");
}
} else {
}
else {
LOG_DEBUG("meet an exception %s", wasm_get_exception(module_inst));
}