OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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-create-lowering.h" | 5 #include "src/compiler/js-create-lowering.h" |
6 | 6 |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/compilation-dependencies.h" | 8 #include "src/compilation-dependencies.h" |
9 #include "src/compiler/access-builder.h" | 9 #include "src/compiler/access-builder.h" |
10 #include "src/compiler/common-operator.h" | 10 #include "src/compiler/common-operator.h" |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 CreateArgumentsType type = CreateArgumentsTypeOf(node->op()); | 207 CreateArgumentsType type = CreateArgumentsTypeOf(node->op()); |
208 Node* const frame_state = NodeProperties::GetFrameStateInput(node, 0); | 208 Node* const frame_state = NodeProperties::GetFrameStateInput(node, 0); |
209 Node* const outer_state = frame_state->InputAt(kFrameStateOuterStateInput); | 209 Node* const outer_state = frame_state->InputAt(kFrameStateOuterStateInput); |
210 FrameStateInfo state_info = OpParameter<FrameStateInfo>(frame_state); | 210 FrameStateInfo state_info = OpParameter<FrameStateInfo>(frame_state); |
211 | 211 |
212 // Use the ArgumentsAccessStub for materializing both mapped and unmapped | 212 // Use the ArgumentsAccessStub for materializing both mapped and unmapped |
213 // arguments object, but only for non-inlined (i.e. outermost) frames. | 213 // arguments object, but only for non-inlined (i.e. outermost) frames. |
214 if (outer_state->opcode() != IrOpcode::kFrameState) { | 214 if (outer_state->opcode() != IrOpcode::kFrameState) { |
215 switch (type) { | 215 switch (type) { |
216 case CreateArgumentsType::kMappedArguments: { | 216 case CreateArgumentsType::kMappedArguments: { |
217 // TODO(mstarzinger): Duplicate parameters are not handled yet. | 217 // TODO(bmeurer): Cleanup this mess at some point. |
218 Handle<SharedFunctionInfo> shared_info; | 218 int parameter_count = state_info.parameter_count() - 1; |
219 if (!state_info.shared_info().ToHandle(&shared_info) || | 219 int parameter_offset = parameter_count * kPointerSize; |
220 shared_info->has_duplicate_parameters()) { | 220 int offset = StandardFrameConstants::kCallerSPOffset + parameter_offset; |
221 return NoChange(); | 221 Node* parameter_pointer = |
222 } | 222 graph()->NewNode(machine()->IntAdd(), |
223 // TODO(bmeurer): Actually we don't need a frame state here. | 223 graph()->NewNode(machine()->LoadFramePointer()), |
224 Callable callable = CodeFactory::FastNewSloppyArguments(isolate()); | 224 jsgraph()->IntPtrConstant(offset)); |
| 225 Handle<SharedFunctionInfo> shared; |
| 226 if (!state_info.shared_info().ToHandle(&shared)) return NoChange(); |
| 227 Callable callable = CodeFactory::ArgumentsAccess( |
| 228 isolate(), shared->has_duplicate_parameters()); |
225 CallDescriptor* desc = Linkage::GetStubCallDescriptor( | 229 CallDescriptor* desc = Linkage::GetStubCallDescriptor( |
226 isolate(), graph()->zone(), callable.descriptor(), 0, | 230 isolate(), graph()->zone(), callable.descriptor(), 0, |
227 CallDescriptor::kNeedsFrameState); | 231 CallDescriptor::kNeedsFrameState); |
228 const Operator* new_op = common()->Call(desc); | 232 const Operator* new_op = common()->Call(desc); |
229 Node* stub_code = jsgraph()->HeapConstant(callable.code()); | 233 Node* stub_code = jsgraph()->HeapConstant(callable.code()); |
230 node->InsertInput(graph()->zone(), 0, stub_code); | 234 node->InsertInput(graph()->zone(), 0, stub_code); |
| 235 node->InsertInput(graph()->zone(), 2, |
| 236 jsgraph()->Constant(parameter_count)); |
| 237 node->InsertInput(graph()->zone(), 3, parameter_pointer); |
231 NodeProperties::ChangeOp(node, new_op); | 238 NodeProperties::ChangeOp(node, new_op); |
232 return Changed(node); | 239 return Changed(node); |
233 } | 240 } |
234 case CreateArgumentsType::kUnmappedArguments: { | 241 case CreateArgumentsType::kUnmappedArguments: { |
235 // TODO(bmeurer): Actually we don't need a frame state here. | |
236 Callable callable = CodeFactory::FastNewStrictArguments(isolate()); | 242 Callable callable = CodeFactory::FastNewStrictArguments(isolate()); |
237 CallDescriptor* desc = Linkage::GetStubCallDescriptor( | 243 CallDescriptor* desc = Linkage::GetStubCallDescriptor( |
238 isolate(), graph()->zone(), callable.descriptor(), 0, | 244 isolate(), graph()->zone(), callable.descriptor(), 0, |
239 CallDescriptor::kNeedsFrameState); | 245 CallDescriptor::kNeedsFrameState); |
240 const Operator* new_op = common()->Call(desc); | 246 const Operator* new_op = common()->Call(desc); |
241 Node* stub_code = jsgraph()->HeapConstant(callable.code()); | 247 Node* stub_code = jsgraph()->HeapConstant(callable.code()); |
242 node->InsertInput(graph()->zone(), 0, stub_code); | 248 node->InsertInput(graph()->zone(), 0, stub_code); |
243 NodeProperties::ChangeOp(node, new_op); | 249 NodeProperties::ChangeOp(node, new_op); |
244 return Changed(node); | 250 return Changed(node); |
245 } | 251 } |
246 case CreateArgumentsType::kRestParameter: { | 252 case CreateArgumentsType::kRestParameter: { |
247 // TODO(bmeurer): Actually we don't need a frame state here. | |
248 Callable callable = CodeFactory::FastNewRestParameter(isolate()); | 253 Callable callable = CodeFactory::FastNewRestParameter(isolate()); |
249 CallDescriptor* desc = Linkage::GetStubCallDescriptor( | 254 CallDescriptor* desc = Linkage::GetStubCallDescriptor( |
250 isolate(), graph()->zone(), callable.descriptor(), 0, | 255 isolate(), graph()->zone(), callable.descriptor(), 0, |
251 CallDescriptor::kNeedsFrameState); | 256 CallDescriptor::kNeedsFrameState); |
252 const Operator* new_op = common()->Call(desc); | 257 const Operator* new_op = common()->Call(desc); |
253 Node* stub_code = jsgraph()->HeapConstant(callable.code()); | 258 Node* stub_code = jsgraph()->HeapConstant(callable.code()); |
254 node->InsertInput(graph()->zone(), 0, stub_code); | 259 node->InsertInput(graph()->zone(), 0, stub_code); |
255 NodeProperties::ChangeOp(node, new_op); | 260 NodeProperties::ChangeOp(node, new_op); |
256 return Changed(node); | 261 return Changed(node); |
257 } | 262 } |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
767 return jsgraph()->simplified(); | 772 return jsgraph()->simplified(); |
768 } | 773 } |
769 | 774 |
770 MachineOperatorBuilder* JSCreateLowering::machine() const { | 775 MachineOperatorBuilder* JSCreateLowering::machine() const { |
771 return jsgraph()->machine(); | 776 return jsgraph()->machine(); |
772 } | 777 } |
773 | 778 |
774 } // namespace compiler | 779 } // namespace compiler |
775 } // namespace internal | 780 } // namespace internal |
776 } // namespace v8 | 781 } // namespace v8 |
OLD | NEW |