re-org platform APIs, simplify porting process (#201)
Co-authored-by: Xu Jun <jun1.xu@intel.com>
This commit is contained in:
@ -1401,7 +1401,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
||||
/* fail to memory.grow, return -1 */
|
||||
PUSH_I32(-1);
|
||||
if (wasm_get_exception(module)) {
|
||||
bh_printf("%s\n", wasm_get_exception(module));
|
||||
os_printf("%s\n", wasm_get_exception(module));
|
||||
wasm_set_exception(module, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@ -729,7 +729,7 @@ wasm_interp_call_func_native(WASMModuleInstance *module_inst,
|
||||
#endif /* end of WASM_ENABLE_LABELS_AS_VALUES */
|
||||
|
||||
#if WASM_ENABLE_FAST_INTERP != 0
|
||||
static void *global_handle_table[WASM_INSTRUCTION_NUM] = { 0 };
|
||||
static void **global_handle_table;
|
||||
#endif
|
||||
|
||||
static void
|
||||
@ -769,8 +769,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
||||
#undef HANDLE_OPCODE
|
||||
#if WASM_ENABLE_FAST_INTERP != 0
|
||||
if (exec_env == NULL) {
|
||||
bh_memcpy_s(global_handle_table, sizeof(void*) * WASM_INSTRUCTION_NUM,
|
||||
handle_table, sizeof(void*) * WASM_INSTRUCTION_NUM);
|
||||
global_handle_table = (void **)handle_table;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@ -1240,7 +1239,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
||||
/* fail to memory.grow, return -1 */
|
||||
frame_lp[addr_ret] = -1;
|
||||
if (wasm_get_exception(module)) {
|
||||
bh_printf("%s\n", wasm_get_exception(module));
|
||||
os_printf("%s\n", wasm_get_exception(module));
|
||||
wasm_set_exception(module, NULL);
|
||||
}
|
||||
}
|
||||
@ -2035,19 +2034,20 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
||||
HANDLE_OP (WASM_OP_TEE_LOCAL):
|
||||
{
|
||||
GET_LOCAL_INDEX_TYPE_AND_OFFSET();
|
||||
addr1 = GET_OFFSET();
|
||||
|
||||
switch (local_type) {
|
||||
case VALUE_TYPE_I32:
|
||||
case VALUE_TYPE_F32:
|
||||
*(int32*)(frame_lp + local_offset) = GET_OPERAND(uint32, 0);
|
||||
break;
|
||||
case VALUE_TYPE_I64:
|
||||
case VALUE_TYPE_F64:
|
||||
PUT_I64_TO_ADDR((uint32*)(frame_lp + local_offset), GET_OPERAND(uint64, 0));
|
||||
break;
|
||||
default:
|
||||
wasm_set_exception(module, "invalid local type");
|
||||
goto got_exception;
|
||||
if (local_type == VALUE_TYPE_I32
|
||||
|| local_type == VALUE_TYPE_F32) {
|
||||
*(int32*)(frame_lp + local_offset) = frame_lp[addr1];
|
||||
}
|
||||
else if (local_type == VALUE_TYPE_I32
|
||||
|| local_type == VALUE_TYPE_F32) {
|
||||
PUT_I64_TO_ADDR((uint32*)(frame_lp + local_offset),
|
||||
GET_I64_FROM_ADDR(frame_lp + addr1));
|
||||
}
|
||||
else {
|
||||
wasm_set_exception(module, "invalid local type");
|
||||
goto got_exception;
|
||||
}
|
||||
|
||||
HANDLE_OP_END ();
|
||||
|
||||
@ -2311,7 +2311,7 @@ wasm_loader_find_block_addr(BlockAddr *block_addr_cache,
|
||||
#if WASM_ENABLE_FAST_INTERP != 0
|
||||
|
||||
#if WASM_DEBUG_PREPROCESSOR != 0
|
||||
#define LOG_OP(...) bh_printf(__VA_ARGS__)
|
||||
#define LOG_OP(...) os_printf(__VA_ARGS__)
|
||||
#else
|
||||
#define LOG_OP(...)
|
||||
#endif
|
||||
@ -3886,6 +3886,7 @@ handle_next_reachable_block:
|
||||
}
|
||||
|
||||
case WASM_OP_DROP:
|
||||
case WASM_OP_DROP_64:
|
||||
{
|
||||
if (loader_ctx->stack_cell_num <= 0) {
|
||||
set_error_buf(error_buf, error_buf_size,
|
||||
@ -3915,7 +3916,7 @@ handle_next_reachable_block:
|
||||
}
|
||||
loader_ctx->frame_ref -= 2;
|
||||
loader_ctx->stack_cell_num -= 2;
|
||||
#if WASM_ENABLE_FAST_INTERP == 0
|
||||
#if (WASM_ENABLE_FAST_INTERP == 0) || (WASM_ENABLE_JIT != 0)
|
||||
*(p - 1) = WASM_OP_DROP_64;
|
||||
#endif
|
||||
#if WASM_ENABLE_FAST_INTERP != 0
|
||||
@ -3930,6 +3931,7 @@ handle_next_reachable_block:
|
||||
}
|
||||
|
||||
case WASM_OP_SELECT:
|
||||
case WASM_OP_SELECT_64:
|
||||
{
|
||||
uint8 ref_type;
|
||||
|
||||
@ -3948,7 +3950,7 @@ handle_next_reachable_block:
|
||||
break;
|
||||
case REF_I64_2:
|
||||
case REF_F64_2:
|
||||
#if WASM_ENABLE_FAST_INTERP == 0
|
||||
#if (WASM_ENABLE_FAST_INTERP == 0) || (WASM_ENABLE_JIT != 0)
|
||||
*(p - 1) = WASM_OP_SELECT_64;
|
||||
#endif
|
||||
#if WASM_ENABLE_FAST_INTERP != 0
|
||||
|
||||
@ -1108,7 +1108,8 @@ wasm_enlarge_memory(WASMModuleInstance *module, uint32 inc_page_count)
|
||||
{
|
||||
#if WASM_ENABLE_MEMORY_GROW != 0
|
||||
WASMMemoryInstance *memory = module->default_memory, *new_memory;
|
||||
uint32 old_page_count = memory->cur_page_count, total_size_old;
|
||||
uint32 old_page_count = memory->cur_page_count;
|
||||
uint32 total_size_old = memory->end_addr - (uint8*)memory;
|
||||
uint32 total_page_count = inc_page_count + memory->cur_page_count;
|
||||
uint64 total_size = offsetof(WASMMemoryInstance, base_addr) +
|
||||
memory->num_bytes_per_page * (uint64)total_page_count +
|
||||
@ -1135,14 +1136,14 @@ wasm_enlarge_memory(WASMModuleInstance *module, uint32 inc_page_count)
|
||||
wasm_set_exception(module, "fail to enlarge memory.");
|
||||
return false;
|
||||
}
|
||||
total_size_old = memory->end_addr - (uint8*)memory;
|
||||
bh_memcpy_s((uint8*)new_memory, (uint32)total_size,
|
||||
(uint8*)memory, total_size_old);
|
||||
memset((uint8*)new_memory + total_size_old,
|
||||
0, (uint32)total_size - total_size_old);
|
||||
wasm_runtime_free(memory);
|
||||
}
|
||||
|
||||
memset((uint8*)new_memory + total_size_old,
|
||||
0, (uint32)total_size - total_size_old);
|
||||
|
||||
new_memory->cur_page_count = total_page_count;
|
||||
new_memory->memory_data = new_memory->base_addr;
|
||||
new_memory->global_data = new_memory->memory_data +
|
||||
|
||||
Reference in New Issue
Block a user