@@ -802,11 +802,12 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
802802 WASMInterpFrame * prev_frame )
803803{
804804 WASMMemoryInstance * memory = module -> default_memory ;
805- uint32 memory_data_size = memory
806- ? memory -> num_bytes_per_page * memory -> cur_page_count : 0 ;
805+ uint32 memory_data_size = memory ? (module -> module -> possible_memory_grow
806+ ? DEFAULT_NUM_BYTES_PER_PAGE * memory -> cur_page_count
807+ : memory -> num_bytes_per_page * memory -> cur_page_count )
808+ : 0 ;
807809 uint32 heap_base_offset = memory ? (uint32 )memory -> heap_base_offset : 0 ;
808- uint32 heap_data_size = memory
809- ? (uint32 )(memory -> heap_data_end - memory -> heap_data ) : 0 ;
810+ uint32 heap_data_size = memory ? (uint32 )(memory -> heap_data_end - memory -> heap_data ) : 0 ;
810811 WASMTableInstance * table = module -> default_table ;
811812 WASMGlobalInstance * globals = module -> globals ;
812813 uint8 * global_data = memory ? memory -> global_data : NULL ;
@@ -862,7 +863,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
862863 HANDLE_OP (WASM_OP_BLOCK ):
863864 block_ret_type = * frame_ip ++ ;
864865
865- cache_index = ((uintptr_t )frame_ip ) % block_addr_cache_size ;
866+ cache_index = ((uintptr_t )frame_ip ) & ( uintptr_t )( block_addr_cache_size - 1 ) ;
866867 if (block_addr_cache [cache_index ].frame_ip == frame_ip ) {
867868 end_addr = block_addr_cache [cache_index ].end_addr ;
868869 }
@@ -885,7 +886,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
885886 HANDLE_OP (WASM_OP_LOOP ):
886887 block_ret_type = * frame_ip ++ ;
887888
888- cache_index = ((uintptr_t )frame_ip ) % block_addr_cache_size ;
889+ cache_index = ((uintptr_t )frame_ip ) & ( uintptr_t )( block_addr_cache_size - 1 ) ;
889890 if (block_addr_cache [cache_index ].frame_ip == frame_ip ) {
890891 end_addr = block_addr_cache [cache_index ].end_addr ;
891892 }
@@ -908,7 +909,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
908909 HANDLE_OP (WASM_OP_IF ):
909910 block_ret_type = * frame_ip ++ ;
910911
911- cache_index = ((uintptr_t )frame_ip ) % block_addr_cache_size ;
912+ cache_index = ((uintptr_t )frame_ip ) & ( uintptr_t )( block_addr_cache_size - 1 ) ;
912913 if (block_addr_cache [cache_index ].frame_ip == frame_ip ) {
913914 else_addr = block_addr_cache [cache_index ].else_addr ;
914915 end_addr = block_addr_cache [cache_index ].end_addr ;
@@ -1542,7 +1543,9 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
15421543 PUSH_I32 (prev_page_count );
15431544 /* update the memory instance ptr */
15441545 memory = module -> default_memory ;
1545- memory_data_size = memory -> num_bytes_per_page * memory -> cur_page_count ;
1546+ memory_data_size = module -> module -> possible_memory_grow
1547+ ? DEFAULT_NUM_BYTES_PER_PAGE * memory -> cur_page_count
1548+ : memory -> num_bytes_per_page * memory -> cur_page_count ;
15461549 global_data = memory -> global_data ;
15471550 }
15481551
0 commit comments