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-generic-lowering.h" | 5 #include "src/compiler/js-generic-lowering.h" |
6 | 6 |
7 #include "src/ast/ast.h" | 7 #include "src/ast/ast.h" |
8 #include "src/builtins/builtins-constructor.h" | 8 #include "src/builtins/builtins-constructor.h" |
9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 node->InsertInput(zone(), 0, stub_code); | 491 node->InsertInput(zone(), 0, stub_code); |
492 node->InsertInput(zone(), 2, new_target); | 492 node->InsertInput(zone(), 2, new_target); |
493 node->InsertInput(zone(), 3, stub_arity); | 493 node->InsertInput(zone(), 3, stub_arity); |
494 node->InsertInput(zone(), 4, receiver); | 494 node->InsertInput(zone(), 4, receiver); |
495 NodeProperties::ChangeOp(node, common()->Call(desc)); | 495 NodeProperties::ChangeOp(node, common()->Call(desc)); |
496 } | 496 } |
497 | 497 |
498 void JSGenericLowering::LowerJSCallConstructWithSpread(Node* node) { | 498 void JSGenericLowering::LowerJSCallConstructWithSpread(Node* node) { |
499 CallConstructWithSpreadParameters const& p = | 499 CallConstructWithSpreadParameters const& p = |
500 CallConstructWithSpreadParametersOf(node->op()); | 500 CallConstructWithSpreadParametersOf(node->op()); |
501 ReplaceWithRuntimeCall(node, Runtime::kNewWithSpread, | 501 int const arg_count = static_cast<int>(p.arity() - 2); |
502 static_cast<int>(p.arity())); | 502 CallDescriptor::Flags flags = FrameStateFlagForCall(node); |
| 503 Callable callable = CodeFactory::ConstructWithSpread(isolate()); |
| 504 CallDescriptor* desc = Linkage::GetStubCallDescriptor( |
| 505 isolate(), zone(), callable.descriptor(), arg_count + 1, flags); |
| 506 Node* stub_code = jsgraph()->HeapConstant(callable.code()); |
| 507 Node* stub_arity = jsgraph()->Int32Constant(arg_count); |
| 508 Node* new_target = node->InputAt(arg_count + 1); |
| 509 Node* receiver = jsgraph()->UndefinedConstant(); |
| 510 node->RemoveInput(arg_count + 1); // Drop new target. |
| 511 node->InsertInput(zone(), 0, stub_code); |
| 512 node->InsertInput(zone(), 2, new_target); |
| 513 node->InsertInput(zone(), 3, stub_arity); |
| 514 node->InsertInput(zone(), 4, receiver); |
| 515 NodeProperties::ChangeOp(node, common()->Call(desc)); |
503 } | 516 } |
504 | 517 |
505 void JSGenericLowering::LowerJSCallFunction(Node* node) { | 518 void JSGenericLowering::LowerJSCallFunction(Node* node) { |
506 CallFunctionParameters const& p = CallFunctionParametersOf(node->op()); | 519 CallFunctionParameters const& p = CallFunctionParametersOf(node->op()); |
507 int const arg_count = static_cast<int>(p.arity() - 2); | 520 int const arg_count = static_cast<int>(p.arity() - 2); |
508 ConvertReceiverMode const mode = p.convert_mode(); | 521 ConvertReceiverMode const mode = p.convert_mode(); |
509 Callable callable = CodeFactory::Call(isolate(), mode); | 522 Callable callable = CodeFactory::Call(isolate(), mode); |
510 CallDescriptor::Flags flags = FrameStateFlagForCall(node); | 523 CallDescriptor::Flags flags = FrameStateFlagForCall(node); |
511 if (p.tail_call_mode() == TailCallMode::kAllow) { | 524 if (p.tail_call_mode() == TailCallMode::kAllow) { |
512 flags |= CallDescriptor::kSupportsTailCalls; | 525 flags |= CallDescriptor::kSupportsTailCalls; |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 } | 650 } |
638 | 651 |
639 | 652 |
640 MachineOperatorBuilder* JSGenericLowering::machine() const { | 653 MachineOperatorBuilder* JSGenericLowering::machine() const { |
641 return jsgraph()->machine(); | 654 return jsgraph()->machine(); |
642 } | 655 } |
643 | 656 |
644 } // namespace compiler | 657 } // namespace compiler |
645 } // namespace internal | 658 } // namespace internal |
646 } // namespace v8 | 659 } // namespace v8 |
OLD | NEW |