Update wasm app build scripts for wasi-sdk-12 and refine interpreter (#481)

Update wasm app build scripts for wasi-sdk-12.0: add --export=__main_argc_argv, remove --no-threads
Lookup function with name "__main_argc_argv" as main function besides "main"
Change module_malloc to runtime_malloc in wasi native lib
Refine classic interpreter op_block and op_br_table
Refine faster interpreter op_br_table

Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
This commit is contained in:
Wenyong Huang
2020-12-27 20:46:31 -06:00
committed by GitHub
parent 13f0b2485b
commit 724858c731
19 changed files with 144 additions and 192 deletions

View File

@ -1249,20 +1249,36 @@ recover_br_info:
HANDLE_OP_END ();
HANDLE_OP (WASM_OP_BR_TABLE):
#if WASM_ENABLE_THREAD_MGR != 0
CHECK_SUSPEND_FLAGS();
#endif
count = read_uint32(frame_ip);
didx = GET_OPERAND(uint32, 0);
frame_ip += 2;
{
uint32 arity, br_item_size;
if (!(didx >= 0 && (uint32)didx < count))
#if WASM_ENABLE_THREAD_MGR != 0
CHECK_SUSPEND_FLAGS();
#endif
count = read_uint32(frame_ip);
didx = GET_OPERAND(uint32, 0);
frame_ip += 2;
if (!(didx >= 0 && (uint32)didx < count))
didx = count;
while (didx--)
SKIP_BR_INFO();
/* all br items must have the same arity and item size,
so we only calculate the first item size */
arity = *(uint32*)frame_ip;
br_item_size = sizeof(uint32); /* arity */
if (arity) {
/* total cell num */
br_item_size += sizeof(uint32);
/* cells, src offsets and dst offsets */
br_item_size += (sizeof(uint8) + sizeof(int16) + sizeof(uint16))
* arity;
}
/* target address */
br_item_size += sizeof(uint8*);
goto recover_br_info;
frame_ip += br_item_size * didx;
goto recover_br_info;
}
HANDLE_OP (WASM_OP_RETURN):
{