OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 | 5 |
6 #include "src/compiler/access-builder.h" | 6 #include "src/compiler/access-builder.h" |
7 #include "src/compiler/change-lowering.h" | 7 #include "src/compiler/change-lowering.h" |
8 #include "src/compiler/common-operator.h" | 8 #include "src/compiler/common-operator.h" |
9 #include "src/compiler/diamond.h" | 9 #include "src/compiler/diamond.h" |
10 #include "src/compiler/graph.h" | 10 #include "src/compiler/graph.h" |
(...skipping 1464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1475 *effect_ = node; | 1475 *effect_ = node; |
1476 return node; | 1476 return node; |
1477 } | 1477 } |
1478 | 1478 |
1479 | 1479 |
1480 Node* WasmGraphBuilder::StoreGlobal(uint32_t index, Node* val) { | 1480 Node* WasmGraphBuilder::StoreGlobal(uint32_t index, Node* val) { |
1481 MachineType mem_type = module_->GetGlobalType(index); | 1481 MachineType mem_type = module_->GetGlobalType(index); |
1482 Node* addr = jsgraph()->IntPtrConstant( | 1482 Node* addr = jsgraph()->IntPtrConstant( |
1483 module_->globals_area + module_->module->globals->at(index).offset); | 1483 module_->globals_area + module_->module->globals->at(index).offset); |
1484 const Operator* op = jsgraph()->machine()->Store( | 1484 const Operator* op = jsgraph()->machine()->Store( |
1485 StoreRepresentation(mem_type, kNoWriteBarrier)); | 1485 StoreRepresentation(mem_type.representation(), kNoWriteBarrier)); |
1486 Node* node = graph()->NewNode(op, addr, jsgraph()->Int32Constant(0), val, | 1486 Node* node = graph()->NewNode(op, addr, jsgraph()->Int32Constant(0), val, |
1487 *effect_, *control_); | 1487 *effect_, *control_); |
1488 *effect_ = node; | 1488 *effect_ = node; |
1489 return node; | 1489 return node; |
1490 } | 1490 } |
1491 | 1491 |
1492 | 1492 |
1493 void WasmGraphBuilder::BoundsCheckMem(MachineType memtype, Node* index, | 1493 void WasmGraphBuilder::BoundsCheckMem(MachineType memtype, Node* index, |
1494 uint32_t offset) { | 1494 uint32_t offset) { |
1495 // TODO(turbofan): fold bounds checks for constant indexes. | 1495 // TODO(turbofan): fold bounds checks for constant indexes. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1548 return load; | 1548 return load; |
1549 } | 1549 } |
1550 | 1550 |
1551 | 1551 |
1552 Node* WasmGraphBuilder::StoreMem(MachineType memtype, Node* index, | 1552 Node* WasmGraphBuilder::StoreMem(MachineType memtype, Node* index, |
1553 uint32_t offset, Node* val) { | 1553 uint32_t offset, Node* val) { |
1554 Node* store; | 1554 Node* store; |
1555 if (module_ && module_->asm_js) { | 1555 if (module_ && module_->asm_js) { |
1556 // asm.js semantics use CheckedStore (i.e. ignore OOB writes). | 1556 // asm.js semantics use CheckedStore (i.e. ignore OOB writes). |
1557 DCHECK_EQ(0, offset); | 1557 DCHECK_EQ(0, offset); |
1558 const Operator* op = jsgraph()->machine()->CheckedStore(memtype); | 1558 const Operator* op = |
| 1559 jsgraph()->machine()->CheckedStore(memtype.representation()); |
1559 store = graph()->NewNode(op, MemBuffer(0), index, MemSize(0), val, *effect_, | 1560 store = graph()->NewNode(op, MemBuffer(0), index, MemSize(0), val, *effect_, |
1560 *control_); | 1561 *control_); |
1561 } else { | 1562 } else { |
1562 // WASM semantics throw on OOB. Introduce explicit bounds check. | 1563 // WASM semantics throw on OOB. Introduce explicit bounds check. |
1563 BoundsCheckMem(memtype, index, offset); | 1564 BoundsCheckMem(memtype, index, offset); |
1564 StoreRepresentation rep(memtype, kNoWriteBarrier); | 1565 StoreRepresentation rep(memtype.representation(), kNoWriteBarrier); |
1565 store = | 1566 store = |
1566 graph()->NewNode(jsgraph()->machine()->Store(rep), MemBuffer(offset), | 1567 graph()->NewNode(jsgraph()->machine()->Store(rep), MemBuffer(offset), |
1567 index, val, *effect_, *control_); | 1568 index, val, *effect_, *control_); |
1568 } | 1569 } |
1569 *effect_ = store; | 1570 *effect_ = store; |
1570 return store; | 1571 return store; |
1571 } | 1572 } |
1572 | 1573 |
1573 | 1574 |
1574 void WasmGraphBuilder::PrintDebugName(Node* node) { | 1575 void WasmGraphBuilder::PrintDebugName(Node* node) { |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1830 code->Disassemble(buffer, os); | 1831 code->Disassemble(buffer, os); |
1831 } | 1832 } |
1832 #endif | 1833 #endif |
1833 return code; | 1834 return code; |
1834 } | 1835 } |
1835 | 1836 |
1836 | 1837 |
1837 } // namespace compiler | 1838 } // namespace compiler |
1838 } // namespace internal | 1839 } // namespace internal |
1839 } // namespace v8 | 1840 } // namespace v8 |
OLD | NEW |