| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/code-assembler.h" | 5 #include "src/compiler/code-assembler.h" |
| 6 | 6 |
| 7 #include <ostream> | 7 #include <ostream> |
| 8 | 8 |
| 9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
| 10 #include "src/compiler/graph.h" | 10 #include "src/compiler/graph.h" |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 #undef INSTANTIATE | 478 #undef INSTANTIATE |
| 479 | 479 |
| 480 template <class... TArgs> | 480 template <class... TArgs> |
| 481 Node* CodeAssembler::CallStubR(const CallInterfaceDescriptor& descriptor, | 481 Node* CodeAssembler::CallStubR(const CallInterfaceDescriptor& descriptor, |
| 482 size_t result_size, Node* target, Node* context, | 482 size_t result_size, Node* target, Node* context, |
| 483 TArgs... args) { | 483 TArgs... args) { |
| 484 Node* nodes[] = {target, args..., context}; | 484 Node* nodes[] = {target, args..., context}; |
| 485 return CallStubN(descriptor, result_size, arraysize(nodes), nodes); | 485 return CallStubN(descriptor, result_size, arraysize(nodes), nodes); |
| 486 } | 486 } |
| 487 | 487 |
| 488 // Instantiate CallStubR() with up to 5 arguments. | 488 // Instantiate CallStubR() with up to 6 arguments. |
| 489 #define INSTANTIATE(...) \ | 489 #define INSTANTIATE(...) \ |
| 490 template V8_EXPORT_PRIVATE Node* CodeAssembler::CallStubR( \ | 490 template V8_EXPORT_PRIVATE Node* CodeAssembler::CallStubR( \ |
| 491 const CallInterfaceDescriptor& descriptor, size_t, Node*, __VA_ARGS__); | 491 const CallInterfaceDescriptor& descriptor, size_t, Node*, __VA_ARGS__); |
| 492 REPEAT_1_TO_6(INSTANTIATE, Node*) | 492 REPEAT_1_TO_7(INSTANTIATE, Node*) |
| 493 #undef INSTANTIATE | 493 #undef INSTANTIATE |
| 494 | 494 |
| 495 Node* CodeAssembler::CallStubN(const CallInterfaceDescriptor& descriptor, | 495 Node* CodeAssembler::CallStubN(const CallInterfaceDescriptor& descriptor, |
| 496 size_t result_size, int input_count, | 496 size_t result_size, int input_count, |
| 497 Node* const* inputs) { | 497 Node* const* inputs) { |
| 498 // 2 is for target and context. | 498 // 2 is for target and context. |
| 499 DCHECK_LE(2, input_count); | 499 DCHECK_LE(2, input_count); |
| 500 int argc = input_count - 2; | 500 int argc = input_count - 2; |
| 501 DCHECK_LE(descriptor.GetParameterCount(), argc); | 501 DCHECK_LE(descriptor.GetParameterCount(), argc); |
| 502 // Extra arguments not mentioned in the descriptor are passed on the stack. | 502 // Extra arguments not mentioned in the descriptor are passed on the stack. |
| 503 int stack_parameter_count = argc - descriptor.GetRegisterParameterCount(); | 503 int stack_parameter_count = argc - descriptor.GetRegisterParameterCount(); |
| 504 DCHECK_LE(descriptor.GetStackParameterCount(), stack_parameter_count); | 504 DCHECK_LE(descriptor.GetStackParameterCount(), stack_parameter_count); |
| 505 CallDescriptor* desc = Linkage::GetStubCallDescriptor( | 505 CallDescriptor* desc = Linkage::GetStubCallDescriptor( |
| 506 isolate(), zone(), descriptor, stack_parameter_count, | 506 isolate(), zone(), descriptor, stack_parameter_count, |
| 507 CallDescriptor::kNoFlags, Operator::kNoProperties, | 507 CallDescriptor::kNoFlags, Operator::kNoProperties, |
| 508 MachineType::AnyTagged(), result_size); | 508 MachineType::AnyTagged(), result_size); |
| 509 | 509 |
| 510 CallPrologue(); | 510 CallPrologue(); |
| 511 Node* return_value = raw_assembler()->CallN(desc, input_count, inputs); | 511 Node* return_value = raw_assembler()->CallN(desc, input_count, inputs); |
| 512 CallEpilogue(); | 512 CallEpilogue(); |
| 513 return return_value; | 513 return return_value; |
| 514 } | 514 } |
| 515 | 515 |
| 516 Node* CodeAssembler::CallStubN(const CallInterfaceDescriptor& descriptor, | |
| 517 int js_parameter_count, Node* target, | |
| 518 Node** args, size_t result_size) { | |
| 519 CallDescriptor* call_descriptor = Linkage::GetStubCallDescriptor( | |
| 520 isolate(), zone(), descriptor, | |
| 521 descriptor.GetStackParameterCount() + js_parameter_count, | |
| 522 CallDescriptor::kNoFlags, Operator::kNoProperties, | |
| 523 MachineType::AnyTagged(), result_size); | |
| 524 | |
| 525 return CallN(call_descriptor, target, args); | |
| 526 } | |
| 527 | |
| 528 Node* CodeAssembler::TailCallStub(Callable const& callable, Node* context, | 516 Node* CodeAssembler::TailCallStub(Callable const& callable, Node* context, |
| 529 Node* arg1, size_t result_size) { | 517 Node* arg1, size_t result_size) { |
| 530 Node* target = HeapConstant(callable.code()); | 518 Node* target = HeapConstant(callable.code()); |
| 531 return TailCallStub(callable.descriptor(), target, context, arg1, | 519 return TailCallStub(callable.descriptor(), target, context, arg1, |
| 532 result_size); | 520 result_size); |
| 533 } | 521 } |
| 534 | 522 |
| 535 Node* CodeAssembler::TailCallStub(Callable const& callable, Node* context, | 523 Node* CodeAssembler::TailCallStub(Callable const& callable, Node* context, |
| 536 Node* arg1, Node* arg2, size_t result_size) { | 524 Node* arg1, Node* arg2, size_t result_size) { |
| 537 Node* target = HeapConstant(callable.code()); | 525 Node* target = HeapConstant(callable.code()); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 | 661 |
| 674 Node* CodeAssembler::TailCallBytecodeDispatch( | 662 Node* CodeAssembler::TailCallBytecodeDispatch( |
| 675 const CallInterfaceDescriptor& interface_descriptor, | 663 const CallInterfaceDescriptor& interface_descriptor, |
| 676 Node* code_target_address, Node** args) { | 664 Node* code_target_address, Node** args) { |
| 677 CallDescriptor* descriptor = Linkage::GetBytecodeDispatchCallDescriptor( | 665 CallDescriptor* descriptor = Linkage::GetBytecodeDispatchCallDescriptor( |
| 678 isolate(), zone(), interface_descriptor, | 666 isolate(), zone(), interface_descriptor, |
| 679 interface_descriptor.GetStackParameterCount()); | 667 interface_descriptor.GetStackParameterCount()); |
| 680 return raw_assembler()->TailCallN(descriptor, code_target_address, args); | 668 return raw_assembler()->TailCallN(descriptor, code_target_address, args); |
| 681 } | 669 } |
| 682 | 670 |
| 683 Node* CodeAssembler::CallJS(Callable const& callable, Node* context, | |
| 684 Node* function, Node* receiver, | |
| 685 size_t result_size) { | |
| 686 const int argc = 0; | |
| 687 Node* target = HeapConstant(callable.code()); | |
| 688 | |
| 689 Node** args = zone()->NewArray<Node*>(argc + 4); | |
| 690 args[0] = function; | |
| 691 args[1] = Int32Constant(argc); | |
| 692 args[2] = receiver; | |
| 693 args[3] = context; | |
| 694 | |
| 695 return CallStubN(callable.descriptor(), argc + 1, target, args, result_size); | |
| 696 } | |
| 697 | |
| 698 Node* CodeAssembler::CallJS(Callable const& callable, Node* context, | |
| 699 Node* function, Node* receiver, Node* arg1, | |
| 700 size_t result_size) { | |
| 701 const int argc = 1; | |
| 702 Node* target = HeapConstant(callable.code()); | |
| 703 | |
| 704 Node** args = zone()->NewArray<Node*>(argc + 4); | |
| 705 args[0] = function; | |
| 706 args[1] = Int32Constant(argc); | |
| 707 args[2] = receiver; | |
| 708 args[3] = arg1; | |
| 709 args[4] = context; | |
| 710 | |
| 711 return CallStubN(callable.descriptor(), argc + 1, target, args, result_size); | |
| 712 } | |
| 713 | |
| 714 Node* CodeAssembler::CallJS(Callable const& callable, Node* context, | |
| 715 Node* function, Node* receiver, Node* arg1, | |
| 716 Node* arg2, size_t result_size) { | |
| 717 const int argc = 2; | |
| 718 Node* target = HeapConstant(callable.code()); | |
| 719 | |
| 720 Node** args = zone()->NewArray<Node*>(argc + 4); | |
| 721 args[0] = function; | |
| 722 args[1] = Int32Constant(argc); | |
| 723 args[2] = receiver; | |
| 724 args[3] = arg1; | |
| 725 args[4] = arg2; | |
| 726 args[5] = context; | |
| 727 | |
| 728 return CallStubN(callable.descriptor(), argc + 1, target, args, result_size); | |
| 729 } | |
| 730 | |
| 731 Node* CodeAssembler::CallJS(Callable const& callable, Node* context, | |
| 732 Node* function, Node* receiver, Node* arg1, | |
| 733 Node* arg2, Node* arg3, size_t result_size) { | |
| 734 const int argc = 3; | |
| 735 Node* target = HeapConstant(callable.code()); | |
| 736 | |
| 737 Node** args = zone()->NewArray<Node*>(argc + 4); | |
| 738 args[0] = function; | |
| 739 args[1] = Int32Constant(argc); | |
| 740 args[2] = receiver; | |
| 741 args[3] = arg1; | |
| 742 args[4] = arg2; | |
| 743 args[5] = arg3; | |
| 744 args[6] = context; | |
| 745 | |
| 746 return CallStubN(callable.descriptor(), argc + 1, target, args, result_size); | |
| 747 } | |
| 748 | |
| 749 Node* CodeAssembler::CallCFunction2(MachineType return_type, | 671 Node* CodeAssembler::CallCFunction2(MachineType return_type, |
| 750 MachineType arg0_type, | 672 MachineType arg0_type, |
| 751 MachineType arg1_type, Node* function, | 673 MachineType arg1_type, Node* function, |
| 752 Node* arg0, Node* arg1) { | 674 Node* arg0, Node* arg1) { |
| 753 return raw_assembler()->CallCFunction2(return_type, arg0_type, arg1_type, | 675 return raw_assembler()->CallCFunction2(return_type, arg0_type, arg1_type, |
| 754 function, arg0, arg1); | 676 function, arg0, arg1); |
| 755 } | 677 } |
| 756 | 678 |
| 757 void CodeAssembler::Goto(Label* label) { | 679 void CodeAssembler::Goto(Label* label) { |
| 758 label->MergeVariables(); | 680 label->MergeVariables(); |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 952 } | 874 } |
| 953 } | 875 } |
| 954 } | 876 } |
| 955 | 877 |
| 956 bound_ = true; | 878 bound_ = true; |
| 957 } | 879 } |
| 958 | 880 |
| 959 } // namespace compiler | 881 } // namespace compiler |
| 960 } // namespace internal | 882 } // namespace internal |
| 961 } // namespace v8 | 883 } // namespace v8 |
| OLD | NEW |