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/compiler/js-typed-lowering.h" | 5 #include "src/compiler/js-typed-lowering.h" |
6 | 6 |
7 #include "src/ast/modules.h" | 7 #include "src/ast/modules.h" |
8 #include "src/builtins/builtins-utils.h" | 8 #include "src/builtins/builtins-utils.h" |
9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
10 #include "src/compilation-dependencies.h" | 10 #include "src/compilation-dependencies.h" |
(...skipping 1489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1500 node->TrimInputCount(6); | 1500 node->TrimInputCount(6); |
1501 NodeProperties::ChangeOp(node, | 1501 NodeProperties::ChangeOp(node, |
1502 common()->Phi(MachineRepresentation::kTagged, 5)); | 1502 common()->Phi(MachineRepresentation::kTagged, 5)); |
1503 return Changed(node); | 1503 return Changed(node); |
1504 } | 1504 } |
1505 | 1505 |
1506 Reduction JSTypedLowering::ReduceJSLoadContext(Node* node) { | 1506 Reduction JSTypedLowering::ReduceJSLoadContext(Node* node) { |
1507 DCHECK_EQ(IrOpcode::kJSLoadContext, node->opcode()); | 1507 DCHECK_EQ(IrOpcode::kJSLoadContext, node->opcode()); |
1508 ContextAccess const& access = ContextAccessOf(node->op()); | 1508 ContextAccess const& access = ContextAccessOf(node->op()); |
1509 Node* effect = NodeProperties::GetEffectInput(node); | 1509 Node* effect = NodeProperties::GetEffectInput(node); |
| 1510 Node* context = NodeProperties::GetContextInput(node); |
1510 Node* control = graph()->start(); | 1511 Node* control = graph()->start(); |
1511 for (size_t i = 0; i < access.depth(); ++i) { | 1512 for (size_t i = 0; i < access.depth(); ++i) { |
1512 Node* previous = effect = graph()->NewNode( | 1513 context = effect = graph()->NewNode( |
1513 simplified()->LoadField( | 1514 simplified()->LoadField( |
1514 AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX)), | 1515 AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX)), |
1515 NodeProperties::GetValueInput(node, 0), effect, control); | 1516 context, effect, control); |
1516 node->ReplaceInput(0, previous); | |
1517 } | 1517 } |
| 1518 node->ReplaceInput(0, context); |
1518 node->ReplaceInput(1, effect); | 1519 node->ReplaceInput(1, effect); |
1519 node->ReplaceInput(2, control); | 1520 node->AppendInput(jsgraph()->zone(), control); |
1520 NodeProperties::ChangeOp( | 1521 NodeProperties::ChangeOp( |
1521 node, | 1522 node, |
1522 simplified()->LoadField(AccessBuilder::ForContextSlot(access.index()))); | 1523 simplified()->LoadField(AccessBuilder::ForContextSlot(access.index()))); |
1523 return Changed(node); | 1524 return Changed(node); |
1524 } | 1525 } |
1525 | 1526 |
1526 Reduction JSTypedLowering::ReduceJSStoreContext(Node* node) { | 1527 Reduction JSTypedLowering::ReduceJSStoreContext(Node* node) { |
1527 DCHECK_EQ(IrOpcode::kJSStoreContext, node->opcode()); | 1528 DCHECK_EQ(IrOpcode::kJSStoreContext, node->opcode()); |
1528 ContextAccess const& access = ContextAccessOf(node->op()); | 1529 ContextAccess const& access = ContextAccessOf(node->op()); |
1529 Node* effect = NodeProperties::GetEffectInput(node); | 1530 Node* effect = NodeProperties::GetEffectInput(node); |
| 1531 Node* context = NodeProperties::GetContextInput(node); |
1530 Node* control = graph()->start(); | 1532 Node* control = graph()->start(); |
| 1533 Node* value = NodeProperties::GetValueInput(node, 0); |
1531 for (size_t i = 0; i < access.depth(); ++i) { | 1534 for (size_t i = 0; i < access.depth(); ++i) { |
1532 Node* previous = effect = graph()->NewNode( | 1535 context = effect = graph()->NewNode( |
1533 simplified()->LoadField( | 1536 simplified()->LoadField( |
1534 AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX)), | 1537 AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX)), |
1535 NodeProperties::GetValueInput(node, 0), effect, control); | 1538 context, effect, control); |
1536 node->ReplaceInput(0, previous); | |
1537 } | 1539 } |
1538 node->RemoveInput(2); | 1540 node->ReplaceInput(0, context); |
| 1541 node->ReplaceInput(1, value); |
1539 node->ReplaceInput(2, effect); | 1542 node->ReplaceInput(2, effect); |
1540 NodeProperties::ChangeOp( | 1543 NodeProperties::ChangeOp( |
1541 node, | 1544 node, |
1542 simplified()->StoreField(AccessBuilder::ForContextSlot(access.index()))); | 1545 simplified()->StoreField(AccessBuilder::ForContextSlot(access.index()))); |
1543 return Changed(node); | 1546 return Changed(node); |
1544 } | 1547 } |
1545 | 1548 |
1546 Reduction JSTypedLowering::ReduceJSLoadModule(Node* node) { | 1549 Reduction JSTypedLowering::ReduceJSLoadModule(Node* node) { |
1547 DCHECK_EQ(IrOpcode::kJSLoadModule, node->opcode()); | 1550 DCHECK_EQ(IrOpcode::kJSLoadModule, node->opcode()); |
1548 Node* effect = NodeProperties::GetEffectInput(node); | 1551 Node* effect = NodeProperties::GetEffectInput(node); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1641 mode == ConvertReceiverMode::kNullOrUndefined) { | 1644 mode == ConvertReceiverMode::kNullOrUndefined) { |
1642 if (context_type->IsHeapConstant()) { | 1645 if (context_type->IsHeapConstant()) { |
1643 Handle<JSObject> global_proxy( | 1646 Handle<JSObject> global_proxy( |
1644 Handle<Context>::cast(context_type->AsHeapConstant()->Value()) | 1647 Handle<Context>::cast(context_type->AsHeapConstant()->Value()) |
1645 ->global_proxy(), | 1648 ->global_proxy(), |
1646 isolate()); | 1649 isolate()); |
1647 receiver = jsgraph()->Constant(global_proxy); | 1650 receiver = jsgraph()->Constant(global_proxy); |
1648 } else { | 1651 } else { |
1649 Node* native_context = effect = graph()->NewNode( | 1652 Node* native_context = effect = graph()->NewNode( |
1650 javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true), | 1653 javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true), |
1651 context, context, effect); | 1654 context, effect); |
1652 receiver = effect = graph()->NewNode( | 1655 receiver = effect = graph()->NewNode( |
1653 javascript()->LoadContext(0, Context::GLOBAL_PROXY_INDEX, true), | 1656 javascript()->LoadContext(0, Context::GLOBAL_PROXY_INDEX, true), |
1654 native_context, native_context, effect); | 1657 native_context, effect); |
1655 } | 1658 } |
1656 ReplaceWithValue(node, receiver, effect, control); | 1659 ReplaceWithValue(node, receiver, effect, control); |
1657 return Replace(receiver); | 1660 return Replace(receiver); |
1658 } | 1661 } |
1659 | 1662 |
1660 // If {receiver} cannot be null or undefined we can skip a few checks. | 1663 // If {receiver} cannot be null or undefined we can skip a few checks. |
1661 if (!receiver_type->Maybe(Type::NullOrUndefined()) || | 1664 if (!receiver_type->Maybe(Type::NullOrUndefined()) || |
1662 mode == ConvertReceiverMode::kNotNullOrUndefined) { | 1665 mode == ConvertReceiverMode::kNotNullOrUndefined) { |
1663 Node* check = graph()->NewNode(simplified()->ObjectIsReceiver(), receiver); | 1666 Node* check = graph()->NewNode(simplified()->ObjectIsReceiver(), receiver); |
1664 Node* branch = | 1667 Node* branch = |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1746 { | 1749 { |
1747 if (context_type->IsHeapConstant()) { | 1750 if (context_type->IsHeapConstant()) { |
1748 Handle<JSObject> global_proxy( | 1751 Handle<JSObject> global_proxy( |
1749 Handle<Context>::cast(context_type->AsHeapConstant()->Value()) | 1752 Handle<Context>::cast(context_type->AsHeapConstant()->Value()) |
1750 ->global_proxy(), | 1753 ->global_proxy(), |
1751 isolate()); | 1754 isolate()); |
1752 rglobal = jsgraph()->Constant(global_proxy); | 1755 rglobal = jsgraph()->Constant(global_proxy); |
1753 } else { | 1756 } else { |
1754 Node* native_context = eglobal = graph()->NewNode( | 1757 Node* native_context = eglobal = graph()->NewNode( |
1755 javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true), | 1758 javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true), |
1756 context, context, eglobal); | 1759 context, eglobal); |
1757 rglobal = eglobal = graph()->NewNode( | 1760 rglobal = eglobal = graph()->NewNode( |
1758 javascript()->LoadContext(0, Context::GLOBAL_PROXY_INDEX, true), | 1761 javascript()->LoadContext(0, Context::GLOBAL_PROXY_INDEX, true), |
1759 native_context, native_context, eglobal); | 1762 native_context, eglobal); |
1760 } | 1763 } |
1761 } | 1764 } |
1762 | 1765 |
1763 control = | 1766 control = |
1764 graph()->NewNode(common()->Merge(3), if_noop, if_convert, if_global); | 1767 graph()->NewNode(common()->Merge(3), if_noop, if_convert, if_global); |
1765 effect = graph()->NewNode(common()->EffectPhi(3), enoop, econvert, eglobal, | 1768 effect = graph()->NewNode(common()->EffectPhi(3), enoop, econvert, eglobal, |
1766 control); | 1769 control); |
1767 // Morph the {node} into an appropriate Phi. | 1770 // Morph the {node} into an appropriate Phi. |
1768 ReplaceWithValue(node, node, effect, control); | 1771 ReplaceWithValue(node, node, effect, control); |
1769 node->ReplaceInput(0, rnoop); | 1772 node->ReplaceInput(0, rnoop); |
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2305 } | 2308 } |
2306 | 2309 |
2307 | 2310 |
2308 CompilationDependencies* JSTypedLowering::dependencies() const { | 2311 CompilationDependencies* JSTypedLowering::dependencies() const { |
2309 return dependencies_; | 2312 return dependencies_; |
2310 } | 2313 } |
2311 | 2314 |
2312 } // namespace compiler | 2315 } // namespace compiler |
2313 } // namespace internal | 2316 } // namespace internal |
2314 } // namespace v8 | 2317 } // namespace v8 |
OLD | NEW |