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 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 node->InsertInput(zone(), 0, stub_code); | 497 node->InsertInput(zone(), 0, stub_code); |
498 node->InsertInput(zone(), 2, new_target); | 498 node->InsertInput(zone(), 2, new_target); |
499 node->InsertInput(zone(), 3, stub_arity); | 499 node->InsertInput(zone(), 3, stub_arity); |
500 node->InsertInput(zone(), 4, receiver); | 500 node->InsertInput(zone(), 4, receiver); |
501 NodeProperties::ChangeOp(node, common()->Call(desc)); | 501 NodeProperties::ChangeOp(node, common()->Call(desc)); |
502 } | 502 } |
503 | 503 |
504 void JSGenericLowering::LowerJSCallConstructWithSpread(Node* node) { | 504 void JSGenericLowering::LowerJSCallConstructWithSpread(Node* node) { |
505 CallConstructWithSpreadParameters const& p = | 505 CallConstructWithSpreadParameters const& p = |
506 CallConstructWithSpreadParametersOf(node->op()); | 506 CallConstructWithSpreadParametersOf(node->op()); |
507 ReplaceWithRuntimeCall(node, Runtime::kNewWithSpread, | 507 int const arg_count = static_cast<int>(p.arity() - 2); |
508 static_cast<int>(p.arity())); | 508 CallDescriptor::Flags flags = FrameStateFlagForCall(node); |
| 509 Callable callable = CodeFactory::ConstructWithSpread(isolate()); |
| 510 CallDescriptor* desc = Linkage::GetStubCallDescriptor( |
| 511 isolate(), zone(), callable.descriptor(), arg_count + 1, flags); |
| 512 Node* stub_code = jsgraph()->HeapConstant(callable.code()); |
| 513 Node* stub_arity = jsgraph()->Int32Constant(arg_count); |
| 514 Node* new_target = node->InputAt(arg_count + 1); |
| 515 Node* receiver = jsgraph()->UndefinedConstant(); |
| 516 node->RemoveInput(arg_count + 1); // Drop new target. |
| 517 node->InsertInput(zone(), 0, stub_code); |
| 518 node->InsertInput(zone(), 2, new_target); |
| 519 node->InsertInput(zone(), 3, stub_arity); |
| 520 node->InsertInput(zone(), 4, receiver); |
| 521 NodeProperties::ChangeOp(node, common()->Call(desc)); |
509 } | 522 } |
510 | 523 |
511 void JSGenericLowering::LowerJSCallFunction(Node* node) { | 524 void JSGenericLowering::LowerJSCallFunction(Node* node) { |
512 CallFunctionParameters const& p = CallFunctionParametersOf(node->op()); | 525 CallFunctionParameters const& p = CallFunctionParametersOf(node->op()); |
513 int const arg_count = static_cast<int>(p.arity() - 2); | 526 int const arg_count = static_cast<int>(p.arity() - 2); |
514 ConvertReceiverMode const mode = p.convert_mode(); | 527 ConvertReceiverMode const mode = p.convert_mode(); |
515 Callable callable = CodeFactory::Call(isolate(), mode); | 528 Callable callable = CodeFactory::Call(isolate(), mode); |
516 CallDescriptor::Flags flags = FrameStateFlagForCall(node); | 529 CallDescriptor::Flags flags = FrameStateFlagForCall(node); |
517 if (p.tail_call_mode() == TailCallMode::kAllow) { | 530 if (p.tail_call_mode() == TailCallMode::kAllow) { |
518 flags |= CallDescriptor::kSupportsTailCalls; | 531 flags |= CallDescriptor::kSupportsTailCalls; |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 } | 656 } |
644 | 657 |
645 | 658 |
646 MachineOperatorBuilder* JSGenericLowering::machine() const { | 659 MachineOperatorBuilder* JSGenericLowering::machine() const { |
647 return jsgraph()->machine(); | 660 return jsgraph()->machine(); |
648 } | 661 } |
649 | 662 |
650 } // namespace compiler | 663 } // namespace compiler |
651 } // namespace internal | 664 } // namespace internal |
652 } // namespace v8 | 665 } // namespace v8 |
OLD | NEW |