Kaynağa Gözat

Wrap data width according to atomic opcode specified (#936)

Wrap data width according to atomic opcode specified

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
Huang Qi 4 yıl önce
ebeveyn
işleme
9d2576d8e0

+ 5 - 0
core/iwasm/interpreter/wasm_interp_classic.c

@@ -3389,6 +3389,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
                             CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 1, maddr);
                             CHECK_ATOMIC_MEMORY_ACCESS();
 
+                            expect = (uint8)expect;
                             os_mutex_lock(&memory->mem_lock);
                             readv = (uint32)(*(uint8 *)maddr);
                             if (readv == expect)
@@ -3399,6 +3400,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
                             CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 2, maddr);
                             CHECK_ATOMIC_MEMORY_ACCESS();
 
+                            expect = (uint16)expect;
                             os_mutex_lock(&memory->mem_lock);
                             readv = (uint32)LOAD_U16(maddr);
                             if (readv == expect)
@@ -3433,6 +3435,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
                             CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 1, maddr);
                             CHECK_ATOMIC_MEMORY_ACCESS();
 
+                            expect = (uint8)expect;
                             os_mutex_lock(&memory->mem_lock);
                             readv = (uint64)(*(uint8 *)maddr);
                             if (readv == expect)
@@ -3443,6 +3446,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
                             CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 2, maddr);
                             CHECK_ATOMIC_MEMORY_ACCESS();
 
+                            expect = (uint16)expect;
                             os_mutex_lock(&memory->mem_lock);
                             readv = (uint64)LOAD_U16(maddr);
                             if (readv == expect)
@@ -3453,6 +3457,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
                             CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 4, maddr);
                             CHECK_ATOMIC_MEMORY_ACCESS();
 
+                            expect = (uint32)expect;
                             os_mutex_lock(&memory->mem_lock);
                             readv = (uint64)LOAD_U32(maddr);
                             if (readv == expect)

+ 5 - 0
core/iwasm/interpreter/wasm_interp_fast.c

@@ -3308,6 +3308,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
                             CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 1, maddr);
                             CHECK_ATOMIC_MEMORY_ACCESS(1);
 
+                            expect = (uint8)expect;
                             os_mutex_lock(&memory->mem_lock);
                             readv = (uint32)(*(uint8 *)maddr);
                             if (readv == expect)
@@ -3318,6 +3319,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
                             CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 2, maddr);
                             CHECK_ATOMIC_MEMORY_ACCESS(2);
 
+                            expect = (uint16)expect;
                             os_mutex_lock(&memory->mem_lock);
                             readv = (uint32)LOAD_U16(maddr);
                             if (readv == expect)
@@ -3352,6 +3354,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
                             CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 1, maddr);
                             CHECK_ATOMIC_MEMORY_ACCESS(1);
 
+                            expect = (uint8)expect;
                             os_mutex_lock(&memory->mem_lock);
                             readv = (uint64)(*(uint8 *)maddr);
                             if (readv == expect)
@@ -3362,6 +3365,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
                             CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 2, maddr);
                             CHECK_ATOMIC_MEMORY_ACCESS(2);
 
+                            expect = (uint16)expect;
                             os_mutex_lock(&memory->mem_lock);
                             readv = (uint64)LOAD_U16(maddr);
                             if (readv == expect)
@@ -3372,6 +3376,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
                             CHECK_BULK_MEMORY_OVERFLOW(addr + offset, 4, maddr);
                             CHECK_ATOMIC_MEMORY_ACCESS(4);
 
+                            expect = (uint32)expect;
                             os_mutex_lock(&memory->mem_lock);
                             readv = (uint64)LOAD_U32(maddr);
                             if (readv == expect)