Index: src/wasm/wasm-interpreter.cc |
diff --git a/src/wasm/wasm-interpreter.cc b/src/wasm/wasm-interpreter.cc |
index a88fa93f06df0fc95d18d60594744981546d90f6..dda4c1bb7dab0d7e0eeeb13dd19effbb0b0c056d 100644 |
--- a/src/wasm/wasm-interpreter.cc |
+++ b/src/wasm/wasm-interpreter.cc |
@@ -1459,20 +1459,20 @@ class ThreadImpl : public WasmInterpreter::Thread { |
break; |
} |
-#define LOAD_CASE(name, ctype, mtype) \ |
- case kExpr##name: { \ |
- MemoryAccessOperand operand(&decoder, code->at(pc)); \ |
- uint32_t index = Pop().to<uint32_t>(); \ |
- size_t effective_mem_size = instance()->mem_size - sizeof(mtype); \ |
- if (operand.offset > effective_mem_size || \ |
- index > (effective_mem_size - operand.offset)) { \ |
- return DoTrap(kTrapMemOutOfBounds, pc); \ |
- } \ |
- byte* addr = instance()->mem_start + operand.offset + index; \ |
- WasmVal result(static_cast<ctype>(ReadUnalignedValue<mtype>(addr))); \ |
- Push(pc, result); \ |
- len = 1 + operand.length; \ |
- break; \ |
+#define LOAD_CASE(name, ctype, mtype) \ |
+ case kExpr##name: { \ |
+ MemoryAccessOperand operand(&decoder, code->at(pc)); \ |
+ uint32_t index = Pop().to<uint32_t>(); \ |
+ size_t effective_mem_size = instance()->mem_size - sizeof(mtype); \ |
+ if (operand.offset > effective_mem_size || \ |
+ index > (effective_mem_size - operand.offset)) { \ |
+ return DoTrap(kTrapMemOutOfBounds, pc); \ |
+ } \ |
+ byte* addr = instance()->mem_start + operand.offset + index; \ |
+ WasmVal result(static_cast<ctype>(ReadLittleEndianValue<mtype>(addr))); \ |
+ Push(pc, result); \ |
+ len = 1 + operand.length; \ |
+ break; \ |
} |
LOAD_CASE(I32LoadMem8S, int32_t, int8_t); |
@@ -1491,21 +1491,21 @@ class ThreadImpl : public WasmInterpreter::Thread { |
LOAD_CASE(F64LoadMem, double, double); |
#undef LOAD_CASE |
-#define STORE_CASE(name, ctype, mtype) \ |
- case kExpr##name: { \ |
- MemoryAccessOperand operand(&decoder, code->at(pc)); \ |
- WasmVal val = Pop(); \ |
- uint32_t index = Pop().to<uint32_t>(); \ |
- size_t effective_mem_size = instance()->mem_size - sizeof(mtype); \ |
- if (operand.offset > effective_mem_size || \ |
- index > (effective_mem_size - operand.offset)) { \ |
- return DoTrap(kTrapMemOutOfBounds, pc); \ |
- } \ |
- byte* addr = instance()->mem_start + operand.offset + index; \ |
- WriteUnalignedValue<mtype>(addr, static_cast<mtype>(val.to<ctype>())); \ |
- Push(pc, val); \ |
- len = 1 + operand.length; \ |
- break; \ |
+#define STORE_CASE(name, ctype, mtype) \ |
+ case kExpr##name: { \ |
+ MemoryAccessOperand operand(&decoder, code->at(pc)); \ |
+ WasmVal val = Pop(); \ |
+ uint32_t index = Pop().to<uint32_t>(); \ |
+ size_t effective_mem_size = instance()->mem_size - sizeof(mtype); \ |
+ if (operand.offset > effective_mem_size || \ |
+ index > (effective_mem_size - operand.offset)) { \ |
+ return DoTrap(kTrapMemOutOfBounds, pc); \ |
+ } \ |
+ byte* addr = instance()->mem_start + operand.offset + index; \ |
+ WriteLittleEndianValue<mtype>(addr, static_cast<mtype>(val.to<ctype>())); \ |
+ Push(pc, val); \ |
+ len = 1 + operand.length; \ |
+ break; \ |
} |
STORE_CASE(I32StoreMem8, int32_t, int8_t); |