Skip to content

Commit 2bc58d6

Browse files
James MarshZzzabiyaka
authored andcommitted
Fix incorrect memory overflow values + SIMD ifdefs
1 parent a374d6c commit 2bc58d6

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

core/iwasm/interpreter/wasm_interp_fast.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5911,7 +5911,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
59115911
addr = GET_OPERAND(uint32, I32, 0); \
59125912
frame_ip += 2; \
59135913
addr_ret = GET_OFFSET(); \
5914-
CHECK_MEMORY_OVERFLOW(16); \
5914+
CHECK_MEMORY_OVERFLOW(4); \
59155915
\
59165916
simde_v128_t simde_result = simde_func(maddr); \
59175917
\
@@ -5954,7 +5954,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
59545954
offset += base;
59555955
addr = GET_OPERAND(uint32, I32, 0);
59565956

5957-
CHECK_MEMORY_OVERFLOW(32);
5957+
CHECK_MEMORY_OVERFLOW(4);
59585958
STORE_V128(maddr, data);
59595959
break;
59605960
}

core/iwasm/interpreter/wasm_loader.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7300,8 +7300,10 @@ wasm_loader_find_block_addr(WASMExecEnv *exec_env, BlockAddr *block_addr_cache,
73007300
case WASM_OP_SET_GLOBAL:
73017301
case WASM_OP_GET_GLOBAL_64:
73027302
case WASM_OP_SET_GLOBAL_64:
7303+
#if WASM_ENABLE_SIMDE != 0
73037304
case WASM_OP_GET_GLOBAL_128:
73047305
case WASM_OP_SET_GLOBAL_128:
7306+
#endif
73057307
case WASM_OP_SET_GLOBAL_AUX_STACK:
73067308
skip_leb_uint32(p, p_end); /* local index */
73077309
break;
@@ -9090,6 +9092,7 @@ preserve_referenced_local(WASMLoaderContext *loader_ctx, uint8 opcode,
90909092
bool *preserved, char *error_buf,
90919093
uint32 error_buf_size)
90929094
{
9095+
90939096
uint32 i = 0;
90949097
int16 preserved_offset = (int16)local_index;
90959098

@@ -9113,11 +9116,13 @@ preserve_referenced_local(WASMLoaderContext *loader_ctx, uint8 opcode,
91139116
loader_ctx->preserved_local_offset++;
91149117
emit_label(EXT_OP_COPY_STACK_TOP);
91159118
}
9119+
#if WASM_ENABLE_SIMDE != 0
91169120
else if (local_type == VALUE_TYPE_V128) {
91179121
if (loader_ctx->p_code_compiled)
91189122
loader_ctx->preserved_local_offset += 4;
91199123
emit_label(EXT_OP_COPY_STACK_TOP_V128);
91209124
}
9125+
#endif
91219126
else {
91229127
if (loader_ctx->p_code_compiled)
91239128
loader_ctx->preserved_local_offset += 2;
@@ -9790,11 +9795,12 @@ reserve_block_ret(WASMLoaderContext *loader_ctx, uint8 opcode,
97909795
/* insert op_copy before else opcode */
97919796
if (opcode == WASM_OP_ELSE)
97929797
skip_label();
9793-
9798+
#if WASM_ENABLE_SIMDE != 0
97949799
if (cell == 4) {
97959800
emit_label(EXT_OP_COPY_STACK_TOP_V128);
97969801
}
9797-
else {
9802+
#endif
9803+
if (cell <= 2) {
97989804
emit_label(cell == 1 ? EXT_OP_COPY_STACK_TOP
97999805
: EXT_OP_COPY_STACK_TOP_I64);
98009806
}
@@ -13115,10 +13121,12 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func,
1311513121
emit_label(EXT_OP_TEE_LOCAL_FAST);
1311613122
emit_byte(loader_ctx, (uint8)local_offset);
1311713123
}
13124+
#if WASM_ENABLE_SIMDE != 0
1311813125
else if (local_type == VALUE_TYPE_V128) {
1311913126
emit_label(EXT_OP_TEE_LOCAL_FAST_V128);
1312013127
emit_byte(loader_ctx, (uint8)local_offset);
1312113128
}
13129+
#endif
1312213130
else {
1312313131
emit_label(EXT_OP_TEE_LOCAL_FAST_I64);
1312413132
emit_byte(loader_ctx, (uint8)local_offset);
@@ -13213,11 +13221,12 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func,
1321313221
skip_label();
1321413222
emit_label(WASM_OP_GET_GLOBAL_64);
1321513223
}
13216-
13224+
#if WASM_ENABLE_SIMDE != 0
1321713225
if (global_type == VALUE_TYPE_V128) {
1321813226
skip_label();
1321913227
emit_label(WASM_OP_GET_GLOBAL_128);
1322013228
}
13229+
#endif
1322113230
#endif /* end of WASM_ENABLE_SIMDE */
1322213231
emit_uint32(loader_ctx, global_idx);
1322313232
PUSH_OFFSET_TYPE(global_type);

0 commit comments

Comments
 (0)