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/compiler/access-builder.h" | 6 #include "src/compiler/access-builder.h" |
7 #include "src/compiler/js-graph.h" | 7 #include "src/compiler/js-graph.h" |
8 #include "src/compiler/js-typed-lowering.h" | 8 #include "src/compiler/js-typed-lowering.h" |
9 #include "src/compiler/linkage.h" | 9 #include "src/compiler/linkage.h" |
10 #include "src/compiler/node-matchers.h" | 10 #include "src/compiler/node-matchers.h" |
(...skipping 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1090 graph()->NewNode(common()->Merge(2), check_true, check_false); | 1090 graph()->NewNode(common()->Merge(2), check_true, check_false); |
1091 Node* new_effect = | 1091 Node* new_effect = |
1092 graph()->NewNode(common()->EffectPhi(2), fast, slow, new_control); | 1092 graph()->NewNode(common()->EffectPhi(2), fast, slow, new_control); |
1093 Node* new_value = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), fast, | 1093 Node* new_value = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), fast, |
1094 slow, new_control); | 1094 slow, new_control); |
1095 ReplaceWithValue(node, new_value, new_effect, new_control); | 1095 ReplaceWithValue(node, new_value, new_effect, new_control); |
1096 return Changed(new_value); | 1096 return Changed(new_value); |
1097 } | 1097 } |
1098 | 1098 |
1099 | 1099 |
| 1100 Reduction JSTypedLowering::ReduceJSCreateArguments(Node* node) { |
| 1101 DCHECK_EQ(IrOpcode::kJSCreateArguments, node->opcode()); |
| 1102 CreateArgumentsParameters const& p = CreateArgumentsParametersOf(node->op()); |
| 1103 Node* const frame_state = NodeProperties::GetFrameStateInput(node, 0); |
| 1104 Node* const outer_state = frame_state->InputAt(kFrameStateOuterStateInput); |
| 1105 FrameStateInfo state_info = OpParameter<FrameStateInfo>(frame_state); |
| 1106 |
| 1107 // Use the ArgumentsAccessStub for materializing both mapped and unmapped |
| 1108 // arguments object, but only for non-inlined (i.e. outermost) frames. |
| 1109 if (p.type() != CreateArgumentsParameters::kRestArray && |
| 1110 outer_state->opcode() != IrOpcode::kFrameState) { |
| 1111 Isolate* isolate = jsgraph()->isolate(); |
| 1112 ArgumentsAccessStub::Type type = |
| 1113 p.type() == CreateArgumentsParameters::kUnmappedArguments |
| 1114 ? ArgumentsAccessStub::NEW_STRICT |
| 1115 : ArgumentsAccessStub::NEW_SLOPPY_SLOW; |
| 1116 Callable callable = CodeFactory::ArgumentsAccess(isolate, type); |
| 1117 CallDescriptor* desc = Linkage::GetStubCallDescriptor( |
| 1118 isolate, graph()->zone(), callable.descriptor(), 0, |
| 1119 CallDescriptor::kNeedsFrameState); |
| 1120 const Operator* new_op = common()->Call(desc); |
| 1121 int parameter_count = state_info.parameter_count() - 1; |
| 1122 int parameter_offset = parameter_count * kPointerSize; |
| 1123 int offset = StandardFrameConstants::kCallerSPOffset + parameter_offset; |
| 1124 Node* stub_code = jsgraph()->HeapConstant(callable.code()); |
| 1125 Node* parameter_pointer = graph()->NewNode( |
| 1126 machine()->IntAdd(), graph()->NewNode(machine()->LoadFramePointer()), |
| 1127 jsgraph()->Constant(offset)); |
| 1128 node->InsertInput(graph()->zone(), 0, stub_code); |
| 1129 node->InsertInput(graph()->zone(), 2, jsgraph()->Constant(parameter_count)); |
| 1130 node->InsertInput(graph()->zone(), 3, parameter_pointer); |
| 1131 node->set_op(new_op); |
| 1132 return Changed(node); |
| 1133 } |
| 1134 |
| 1135 return NoChange(); |
| 1136 } |
| 1137 |
| 1138 |
1100 Reduction JSTypedLowering::ReduceJSCreateClosure(Node* node) { | 1139 Reduction JSTypedLowering::ReduceJSCreateClosure(Node* node) { |
1101 DCHECK_EQ(IrOpcode::kJSCreateClosure, node->opcode()); | 1140 DCHECK_EQ(IrOpcode::kJSCreateClosure, node->opcode()); |
1102 CreateClosureParameters const& p = CreateClosureParametersOf(node->op()); | 1141 CreateClosureParameters const& p = CreateClosureParametersOf(node->op()); |
1103 Handle<SharedFunctionInfo> shared = p.shared_info(); | 1142 Handle<SharedFunctionInfo> shared = p.shared_info(); |
1104 | 1143 |
1105 // Use the FastNewClosureStub that allocates in new space only for nested | 1144 // Use the FastNewClosureStub that allocates in new space only for nested |
1106 // functions that don't need literals cloning. | 1145 // functions that don't need literals cloning. |
1107 if (p.pretenure() == NOT_TENURED && shared->num_literals() == 0) { | 1146 if (p.pretenure() == NOT_TENURED && shared->num_literals() == 0) { |
1108 Isolate* isolate = jsgraph()->isolate(); | 1147 Isolate* isolate = jsgraph()->isolate(); |
1109 Callable callable = CodeFactory::FastNewClosure( | 1148 Callable callable = CodeFactory::FastNewClosure( |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1644 case IrOpcode::kJSStoreProperty: | 1683 case IrOpcode::kJSStoreProperty: |
1645 return ReduceJSStoreProperty(node); | 1684 return ReduceJSStoreProperty(node); |
1646 case IrOpcode::kJSLoadContext: | 1685 case IrOpcode::kJSLoadContext: |
1647 return ReduceJSLoadContext(node); | 1686 return ReduceJSLoadContext(node); |
1648 case IrOpcode::kJSStoreContext: | 1687 case IrOpcode::kJSStoreContext: |
1649 return ReduceJSStoreContext(node); | 1688 return ReduceJSStoreContext(node); |
1650 case IrOpcode::kJSLoadDynamicGlobal: | 1689 case IrOpcode::kJSLoadDynamicGlobal: |
1651 return ReduceJSLoadDynamicGlobal(node); | 1690 return ReduceJSLoadDynamicGlobal(node); |
1652 case IrOpcode::kJSLoadDynamicContext: | 1691 case IrOpcode::kJSLoadDynamicContext: |
1653 return ReduceJSLoadDynamicContext(node); | 1692 return ReduceJSLoadDynamicContext(node); |
| 1693 case IrOpcode::kJSCreateArguments: |
| 1694 return ReduceJSCreateArguments(node); |
1654 case IrOpcode::kJSCreateClosure: | 1695 case IrOpcode::kJSCreateClosure: |
1655 return ReduceJSCreateClosure(node); | 1696 return ReduceJSCreateClosure(node); |
1656 case IrOpcode::kJSCreateLiteralArray: | 1697 case IrOpcode::kJSCreateLiteralArray: |
1657 return ReduceJSCreateLiteralArray(node); | 1698 return ReduceJSCreateLiteralArray(node); |
1658 case IrOpcode::kJSCreateLiteralObject: | 1699 case IrOpcode::kJSCreateLiteralObject: |
1659 return ReduceJSCreateLiteralObject(node); | 1700 return ReduceJSCreateLiteralObject(node); |
1660 case IrOpcode::kJSCreateWithContext: | 1701 case IrOpcode::kJSCreateWithContext: |
1661 return ReduceJSCreateWithContext(node); | 1702 return ReduceJSCreateWithContext(node); |
1662 case IrOpcode::kJSCreateBlockContext: | 1703 case IrOpcode::kJSCreateBlockContext: |
1663 return ReduceJSCreateBlockContext(node); | 1704 return ReduceJSCreateBlockContext(node); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1704 } | 1745 } |
1705 | 1746 |
1706 | 1747 |
1707 MachineOperatorBuilder* JSTypedLowering::machine() const { | 1748 MachineOperatorBuilder* JSTypedLowering::machine() const { |
1708 return jsgraph()->machine(); | 1749 return jsgraph()->machine(); |
1709 } | 1750 } |
1710 | 1751 |
1711 } // namespace compiler | 1752 } // namespace compiler |
1712 } // namespace internal | 1753 } // namespace internal |
1713 } // namespace v8 | 1754 } // namespace v8 |
OLD | NEW |