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 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 ReplaceWithRuntimeCall(node, Runtime::kPushBlockContext); | 516 ReplaceWithRuntimeCall(node, Runtime::kPushBlockContext); |
517 } | 517 } |
518 | 518 |
519 | 519 |
520 void JSGenericLowering::LowerJSCreateScriptContext(Node* node) { | 520 void JSGenericLowering::LowerJSCreateScriptContext(Node* node) { |
521 Handle<ScopeInfo> scope_info = OpParameter<Handle<ScopeInfo>>(node); | 521 Handle<ScopeInfo> scope_info = OpParameter<Handle<ScopeInfo>>(node); |
522 node->InsertInput(zone(), 1, jsgraph()->HeapConstant(scope_info)); | 522 node->InsertInput(zone(), 1, jsgraph()->HeapConstant(scope_info)); |
523 ReplaceWithRuntimeCall(node, Runtime::kNewScriptContext); | 523 ReplaceWithRuntimeCall(node, Runtime::kNewScriptContext); |
524 } | 524 } |
525 | 525 |
| 526 void JSGenericLowering::LowerJSConstructForwardVarargs(Node* node) { |
| 527 ConstructForwardVarargsParameters p = |
| 528 ConstructForwardVarargsParametersOf(node->op()); |
| 529 int const arg_count = static_cast<int>(p.arity() - 2); |
| 530 CallDescriptor::Flags flags = FrameStateFlagForCall(node); |
| 531 Callable callable = CodeFactory::ConstructForwardVarargs(isolate()); |
| 532 CallDescriptor* desc = Linkage::GetStubCallDescriptor( |
| 533 isolate(), zone(), callable.descriptor(), arg_count + 1, flags); |
| 534 Node* stub_code = jsgraph()->HeapConstant(callable.code()); |
| 535 Node* stub_arity = jsgraph()->Int32Constant(arg_count); |
| 536 Node* start_index = jsgraph()->Uint32Constant(p.start_index()); |
| 537 Node* new_target = node->InputAt(arg_count + 1); |
| 538 Node* receiver = jsgraph()->UndefinedConstant(); |
| 539 node->RemoveInput(arg_count + 1); // Drop new target. |
| 540 node->InsertInput(zone(), 0, stub_code); |
| 541 node->InsertInput(zone(), 2, new_target); |
| 542 node->InsertInput(zone(), 3, stub_arity); |
| 543 node->InsertInput(zone(), 4, start_index); |
| 544 node->InsertInput(zone(), 5, receiver); |
| 545 NodeProperties::ChangeOp(node, common()->Call(desc)); |
| 546 } |
| 547 |
526 void JSGenericLowering::LowerJSConstruct(Node* node) { | 548 void JSGenericLowering::LowerJSConstruct(Node* node) { |
527 ConstructParameters const& p = ConstructParametersOf(node->op()); | 549 ConstructParameters const& p = ConstructParametersOf(node->op()); |
528 int const arg_count = static_cast<int>(p.arity() - 2); | 550 int const arg_count = static_cast<int>(p.arity() - 2); |
529 CallDescriptor::Flags flags = FrameStateFlagForCall(node); | 551 CallDescriptor::Flags flags = FrameStateFlagForCall(node); |
530 Callable callable = CodeFactory::Construct(isolate()); | 552 Callable callable = CodeFactory::Construct(isolate()); |
531 CallDescriptor* desc = Linkage::GetStubCallDescriptor( | 553 CallDescriptor* desc = Linkage::GetStubCallDescriptor( |
532 isolate(), zone(), callable.descriptor(), arg_count + 1, flags); | 554 isolate(), zone(), callable.descriptor(), arg_count + 1, flags); |
533 Node* stub_code = jsgraph()->HeapConstant(callable.code()); | 555 Node* stub_code = jsgraph()->HeapConstant(callable.code()); |
534 Node* stub_arity = jsgraph()->Int32Constant(arg_count); | 556 Node* stub_arity = jsgraph()->Int32Constant(arg_count); |
535 Node* new_target = node->InputAt(arg_count + 1); | 557 Node* new_target = node->InputAt(arg_count + 1); |
(...skipping 20 matching lines...) Expand all Loading... |
556 node->RemoveInput(arg_count + 1); // Drop new target. | 578 node->RemoveInput(arg_count + 1); // Drop new target. |
557 node->InsertInput(zone(), 0, stub_code); | 579 node->InsertInput(zone(), 0, stub_code); |
558 node->InsertInput(zone(), 2, new_target); | 580 node->InsertInput(zone(), 2, new_target); |
559 node->InsertInput(zone(), 3, stub_arity); | 581 node->InsertInput(zone(), 3, stub_arity); |
560 node->InsertInput(zone(), 4, receiver); | 582 node->InsertInput(zone(), 4, receiver); |
561 NodeProperties::ChangeOp(node, common()->Call(desc)); | 583 NodeProperties::ChangeOp(node, common()->Call(desc)); |
562 } | 584 } |
563 | 585 |
564 void JSGenericLowering::LowerJSCallForwardVarargs(Node* node) { | 586 void JSGenericLowering::LowerJSCallForwardVarargs(Node* node) { |
565 CallForwardVarargsParameters p = CallForwardVarargsParametersOf(node->op()); | 587 CallForwardVarargsParameters p = CallForwardVarargsParametersOf(node->op()); |
| 588 int const arg_count = static_cast<int>(p.arity() - 2); |
| 589 CallDescriptor::Flags flags = FrameStateFlagForCall(node); |
566 Callable callable = CodeFactory::CallForwardVarargs(isolate()); | 590 Callable callable = CodeFactory::CallForwardVarargs(isolate()); |
567 CallDescriptor::Flags flags = FrameStateFlagForCall(node); | |
568 if (p.tail_call_mode() == TailCallMode::kAllow) { | 591 if (p.tail_call_mode() == TailCallMode::kAllow) { |
569 flags |= CallDescriptor::kSupportsTailCalls; | 592 flags |= CallDescriptor::kSupportsTailCalls; |
570 } | 593 } |
571 CallDescriptor* desc = Linkage::GetStubCallDescriptor( | 594 CallDescriptor* desc = Linkage::GetStubCallDescriptor( |
572 isolate(), zone(), callable.descriptor(), 1, flags); | 595 isolate(), zone(), callable.descriptor(), arg_count + 1, flags); |
573 Node* stub_code = jsgraph()->HeapConstant(callable.code()); | 596 Node* stub_code = jsgraph()->HeapConstant(callable.code()); |
| 597 Node* stub_arity = jsgraph()->Int32Constant(arg_count); |
574 Node* start_index = jsgraph()->Uint32Constant(p.start_index()); | 598 Node* start_index = jsgraph()->Uint32Constant(p.start_index()); |
575 node->InsertInput(zone(), 0, stub_code); | 599 node->InsertInput(zone(), 0, stub_code); |
576 node->InsertInput(zone(), 2, start_index); | 600 node->InsertInput(zone(), 2, stub_arity); |
| 601 node->InsertInput(zone(), 3, start_index); |
577 NodeProperties::ChangeOp(node, common()->Call(desc)); | 602 NodeProperties::ChangeOp(node, common()->Call(desc)); |
578 } | 603 } |
579 | 604 |
580 void JSGenericLowering::LowerJSCall(Node* node) { | 605 void JSGenericLowering::LowerJSCall(Node* node) { |
581 CallParameters const& p = CallParametersOf(node->op()); | 606 CallParameters const& p = CallParametersOf(node->op()); |
582 int const arg_count = static_cast<int>(p.arity() - 2); | 607 int const arg_count = static_cast<int>(p.arity() - 2); |
583 ConvertReceiverMode const mode = p.convert_mode(); | 608 ConvertReceiverMode const mode = p.convert_mode(); |
584 Callable callable = CodeFactory::Call(isolate(), mode); | 609 Callable callable = CodeFactory::Call(isolate(), mode); |
585 CallDescriptor::Flags flags = FrameStateFlagForCall(node); | 610 CallDescriptor::Flags flags = FrameStateFlagForCall(node); |
586 if (p.tail_call_mode() == TailCallMode::kAllow) { | 611 if (p.tail_call_mode() == TailCallMode::kAllow) { |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 } | 754 } |
730 | 755 |
731 | 756 |
732 MachineOperatorBuilder* JSGenericLowering::machine() const { | 757 MachineOperatorBuilder* JSGenericLowering::machine() const { |
733 return jsgraph()->machine(); | 758 return jsgraph()->machine(); |
734 } | 759 } |
735 | 760 |
736 } // namespace compiler | 761 } // namespace compiler |
737 } // namespace internal | 762 } // namespace internal |
738 } // namespace v8 | 763 } // namespace v8 |
OLD | NEW |