Chromium Code Reviews| 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(); |
| 1531 for (size_t i = 0; i < access.depth(); ++i) { | 1533 for (size_t i = 0; i < access.depth(); ++i) { |
| 1532 Node* previous = effect = graph()->NewNode( | 1534 context = effect = graph()->NewNode( |
| 1533 simplified()->LoadField( | 1535 simplified()->LoadField( |
| 1534 AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX)), | 1536 AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX)), |
| 1535 NodeProperties::GetValueInput(node, 0), effect, control); | 1537 context, effect, control); |
| 1536 node->ReplaceInput(0, previous); | |
| 1537 } | 1538 } |
| 1539 node->InsertInput(jsgraph()->zone(), 0, context); | |
|
Michael Starzinger
2016/11/30 12:43:28
nit: First inserting and then removing an input is
| |
| 1538 node->RemoveInput(2); | 1540 node->RemoveInput(2); |
| 1539 node->ReplaceInput(2, effect); | 1541 node->ReplaceInput(2, effect); |
| 1540 NodeProperties::ChangeOp( | 1542 NodeProperties::ChangeOp( |
| 1541 node, | 1543 node, |
| 1542 simplified()->StoreField(AccessBuilder::ForContextSlot(access.index()))); | 1544 simplified()->StoreField(AccessBuilder::ForContextSlot(access.index()))); |
| 1543 return Changed(node); | 1545 return Changed(node); // control?? |
|
Michael Starzinger
2016/11/30 12:43:28
explanation: The {JSStoreContext} operators are ma
| |
| 1544 } | 1546 } |
| 1545 | 1547 |
| 1546 Reduction JSTypedLowering::ReduceJSLoadModule(Node* node) { | 1548 Reduction JSTypedLowering::ReduceJSLoadModule(Node* node) { |
| 1547 DCHECK_EQ(IrOpcode::kJSLoadModule, node->opcode()); | 1549 DCHECK_EQ(IrOpcode::kJSLoadModule, node->opcode()); |
| 1548 Node* effect = NodeProperties::GetEffectInput(node); | 1550 Node* effect = NodeProperties::GetEffectInput(node); |
| 1549 Node* control = NodeProperties::GetControlInput(node); | 1551 Node* control = NodeProperties::GetControlInput(node); |
| 1550 | 1552 |
| 1551 int32_t cell_index = OpParameter<int32_t>(node); | 1553 int32_t cell_index = OpParameter<int32_t>(node); |
| 1552 Node* module = NodeProperties::GetValueInput(node, 0); | 1554 Node* module = NodeProperties::GetValueInput(node, 0); |
| 1553 | 1555 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1641 mode == ConvertReceiverMode::kNullOrUndefined) { | 1643 mode == ConvertReceiverMode::kNullOrUndefined) { |
| 1642 if (context_type->IsHeapConstant()) { | 1644 if (context_type->IsHeapConstant()) { |
| 1643 Handle<JSObject> global_proxy( | 1645 Handle<JSObject> global_proxy( |
| 1644 Handle<Context>::cast(context_type->AsHeapConstant()->Value()) | 1646 Handle<Context>::cast(context_type->AsHeapConstant()->Value()) |
| 1645 ->global_proxy(), | 1647 ->global_proxy(), |
| 1646 isolate()); | 1648 isolate()); |
| 1647 receiver = jsgraph()->Constant(global_proxy); | 1649 receiver = jsgraph()->Constant(global_proxy); |
| 1648 } else { | 1650 } else { |
| 1649 Node* native_context = effect = graph()->NewNode( | 1651 Node* native_context = effect = graph()->NewNode( |
| 1650 javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true), | 1652 javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true), |
| 1651 context, context, effect); | 1653 context, effect); |
| 1652 receiver = effect = graph()->NewNode( | 1654 receiver = effect = graph()->NewNode( |
| 1653 javascript()->LoadContext(0, Context::GLOBAL_PROXY_INDEX, true), | 1655 javascript()->LoadContext(0, Context::GLOBAL_PROXY_INDEX, true), |
| 1654 native_context, native_context, effect); | 1656 native_context, effect); |
| 1655 } | 1657 } |
| 1656 ReplaceWithValue(node, receiver, effect, control); | 1658 ReplaceWithValue(node, receiver, effect, control); |
| 1657 return Replace(receiver); | 1659 return Replace(receiver); |
| 1658 } | 1660 } |
| 1659 | 1661 |
| 1660 // If {receiver} cannot be null or undefined we can skip a few checks. | 1662 // If {receiver} cannot be null or undefined we can skip a few checks. |
| 1661 if (!receiver_type->Maybe(Type::NullOrUndefined()) || | 1663 if (!receiver_type->Maybe(Type::NullOrUndefined()) || |
| 1662 mode == ConvertReceiverMode::kNotNullOrUndefined) { | 1664 mode == ConvertReceiverMode::kNotNullOrUndefined) { |
| 1663 Node* check = graph()->NewNode(simplified()->ObjectIsReceiver(), receiver); | 1665 Node* check = graph()->NewNode(simplified()->ObjectIsReceiver(), receiver); |
| 1664 Node* branch = | 1666 Node* branch = |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1746 { | 1748 { |
| 1747 if (context_type->IsHeapConstant()) { | 1749 if (context_type->IsHeapConstant()) { |
| 1748 Handle<JSObject> global_proxy( | 1750 Handle<JSObject> global_proxy( |
| 1749 Handle<Context>::cast(context_type->AsHeapConstant()->Value()) | 1751 Handle<Context>::cast(context_type->AsHeapConstant()->Value()) |
| 1750 ->global_proxy(), | 1752 ->global_proxy(), |
| 1751 isolate()); | 1753 isolate()); |
| 1752 rglobal = jsgraph()->Constant(global_proxy); | 1754 rglobal = jsgraph()->Constant(global_proxy); |
| 1753 } else { | 1755 } else { |
| 1754 Node* native_context = eglobal = graph()->NewNode( | 1756 Node* native_context = eglobal = graph()->NewNode( |
| 1755 javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true), | 1757 javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true), |
| 1756 context, context, eglobal); | 1758 context, eglobal); |
| 1757 rglobal = eglobal = graph()->NewNode( | 1759 rglobal = eglobal = graph()->NewNode( |
| 1758 javascript()->LoadContext(0, Context::GLOBAL_PROXY_INDEX, true), | 1760 javascript()->LoadContext(0, Context::GLOBAL_PROXY_INDEX, true), |
| 1759 native_context, native_context, eglobal); | 1761 native_context, eglobal); |
| 1760 } | 1762 } |
| 1761 } | 1763 } |
| 1762 | 1764 |
| 1763 control = | 1765 control = |
| 1764 graph()->NewNode(common()->Merge(3), if_noop, if_convert, if_global); | 1766 graph()->NewNode(common()->Merge(3), if_noop, if_convert, if_global); |
| 1765 effect = graph()->NewNode(common()->EffectPhi(3), enoop, econvert, eglobal, | 1767 effect = graph()->NewNode(common()->EffectPhi(3), enoop, econvert, eglobal, |
| 1766 control); | 1768 control); |
| 1767 // Morph the {node} into an appropriate Phi. | 1769 // Morph the {node} into an appropriate Phi. |
| 1768 ReplaceWithValue(node, node, effect, control); | 1770 ReplaceWithValue(node, node, effect, control); |
| 1769 node->ReplaceInput(0, rnoop); | 1771 node->ReplaceInput(0, rnoop); |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2305 } | 2307 } |
| 2306 | 2308 |
| 2307 | 2309 |
| 2308 CompilationDependencies* JSTypedLowering::dependencies() const { | 2310 CompilationDependencies* JSTypedLowering::dependencies() const { |
| 2309 return dependencies_; | 2311 return dependencies_; |
| 2310 } | 2312 } |
| 2311 | 2313 |
| 2312 } // namespace compiler | 2314 } // namespace compiler |
| 2313 } // namespace internal | 2315 } // namespace internal |
| 2314 } // namespace v8 | 2316 } // namespace v8 |
| OLD | NEW |