| 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/allocation-site-scopes.h" | 7 #include "src/allocation-site-scopes.h" |
| 8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
| 9 #include "src/compilation-dependencies.h" | 9 #include "src/compilation-dependencies.h" |
| 10 #include "src/compiler/access-builder.h" | 10 #include "src/compiler/access-builder.h" |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 CreateArgumentsType type = CreateArgumentsTypeOf(node->op()); | 279 CreateArgumentsType type = CreateArgumentsTypeOf(node->op()); |
| 280 Node* const frame_state = NodeProperties::GetFrameStateInput(node, 0); | 280 Node* const frame_state = NodeProperties::GetFrameStateInput(node, 0); |
| 281 Node* const outer_state = frame_state->InputAt(kFrameStateOuterStateInput); | 281 Node* const outer_state = frame_state->InputAt(kFrameStateOuterStateInput); |
| 282 FrameStateInfo state_info = OpParameter<FrameStateInfo>(frame_state); | 282 FrameStateInfo state_info = OpParameter<FrameStateInfo>(frame_state); |
| 283 | 283 |
| 284 // Use the ArgumentsAccessStub for materializing both mapped and unmapped | 284 // Use the ArgumentsAccessStub for materializing both mapped and unmapped |
| 285 // arguments object, but only for non-inlined (i.e. outermost) frames. | 285 // arguments object, but only for non-inlined (i.e. outermost) frames. |
| 286 if (outer_state->opcode() != IrOpcode::kFrameState) { | 286 if (outer_state->opcode() != IrOpcode::kFrameState) { |
| 287 switch (type) { | 287 switch (type) { |
| 288 case CreateArgumentsType::kMappedArguments: { | 288 case CreateArgumentsType::kMappedArguments: { |
| 289 // TODO(bmeurer): Cleanup this mess at some point. | 289 // TODO(mstarzinger): Duplicate parameters are not handled yet. |
| 290 int parameter_count = state_info.parameter_count() - 1; | 290 Handle<SharedFunctionInfo> shared_info; |
| 291 int parameter_offset = parameter_count * kPointerSize; | 291 if (!state_info.shared_info().ToHandle(&shared_info) || |
| 292 int offset = StandardFrameConstants::kCallerSPOffset + parameter_offset; | 292 shared_info->has_duplicate_parameters()) { |
| 293 Node* parameter_pointer = | 293 return NoChange(); |
| 294 graph()->NewNode(machine()->IntAdd(), | 294 } |
| 295 graph()->NewNode(machine()->LoadFramePointer()), | 295 // TODO(bmeurer): Actually we don't need a frame state here. |
| 296 jsgraph()->IntPtrConstant(offset)); | 296 Callable callable = CodeFactory::FastNewSloppyArguments(isolate()); |
| 297 Handle<SharedFunctionInfo> shared; | |
| 298 if (!state_info.shared_info().ToHandle(&shared)) return NoChange(); | |
| 299 Callable callable = CodeFactory::ArgumentsAccess( | |
| 300 isolate(), shared->has_duplicate_parameters()); | |
| 301 CallDescriptor* desc = Linkage::GetStubCallDescriptor( | 297 CallDescriptor* desc = Linkage::GetStubCallDescriptor( |
| 302 isolate(), graph()->zone(), callable.descriptor(), 0, | 298 isolate(), graph()->zone(), callable.descriptor(), 0, |
| 303 CallDescriptor::kNeedsFrameState); | 299 CallDescriptor::kNeedsFrameState); |
| 304 const Operator* new_op = common()->Call(desc); | 300 const Operator* new_op = common()->Call(desc); |
| 305 Node* stub_code = jsgraph()->HeapConstant(callable.code()); | 301 Node* stub_code = jsgraph()->HeapConstant(callable.code()); |
| 306 node->InsertInput(graph()->zone(), 0, stub_code); | 302 node->InsertInput(graph()->zone(), 0, stub_code); |
| 307 node->InsertInput(graph()->zone(), 2, | |
| 308 jsgraph()->Constant(parameter_count)); | |
| 309 node->InsertInput(graph()->zone(), 3, parameter_pointer); | |
| 310 NodeProperties::ChangeOp(node, new_op); | 303 NodeProperties::ChangeOp(node, new_op); |
| 311 return Changed(node); | 304 return Changed(node); |
| 312 } | 305 } |
| 313 case CreateArgumentsType::kUnmappedArguments: { | 306 case CreateArgumentsType::kUnmappedArguments: { |
| 307 // TODO(bmeurer): Actually we don't need a frame state here. |
| 314 Callable callable = CodeFactory::FastNewStrictArguments(isolate()); | 308 Callable callable = CodeFactory::FastNewStrictArguments(isolate()); |
| 315 CallDescriptor* desc = Linkage::GetStubCallDescriptor( | 309 CallDescriptor* desc = Linkage::GetStubCallDescriptor( |
| 316 isolate(), graph()->zone(), callable.descriptor(), 0, | 310 isolate(), graph()->zone(), callable.descriptor(), 0, |
| 317 CallDescriptor::kNeedsFrameState); | 311 CallDescriptor::kNeedsFrameState); |
| 318 const Operator* new_op = common()->Call(desc); | 312 const Operator* new_op = common()->Call(desc); |
| 319 Node* stub_code = jsgraph()->HeapConstant(callable.code()); | 313 Node* stub_code = jsgraph()->HeapConstant(callable.code()); |
| 320 node->InsertInput(graph()->zone(), 0, stub_code); | 314 node->InsertInput(graph()->zone(), 0, stub_code); |
| 321 NodeProperties::ChangeOp(node, new_op); | 315 NodeProperties::ChangeOp(node, new_op); |
| 322 return Changed(node); | 316 return Changed(node); |
| 323 } | 317 } |
| 324 case CreateArgumentsType::kRestParameter: { | 318 case CreateArgumentsType::kRestParameter: { |
| 319 // TODO(bmeurer): Actually we don't need a frame state here. |
| 325 Callable callable = CodeFactory::FastNewRestParameter(isolate()); | 320 Callable callable = CodeFactory::FastNewRestParameter(isolate()); |
| 326 CallDescriptor* desc = Linkage::GetStubCallDescriptor( | 321 CallDescriptor* desc = Linkage::GetStubCallDescriptor( |
| 327 isolate(), graph()->zone(), callable.descriptor(), 0, | 322 isolate(), graph()->zone(), callable.descriptor(), 0, |
| 328 CallDescriptor::kNeedsFrameState); | 323 CallDescriptor::kNeedsFrameState); |
| 329 const Operator* new_op = common()->Call(desc); | 324 const Operator* new_op = common()->Call(desc); |
| 330 Node* stub_code = jsgraph()->HeapConstant(callable.code()); | 325 Node* stub_code = jsgraph()->HeapConstant(callable.code()); |
| 331 node->InsertInput(graph()->zone(), 0, stub_code); | 326 node->InsertInput(graph()->zone(), 0, stub_code); |
| 332 NodeProperties::ChangeOp(node, new_op); | 327 NodeProperties::ChangeOp(node, new_op); |
| 333 return Changed(node); | 328 return Changed(node); |
| 334 } | 329 } |
| (...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1093 return jsgraph()->simplified(); | 1088 return jsgraph()->simplified(); |
| 1094 } | 1089 } |
| 1095 | 1090 |
| 1096 MachineOperatorBuilder* JSCreateLowering::machine() const { | 1091 MachineOperatorBuilder* JSCreateLowering::machine() const { |
| 1097 return jsgraph()->machine(); | 1092 return jsgraph()->machine(); |
| 1098 } | 1093 } |
| 1099 | 1094 |
| 1100 } // namespace compiler | 1095 } // namespace compiler |
| 1101 } // namespace internal | 1096 } // namespace internal |
| 1102 } // namespace v8 | 1097 } // namespace v8 |
| OLD | NEW |