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/code-factory.h" | 8 #include "src/code-factory.h" |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/compiler/common-operator.h" | 10 #include "src/compiler/common-operator.h" |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 node->InsertInput(zone(), 0, stub_code); | 470 node->InsertInput(zone(), 0, stub_code); |
471 node->InsertInput(zone(), 2, new_target); | 471 node->InsertInput(zone(), 2, new_target); |
472 node->InsertInput(zone(), 3, stub_arity); | 472 node->InsertInput(zone(), 3, stub_arity); |
473 node->InsertInput(zone(), 4, receiver); | 473 node->InsertInput(zone(), 4, receiver); |
474 NodeProperties::ChangeOp(node, common()->Call(desc)); | 474 NodeProperties::ChangeOp(node, common()->Call(desc)); |
475 } | 475 } |
476 | 476 |
477 void JSGenericLowering::LowerJSCallConstructWithSpread(Node* node) { | 477 void JSGenericLowering::LowerJSCallConstructWithSpread(Node* node) { |
478 CallConstructWithSpreadParameters const& p = | 478 CallConstructWithSpreadParameters const& p = |
479 CallConstructWithSpreadParametersOf(node->op()); | 479 CallConstructWithSpreadParametersOf(node->op()); |
480 ReplaceWithRuntimeCall(node, Runtime::kNewWithSpread, | 480 int const arg_count = static_cast<int>(p.arity() - 2); |
481 static_cast<int>(p.arity())); | 481 CallDescriptor::Flags flags = FrameStateFlagForCall(node); |
| 482 Callable callable = CodeFactory::ConstructWithSpread(isolate()); |
| 483 CallDescriptor* desc = Linkage::GetStubCallDescriptor( |
| 484 isolate(), zone(), callable.descriptor(), arg_count + 1, flags); |
| 485 Node* stub_code = jsgraph()->HeapConstant(callable.code()); |
| 486 Node* stub_arity = jsgraph()->Int32Constant(arg_count); |
| 487 Node* new_target = node->InputAt(arg_count + 1); |
| 488 Node* receiver = jsgraph()->UndefinedConstant(); |
| 489 node->RemoveInput(arg_count + 1); // Drop new target. |
| 490 node->InsertInput(zone(), 0, stub_code); |
| 491 node->InsertInput(zone(), 2, new_target); |
| 492 node->InsertInput(zone(), 3, stub_arity); |
| 493 node->InsertInput(zone(), 4, receiver); |
| 494 NodeProperties::ChangeOp(node, common()->Call(desc)); |
482 } | 495 } |
483 | 496 |
484 void JSGenericLowering::LowerJSCallFunction(Node* node) { | 497 void JSGenericLowering::LowerJSCallFunction(Node* node) { |
485 CallFunctionParameters const& p = CallFunctionParametersOf(node->op()); | 498 CallFunctionParameters const& p = CallFunctionParametersOf(node->op()); |
486 int const arg_count = static_cast<int>(p.arity() - 2); | 499 int const arg_count = static_cast<int>(p.arity() - 2); |
487 ConvertReceiverMode const mode = p.convert_mode(); | 500 ConvertReceiverMode const mode = p.convert_mode(); |
488 Callable callable = CodeFactory::Call(isolate(), mode); | 501 Callable callable = CodeFactory::Call(isolate(), mode); |
489 CallDescriptor::Flags flags = FrameStateFlagForCall(node); | 502 CallDescriptor::Flags flags = FrameStateFlagForCall(node); |
490 if (p.tail_call_mode() == TailCallMode::kAllow) { | 503 if (p.tail_call_mode() == TailCallMode::kAllow) { |
491 flags |= CallDescriptor::kSupportsTailCalls; | 504 flags |= CallDescriptor::kSupportsTailCalls; |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 } | 629 } |
617 | 630 |
618 | 631 |
619 MachineOperatorBuilder* JSGenericLowering::machine() const { | 632 MachineOperatorBuilder* JSGenericLowering::machine() const { |
620 return jsgraph()->machine(); | 633 return jsgraph()->machine(); |
621 } | 634 } |
622 | 635 |
623 } // namespace compiler | 636 } // namespace compiler |
624 } // namespace internal | 637 } // namespace internal |
625 } // namespace v8 | 638 } // namespace v8 |
OLD | NEW |