mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-05-14 13:41:31 +00:00
format and update shared heap boundary check in runtime API
This commit is contained in:
parent
add69585b9
commit
e911813317
|
@ -496,25 +496,38 @@ is_app_addr_in_shared_heap(WASMModuleInstanceCommon *module_inst,
|
||||||
uint64 shared_heap_start, shared_heap_end;
|
uint64 shared_heap_start, shared_heap_end;
|
||||||
|
|
||||||
if (!heap) {
|
if (!heap) {
|
||||||
return false;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bytes == 0) {
|
if (bytes == 0) {
|
||||||
bytes = 1;
|
bytes = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (cur = heap; cur; cur = cur->chain_next) {
|
/* Early stop for app start address not in the shared heap(chain) at all */
|
||||||
shared_heap_start =
|
shared_heap_start =
|
||||||
is_memory64 ? cur->start_off_mem64 : cur->start_off_mem32;
|
is_memory64 ? heap->start_off_mem64 : heap->start_off_mem32;
|
||||||
shared_heap_end = shared_heap_start - 1 + cur->size;
|
shared_heap_end = is_memory64 ? UINT64_MAX : UINT32_MAX;
|
||||||
if (app_offset >= shared_heap_start
|
if (app_offset < shared_heap_start
|
||||||
&& app_offset <= shared_heap_end - bytes + 1) {
|
|| app_offset > shared_heap_end - bytes + 1) {
|
||||||
if (target_heap)
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Find the exact shared heap that app addr is in */
|
||||||
|
if (target_heap) {
|
||||||
|
for (cur = heap; cur; cur = cur->chain_next) {
|
||||||
|
shared_heap_start =
|
||||||
|
is_memory64 ? cur->start_off_mem64 : cur->start_off_mem32;
|
||||||
|
shared_heap_end = shared_heap_start - 1 + cur->size;
|
||||||
|
if (app_offset >= shared_heap_start
|
||||||
|
&& app_offset <= shared_heap_end - bytes + 1) {
|
||||||
*target_heap = cur;
|
*target_heap = cur;
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
fail:
|
||||||
if (target_heap)
|
if (target_heap)
|
||||||
*target_heap = NULL;
|
*target_heap = NULL;
|
||||||
return false;
|
return false;
|
||||||
|
@ -529,7 +542,7 @@ is_native_addr_in_shared_heap(WASMModuleInstanceCommon *module_inst,
|
||||||
uintptr_t base_addr, addr_int, end_addr;
|
uintptr_t base_addr, addr_int, end_addr;
|
||||||
|
|
||||||
if (!heap_head) {
|
if (!heap_head) {
|
||||||
return false;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Iterate through shared heap chain to find whether native addr in one of
|
/* Iterate through shared heap chain to find whether native addr in one of
|
||||||
|
@ -553,6 +566,7 @@ is_native_addr_in_shared_heap(WASMModuleInstanceCommon *module_inst,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fail:
|
||||||
if (target_heap)
|
if (target_heap)
|
||||||
*target_heap = NULL;
|
*target_heap = NULL;
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1719,10 +1719,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
||||||
goto got_exception;
|
goto got_exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
HANDLE_OP(WASM_OP_NOP)
|
HANDLE_OP(WASM_OP_NOP) { HANDLE_OP_END(); }
|
||||||
{
|
|
||||||
HANDLE_OP_END();
|
|
||||||
}
|
|
||||||
|
|
||||||
#if WASM_ENABLE_EXCE_HANDLING != 0
|
#if WASM_ENABLE_EXCE_HANDLING != 0
|
||||||
HANDLE_OP(WASM_OP_RETHROW)
|
HANDLE_OP(WASM_OP_RETHROW)
|
||||||
|
@ -5659,10 +5656,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
|
||||||
HANDLE_OP(WASM_OP_I32_REINTERPRET_F32)
|
HANDLE_OP(WASM_OP_I32_REINTERPRET_F32)
|
||||||
HANDLE_OP(WASM_OP_I64_REINTERPRET_F64)
|
HANDLE_OP(WASM_OP_I64_REINTERPRET_F64)
|
||||||
HANDLE_OP(WASM_OP_F32_REINTERPRET_I32)
|
HANDLE_OP(WASM_OP_F32_REINTERPRET_I32)
|
||||||
HANDLE_OP(WASM_OP_F64_REINTERPRET_I64)
|
HANDLE_OP(WASM_OP_F64_REINTERPRET_I64) { HANDLE_OP_END(); }
|
||||||
{
|
|
||||||
HANDLE_OP_END();
|
|
||||||
}
|
|
||||||
|
|
||||||
HANDLE_OP(WASM_OP_I32_EXTEND8_S)
|
HANDLE_OP(WASM_OP_I32_EXTEND8_S)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user