| diff --git a/core/iwasm/interpreter/wasm_interp_fast.c b/core/iwasm/interpreter/wasm_interp_fast.c | |
| index 103df43..5c78d30 100644 | |
| --- a/core/iwasm/interpreter/wasm_interp_fast.c | |
| +++ b/core/iwasm/interpreter/wasm_interp_fast.c | |
| @@ -58,15 +58,15 @@ typedef float64 CellType_F64; | |
| if (disable_bounds_checks || offset1 + bytes <= get_linear_mem_size()) \ | |
| /* If offset1 is in valid range, maddr must also \ | |
| be in valid range, no need to check it again. */ \ | |
| - maddr = memory->memory_data + offset1; \ | |
| + maddr = linear_mem_base + offset1; \ | |
| else { \ | |
| RIVE_OOB_DIAG( \ | |
| - "[wamr-oob] plain off=%llu bytes=%llu size=%llu " \ | |
| - "mem=%p inst0=%p inst0size=%llu\\n", \ | |
| - (unsigned long long)offset1, (unsigned long long)(bytes), \ | |
| - (unsigned long long)get_linear_mem_size(), (void *)memory, \ | |
| - (void *)module->memories[0], \ | |
| - (unsigned long long)module->memories[0]->memory_data_size);\ | |
| + "[wamr-oob] plain off=%llu bytes=%llu size=%llu " \ | |
| + "mem=%p inst0=%p inst0size=%llu\\n", \ | |
| + (unsigned long long)offset1, (unsigned long long)(bytes), \ | |
| + (unsigned long long)get_linear_mem_size(), (void *)memory, \ | |
| + (void *)module->memories[0], \ | |
| + (unsigned long long)module->memories[0]->memory_data_size); \ | |
| goto out_of_bounds; \ | |
| } \ | |
| } while (0) | |
| @@ -78,12 +78,12 @@ typedef float64 CellType_F64; | |
| if (disable_bounds_checks || offset1 + bytes <= get_linear_mem_size()) \ | |
| /* App heap space is not valid space for \ | |
| bulk memory operation */ \ | |
| - maddr = memory->memory_data + offset1; \ | |
| + maddr = linear_mem_base + offset1; \ | |
| else { \ | |
| - RIVE_OOB_DIAG( \ | |
| - "[wamr-oob] bulk off=%llu bytes=%llu size=%llu\\n", \ | |
| - (unsigned long long)offset1, (unsigned long long)(bytes), \ | |
| - (unsigned long long)get_linear_mem_size()); \ | |
| + RIVE_OOB_DIAG("[wamr-oob] bulk off=%llu bytes=%llu size=%llu\\n", \ | |
| + (unsigned long long)offset1, \ | |
| + (unsigned long long)(bytes), \ | |
| + (unsigned long long)get_linear_mem_size()); \ | |
| goto out_of_bounds; \ | |
| } \ | |
| } while (0) | |
| @@ -1615,12 +1615,17 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, | |
| || WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS == 0 \ | |
| || WASM_ENABLE_BULK_MEMORY != 0 | |
| uint64 linear_mem_size = 0; | |
| - if (memory) | |
| + /* rive patch: cached beside linear_mem_size and refreshed at the same | |
| + points, so hot handlers skip the memory_data indirection */ | |
| + uint8 *linear_mem_base = NULL; | |
| + if (memory) { | |
| #if WASM_ENABLE_THREAD_MGR == 0 | |
| linear_mem_size = memory->memory_data_size; | |
| #else | |
| linear_mem_size = GET_LINEAR_MEMORY_SIZE(memory); | |
| #endif | |
| + linear_mem_base = memory->memory_data; | |
| + } | |
| #endif | |
| WASMGlobalInstance *globals = module->e ? module->e->globals : NULL; | |
| WASMGlobalInstance *global; | |
| @@ -4252,6 +4257,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, | |
| || WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS == 0 \ | |
| || WASM_ENABLE_BULK_MEMORY != 0 | |
| linear_mem_size = GET_LINEAR_MEMORY_SIZE(memory); | |
| + linear_mem_base = memory->memory_data; | |
| #endif | |
| } | |
| @@ -5405,6 +5411,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, | |
| since this frame cached the size; bulk bounds | |
| must never use a stale value. */ | |
| linear_mem_size = GET_LINEAR_MEMORY_SIZE(memory); | |
| + linear_mem_base = memory->memory_data; | |
| #ifndef OS_ENABLE_HW_BOUND_CHECK | |
| CHECK_BULK_MEMORY_OVERFLOW(addr, bytes, maddr); | |
| @@ -5462,6 +5469,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, | |
| since this frame cached the size; bulk bounds | |
| must never use a stale value. */ | |
| linear_mem_size = GET_LINEAR_MEMORY_SIZE(memory); | |
| + linear_mem_base = memory->memory_data; | |
| #ifndef OS_ENABLE_HW_BOUND_CHECK | |
| CHECK_BULK_MEMORY_OVERFLOW(src, len, msrc); | |
| @@ -5521,6 +5529,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, | |
| since this frame cached the size; bulk bounds | |
| must never use a stale value. */ | |
| linear_mem_size = GET_LINEAR_MEMORY_SIZE(memory); | |
| + linear_mem_base = memory->memory_data; | |
| #ifndef OS_ENABLE_HW_BOUND_CHECK | |
| CHECK_BULK_MEMORY_OVERFLOW(dst, len, mdst); | |
| @@ -7948,8 +7957,10 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, | |
| #if !defined(OS_ENABLE_HW_BOUND_CHECK) \ | |
| || WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS == 0 \ | |
| || WASM_ENABLE_BULK_MEMORY != 0 | |
| - if (memory) | |
| + if (memory) { | |
| linear_mem_size = GET_LINEAR_MEMORY_SIZE(memory); | |
| + linear_mem_base = memory->memory_data; | |
| + } | |
| #endif | |
| if (wasm_copy_exception(module, NULL)) | |
| goto got_exception; | |
| @@ -8049,8 +8060,10 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, | |
| #if !defined(OS_ENABLE_HW_BOUND_CHECK) \ | |
| || WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS == 0 \ | |
| || WASM_ENABLE_BULK_MEMORY != 0 | |
| - if (memory) | |
| + if (memory) { | |
| linear_mem_size = GET_LINEAR_MEMORY_SIZE(memory); | |
| + linear_mem_base = memory->memory_data; | |
| + } | |
| #endif | |
| #if WASM_ENABLE_GC != 0 | |
| local_cell_num = cur_func->param_cell_num + cur_func->local_cell_num; |