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