Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: src/wasm/wasm-interpreter.cc

Issue 2026553002: Fix failure in RunWasmInterpreted_LoadMemI32_const_oob_misaligned on architecures that don't suppor… (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/wasm/wasm-interpreter.h" 5 #include "src/wasm/wasm-interpreter.h"
6 #include "src/wasm/ast-decoder.h" 6 #include "src/wasm/ast-decoder.h"
7 #include "src/wasm/decoder.h" 7 #include "src/wasm/decoder.h"
8 #include "src/wasm/wasm-external-refs.h" 8 #include "src/wasm/wasm-external-refs.h"
9 #include "src/wasm/wasm-module.h" 9 #include "src/wasm/wasm-module.h"
10 10
(...skipping 1429 matching lines...) Expand 10 before | Expand all | Expand 10 after
1440 #define LOAD_CASE(name, ctype, mtype) \ 1440 #define LOAD_CASE(name, ctype, mtype) \
1441 case kExpr##name: { \ 1441 case kExpr##name: { \
1442 MemoryAccessOperand operand(&decoder, code->at(pc)); \ 1442 MemoryAccessOperand operand(&decoder, code->at(pc)); \
1443 uint32_t index = Pop().to<uint32_t>(); \ 1443 uint32_t index = Pop().to<uint32_t>(); \
1444 size_t effective_mem_size = instance()->mem_size - sizeof(mtype); \ 1444 size_t effective_mem_size = instance()->mem_size - sizeof(mtype); \
1445 if (operand.offset > effective_mem_size || \ 1445 if (operand.offset > effective_mem_size || \
1446 index > (effective_mem_size - operand.offset)) { \ 1446 index > (effective_mem_size - operand.offset)) { \
1447 return DoTrap(kTrapMemOutOfBounds, pc); \ 1447 return DoTrap(kTrapMemOutOfBounds, pc); \
1448 } \ 1448 } \
1449 byte* addr = instance()->mem_start + operand.offset + index; \ 1449 byte* addr = instance()->mem_start + operand.offset + index; \
1450 /* TODO(titzer): alignment, endianness for load mem */ \ 1450 WasmVal result(static_cast<ctype>(ReadUnalignedValue<mtype>(addr))); \
1451 WasmVal result(static_cast<ctype>(*reinterpret_cast<mtype*>(addr))); \
1452 Push(pc, result); \ 1451 Push(pc, result); \
1453 len = 1 + operand.length; \ 1452 len = 1 + operand.length; \
1454 break; \ 1453 break; \
1455 } 1454 }
1456 1455
1457 LOAD_CASE(I32LoadMem8S, int32_t, int8_t); 1456 LOAD_CASE(I32LoadMem8S, int32_t, int8_t);
1458 LOAD_CASE(I32LoadMem8U, int32_t, uint8_t); 1457 LOAD_CASE(I32LoadMem8U, int32_t, uint8_t);
1459 LOAD_CASE(I32LoadMem16S, int32_t, int16_t); 1458 LOAD_CASE(I32LoadMem16S, int32_t, int16_t);
1460 LOAD_CASE(I32LoadMem16U, int32_t, uint16_t); 1459 LOAD_CASE(I32LoadMem16U, int32_t, uint16_t);
1461 LOAD_CASE(I64LoadMem8S, int64_t, int8_t); 1460 LOAD_CASE(I64LoadMem8S, int64_t, int8_t);
(...skipping 12 matching lines...) Expand all
1474 case kExpr##name: { \ 1473 case kExpr##name: { \
1475 MemoryAccessOperand operand(&decoder, code->at(pc)); \ 1474 MemoryAccessOperand operand(&decoder, code->at(pc)); \
1476 WasmVal val = Pop(); \ 1475 WasmVal val = Pop(); \
1477 uint32_t index = Pop().to<uint32_t>(); \ 1476 uint32_t index = Pop().to<uint32_t>(); \
1478 size_t effective_mem_size = instance()->mem_size - sizeof(mtype); \ 1477 size_t effective_mem_size = instance()->mem_size - sizeof(mtype); \
1479 if (operand.offset > effective_mem_size || \ 1478 if (operand.offset > effective_mem_size || \
1480 index > (effective_mem_size - operand.offset)) { \ 1479 index > (effective_mem_size - operand.offset)) { \
1481 return DoTrap(kTrapMemOutOfBounds, pc); \ 1480 return DoTrap(kTrapMemOutOfBounds, pc); \
1482 } \ 1481 } \
1483 byte* addr = instance()->mem_start + operand.offset + index; \ 1482 byte* addr = instance()->mem_start + operand.offset + index; \
1484 /* TODO(titzer): alignment, endianness for store mem */ \ 1483 WriteUnalignedValue<mtype>(addr, static_cast<mtype>(val.to<ctype>())); \
1485 *reinterpret_cast<mtype*>(addr) = static_cast<mtype>(val.to<ctype>()); \
1486 Push(pc, val); \ 1484 Push(pc, val); \
1487 len = 1 + operand.length; \ 1485 len = 1 + operand.length; \
1488 break; \ 1486 break; \
1489 } 1487 }
1490 1488
1491 STORE_CASE(I32StoreMem8, int32_t, int8_t); 1489 STORE_CASE(I32StoreMem8, int32_t, int8_t);
1492 STORE_CASE(I32StoreMem16, int32_t, int16_t); 1490 STORE_CASE(I32StoreMem16, int32_t, int16_t);
1493 STORE_CASE(I64StoreMem8, int64_t, int8_t); 1491 STORE_CASE(I64StoreMem8, int64_t, int8_t);
1494 STORE_CASE(I64StoreMem16, int64_t, int16_t); 1492 STORE_CASE(I64StoreMem16, int64_t, int16_t);
1495 STORE_CASE(I64StoreMem32, int64_t, int32_t); 1493 STORE_CASE(I64StoreMem32, int64_t, int32_t);
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
1795 1793
1796 ControlTransferMap WasmInterpreter::ComputeControlTransfersForTesting( 1794 ControlTransferMap WasmInterpreter::ComputeControlTransfersForTesting(
1797 Zone* zone, const byte* start, const byte* end) { 1795 Zone* zone, const byte* start, const byte* end) {
1798 ControlTransfers targets(zone, 0, start, end); 1796 ControlTransfers targets(zone, 0, start, end);
1799 return targets.map_; 1797 return targets.map_;
1800 } 1798 }
1801 1799
1802 } // namespace wasm 1800 } // namespace wasm
1803 } // namespace internal 1801 } // namespace internal
1804 } // namespace v8 1802 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698