OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/code-factory.h" | 5 #include "src/code-factory.h" |
6 #include "src/compilation-dependencies.h" | 6 #include "src/compilation-dependencies.h" |
7 #include "src/compiler/access-builder.h" | 7 #include "src/compiler/access-builder.h" |
8 #include "src/compiler/js-graph.h" | 8 #include "src/compiler/js-graph.h" |
9 #include "src/compiler/js-typed-lowering.h" | 9 #include "src/compiler/js-typed-lowering.h" |
10 #include "src/compiler/linkage.h" | 10 #include "src/compiler/linkage.h" |
(...skipping 1615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1626 Reduction JSTypedLowering::ReduceJSForInStep(Node* node) { | 1626 Reduction JSTypedLowering::ReduceJSForInStep(Node* node) { |
1627 DCHECK_EQ(IrOpcode::kJSForInStep, node->opcode()); | 1627 DCHECK_EQ(IrOpcode::kJSForInStep, node->opcode()); |
1628 node->ReplaceInput(1, jsgraph()->Int32Constant(1)); | 1628 node->ReplaceInput(1, jsgraph()->Int32Constant(1)); |
1629 NodeProperties::ChangeOp(node, machine()->Int32Add()); | 1629 NodeProperties::ChangeOp(node, machine()->Int32Add()); |
1630 return Changed(node); | 1630 return Changed(node); |
1631 } | 1631 } |
1632 | 1632 |
1633 Reduction JSTypedLowering::ReduceJSGeneratorStore(Node* node) { | 1633 Reduction JSTypedLowering::ReduceJSGeneratorStore(Node* node) { |
1634 DCHECK_EQ(IrOpcode::kJSGeneratorStore, node->opcode()); | 1634 DCHECK_EQ(IrOpcode::kJSGeneratorStore, node->opcode()); |
1635 Node* generator = NodeProperties::GetValueInput(node, 0); | 1635 Node* generator = NodeProperties::GetValueInput(node, 0); |
| 1636 Node* continuation = NodeProperties::GetValueInput(node, 1); |
1636 Node* context = NodeProperties::GetContextInput(node); | 1637 Node* context = NodeProperties::GetContextInput(node); |
1637 Node* effect = NodeProperties::GetEffectInput(node); | 1638 Node* effect = NodeProperties::GetEffectInput(node); |
1638 Node* control = NodeProperties::GetControlInput(node); | 1639 Node* control = NodeProperties::GetControlInput(node); |
1639 int register_count = OpParameter<int>(node); | 1640 int register_count = OpParameter<int>(node); |
1640 | 1641 |
1641 FieldAccess array_field = AccessBuilder::ForJSGeneratorObjectOperandStack(); | 1642 FieldAccess array_field = AccessBuilder::ForJSGeneratorObjectOperandStack(); |
1642 FieldAccess context_field = AccessBuilder::ForJSGeneratorObjectContext(); | 1643 FieldAccess context_field = AccessBuilder::ForJSGeneratorObjectContext(); |
1643 FieldAccess continuation_field = | 1644 FieldAccess continuation_field = |
1644 AccessBuilder::ForJSGeneratorObjectContinuation(); | 1645 AccessBuilder::ForJSGeneratorObjectContinuation(); |
1645 | 1646 |
1646 Node* array = graph()->NewNode(simplified()->LoadField(array_field), | 1647 Node* array = effect = graph()->NewNode(simplified()->LoadField(array_field), |
1647 generator, effect, control); | 1648 generator, effect, control); |
1648 | 1649 |
1649 for (int i = 0; i < register_count; ++i) { | 1650 for (int i = 0; i < register_count; ++i) { |
1650 Node* value = NodeProperties::GetValueInput(node, 2 + i); | 1651 Node* value = NodeProperties::GetValueInput(node, 2 + i); |
1651 effect = graph()->NewNode( | 1652 effect = graph()->NewNode( |
1652 simplified()->StoreField(AccessBuilder::ForFixedArraySlot(i)), array, | 1653 simplified()->StoreField(AccessBuilder::ForFixedArraySlot(i)), array, |
1653 value, effect, control); | 1654 value, effect, control); |
1654 } | 1655 } |
1655 | 1656 |
1656 effect = graph()->NewNode(simplified()->StoreField(context_field), generator, | 1657 effect = graph()->NewNode(simplified()->StoreField(context_field), generator, |
1657 context, effect, control); | 1658 context, effect, control); |
| 1659 effect = graph()->NewNode(simplified()->StoreField(continuation_field), |
| 1660 generator, continuation, effect, control); |
1658 | 1661 |
1659 // Change the JSGeneratorStore node to a StoreField node. | 1662 ReplaceWithValue(node, effect, effect, control); |
1660 DCHECK_EQ(0, OperatorProperties::GetFrameStateInputCount(node->op())); | 1663 return Changed(effect); |
1661 DCHECK_EQ(1, OperatorProperties::GetContextInputCount(node->op())); | |
1662 node->RemoveInput(NodeProperties::FirstContextIndex(node)); | |
1663 for (int i = 0; i < register_count; ++i) { | |
1664 node->RemoveInput(NodeProperties::FirstValueIndex(node) + 2); | |
1665 } | |
1666 NodeProperties::RemoveType(node); | |
1667 NodeProperties::ChangeOp(node, simplified()->StoreField(continuation_field)); | |
1668 | |
1669 NodeProperties::ReplaceEffectInput(node, effect); | |
1670 | |
1671 return Changed(node); | |
1672 } | 1664 } |
1673 | 1665 |
1674 Reduction JSTypedLowering::ReduceJSGeneratorRestoreContinuation(Node* node) { | 1666 Reduction JSTypedLowering::ReduceJSGeneratorRestoreContinuation(Node* node) { |
1675 DCHECK_EQ(IrOpcode::kJSGeneratorRestoreContinuation, node->opcode()); | 1667 DCHECK_EQ(IrOpcode::kJSGeneratorRestoreContinuation, node->opcode()); |
1676 Node* generator = NodeProperties::GetValueInput(node, 0); | 1668 Node* generator = NodeProperties::GetValueInput(node, 0); |
1677 Node* effect = NodeProperties::GetEffectInput(node); | 1669 Node* effect = NodeProperties::GetEffectInput(node); |
1678 Node* control = NodeProperties::GetControlInput(node); | 1670 Node* control = NodeProperties::GetControlInput(node); |
1679 | 1671 |
1680 FieldAccess continuation_field = | 1672 FieldAccess continuation_field = |
1681 AccessBuilder::ForJSGeneratorObjectContinuation(); | 1673 AccessBuilder::ForJSGeneratorObjectContinuation(); |
1682 | 1674 |
1683 Node* continuation = graph()->NewNode( | 1675 Node* continuation = effect = graph()->NewNode( |
1684 simplified()->LoadField(continuation_field), generator, effect, control); | 1676 simplified()->LoadField(continuation_field), generator, effect, control); |
| 1677 Node* executing = jsgraph()->Constant(JSGeneratorObject::kGeneratorExecuting); |
| 1678 effect = graph()->NewNode(simplified()->StoreField(continuation_field), |
| 1679 generator, executing, effect, control); |
1685 | 1680 |
1686 // Change the JSGeneratorRestoreContinuation node to a StoreField node. | 1681 ReplaceWithValue(node, continuation, effect, control); |
1687 DCHECK_EQ(0, OperatorProperties::GetFrameStateInputCount(node->op())); | 1682 return Changed(continuation); |
1688 DCHECK_EQ(1, OperatorProperties::GetContextInputCount(node->op())); | |
1689 node->RemoveInput(NodeProperties::FirstContextIndex(node)); | |
1690 node->InsertInput( | |
1691 graph()->zone(), 1, | |
1692 jsgraph()->Constant(JSGeneratorObject::kGeneratorExecuting)); | |
1693 NodeProperties::RemoveType(node); | |
1694 NodeProperties::ChangeOp(node, simplified()->StoreField(continuation_field)); | |
1695 | |
1696 NodeProperties::ReplaceEffectInput(node, continuation); | |
1697 ReplaceWithValue(node, continuation, node, control); | |
1698 | |
1699 return Changed(node); | |
1700 } | 1683 } |
1701 | 1684 |
1702 Reduction JSTypedLowering::ReduceJSGeneratorRestoreRegister(Node* node) { | 1685 Reduction JSTypedLowering::ReduceJSGeneratorRestoreRegister(Node* node) { |
1703 DCHECK_EQ(IrOpcode::kJSGeneratorRestoreRegister, node->opcode()); | 1686 DCHECK_EQ(IrOpcode::kJSGeneratorRestoreRegister, node->opcode()); |
1704 Node* generator = NodeProperties::GetValueInput(node, 0); | 1687 Node* generator = NodeProperties::GetValueInput(node, 0); |
1705 Node* effect = NodeProperties::GetEffectInput(node); | 1688 Node* effect = NodeProperties::GetEffectInput(node); |
1706 Node* control = NodeProperties::GetControlInput(node); | 1689 Node* control = NodeProperties::GetControlInput(node); |
1707 int index = OpParameter<int>(node); | 1690 int index = OpParameter<int>(node); |
1708 | 1691 |
1709 FieldAccess array_field = AccessBuilder::ForJSGeneratorObjectOperandStack(); | 1692 FieldAccess array_field = AccessBuilder::ForJSGeneratorObjectOperandStack(); |
1710 FieldAccess element_field = AccessBuilder::ForFixedArraySlot(index); | 1693 FieldAccess element_field = AccessBuilder::ForFixedArraySlot(index); |
1711 | 1694 |
1712 Node* array = graph()->NewNode(simplified()->LoadField(array_field), | 1695 Node* array = effect = graph()->NewNode(simplified()->LoadField(array_field), |
1713 generator, effect, control); | 1696 generator, effect, control); |
1714 Node* element = graph()->NewNode(simplified()->LoadField(element_field), | 1697 Node* element = effect = graph()->NewNode( |
1715 array, array, control); | 1698 simplified()->LoadField(element_field), array, effect, control); |
| 1699 Node* stale = jsgraph()->StaleRegisterConstant(); |
| 1700 effect = graph()->NewNode(simplified()->StoreField(element_field), array, |
| 1701 stale, effect, control); |
1716 | 1702 |
1717 // Change the JSGeneratorRestoreRegister node to a StoreField node. | 1703 ReplaceWithValue(node, element, effect, control); |
1718 DCHECK_EQ(0, OperatorProperties::GetFrameStateInputCount(node->op())); | 1704 return Changed(element); |
1719 DCHECK_EQ(1, OperatorProperties::GetContextInputCount(node->op())); | |
1720 node->RemoveInput(NodeProperties::FirstContextIndex(node)); | |
1721 node->ReplaceInput(0, array); | |
1722 node->InsertInput(graph()->zone(), 1, jsgraph()->StaleRegisterConstant()); | |
1723 NodeProperties::RemoveType(node); | |
1724 NodeProperties::ChangeOp(node, simplified()->StoreField(element_field)); | |
1725 | |
1726 NodeProperties::ReplaceEffectInput(node, element); | |
1727 ReplaceWithValue(node, element, node, control); | |
1728 | |
1729 return Changed(node); | |
1730 } | 1705 } |
1731 | 1706 |
1732 Reduction JSTypedLowering::ReduceSelect(Node* node) { | 1707 Reduction JSTypedLowering::ReduceSelect(Node* node) { |
1733 DCHECK_EQ(IrOpcode::kSelect, node->opcode()); | 1708 DCHECK_EQ(IrOpcode::kSelect, node->opcode()); |
1734 Node* const condition = NodeProperties::GetValueInput(node, 0); | 1709 Node* const condition = NodeProperties::GetValueInput(node, 0); |
1735 Type* const condition_type = NodeProperties::GetType(condition); | 1710 Type* const condition_type = NodeProperties::GetType(condition); |
1736 Node* const vtrue = NodeProperties::GetValueInput(node, 1); | 1711 Node* const vtrue = NodeProperties::GetValueInput(node, 1); |
1737 Type* const vtrue_type = NodeProperties::GetType(vtrue); | 1712 Type* const vtrue_type = NodeProperties::GetType(vtrue); |
1738 Node* const vfalse = NodeProperties::GetValueInput(node, 2); | 1713 Node* const vfalse = NodeProperties::GetValueInput(node, 2); |
1739 Type* const vfalse_type = NodeProperties::GetType(vfalse); | 1714 Type* const vfalse_type = NodeProperties::GetType(vfalse); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1915 } | 1890 } |
1916 | 1891 |
1917 | 1892 |
1918 CompilationDependencies* JSTypedLowering::dependencies() const { | 1893 CompilationDependencies* JSTypedLowering::dependencies() const { |
1919 return dependencies_; | 1894 return dependencies_; |
1920 } | 1895 } |
1921 | 1896 |
1922 } // namespace compiler | 1897 } // namespace compiler |
1923 } // namespace internal | 1898 } // namespace internal |
1924 } // namespace v8 | 1899 } // namespace v8 |
OLD | NEW |