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 #ifndef V8_COMPILER_RAW_MACHINE_ASSEMBLER_H_ | 5 #ifndef V8_COMPILER_RAW_MACHINE_ASSEMBLER_H_ |
6 #define V8_COMPILER_RAW_MACHINE_ASSEMBLER_H_ | 6 #define V8_COMPILER_RAW_MACHINE_ASSEMBLER_H_ |
7 | 7 |
8 #include "src/assembler.h" | 8 #include "src/assembler.h" |
9 #include "src/code-factory.h" | |
10 #include "src/compiler/common-operator.h" | 9 #include "src/compiler/common-operator.h" |
11 #include "src/compiler/graph.h" | 10 #include "src/compiler/graph.h" |
12 #include "src/compiler/linkage.h" | 11 #include "src/compiler/linkage.h" |
13 #include "src/compiler/machine-operator.h" | 12 #include "src/compiler/machine-operator.h" |
14 #include "src/compiler/node.h" | 13 #include "src/compiler/node.h" |
15 #include "src/compiler/operator.h" | 14 #include "src/compiler/operator.h" |
16 #include "src/factory.h" | 15 #include "src/factory.h" |
17 #include "src/globals.h" | 16 #include "src/globals.h" |
18 | 17 |
19 namespace v8 { | 18 namespace v8 { |
(...skipping 680 matching lines...) Loading... | |
700 Node* StringConstant(const char* string) { | 699 Node* StringConstant(const char* string) { |
701 return HeapConstant(isolate()->factory()->InternalizeUtf8String(string)); | 700 return HeapConstant(isolate()->factory()->InternalizeUtf8String(string)); |
702 } | 701 } |
703 | 702 |
704 // Call a given call descriptor and the given arguments. | 703 // Call a given call descriptor and the given arguments. |
705 Node* CallN(CallDescriptor* desc, Node* function, Node** args); | 704 Node* CallN(CallDescriptor* desc, Node* function, Node** args); |
706 // Call a given call descriptor and the given arguments and frame-state. | 705 // Call a given call descriptor and the given arguments and frame-state. |
707 Node* CallNWithFrameState(CallDescriptor* desc, Node* function, Node** args, | 706 Node* CallNWithFrameState(CallDescriptor* desc, Node* function, Node** args, |
708 Node* frame_state); | 707 Node* frame_state); |
709 | 708 |
710 // Call to a runtime function with given arguments. | 709 // Call a given call descriptor and the given arguments. |
711 template <class... TArgs> | 710 template <class... TArgs> |
712 Node* CallRuntime(Runtime::FunctionId function, Node* context, | 711 Node* CallV(CallDescriptor* desc, Node* target, TArgs... args) { |
Igor Sheludko
2016/12/15 23:34:07
I added suffix V to avoid conflicts in tests with
| |
713 TArgs... args) { | 712 int input_count = static_cast<int>(sizeof...(args)) + 1; |
714 int argc = static_cast<int>(sizeof...(args)); | 713 Node* nodes[] = {target, args...}; |
715 CallDescriptor* descriptor = Linkage::GetRuntimeCallDescriptor( | 714 return AddNode(common()->Call(desc), input_count, nodes); |
716 zone(), function, argc, Operator::kNoProperties, | 715 } |
717 CallDescriptor::kNoFlags); | |
718 int return_count = static_cast<int>(descriptor->ReturnCount()); | |
719 | 716 |
720 Node* centry = | 717 // Tail call a given call descriptor and the given arguments. |
721 HeapConstant(CodeFactory::RuntimeCEntry(isolate(), return_count)); | 718 template <class... TArgs> |
722 Node* ref = AddNode( | 719 Node* TailCallV(CallDescriptor* desc, Node* target, TArgs... args) { |
723 common()->ExternalConstant(ExternalReference(function, isolate()))); | 720 int input_count = static_cast<int>(sizeof...(args)) + 1; |
724 Node* arity = Int32Constant(argc); | 721 Node* nodes[] = {target, args...}; |
725 | 722 return TailCallN(desc, input_count, nodes); |
726 return AddNode(common()->Call(descriptor), centry, args..., ref, arity, | |
727 context); | |
728 } | 723 } |
729 | 724 |
730 // Call to a C function with zero arguments. | 725 // Call to a C function with zero arguments. |
731 Node* CallCFunction0(MachineType return_type, Node* function); | 726 Node* CallCFunction0(MachineType return_type, Node* function); |
732 // Call to a C function with one parameter. | 727 // Call to a C function with one parameter. |
733 Node* CallCFunction1(MachineType return_type, MachineType arg0_type, | 728 Node* CallCFunction1(MachineType return_type, MachineType arg0_type, |
734 Node* function, Node* arg0); | 729 Node* function, Node* arg0); |
735 // Call to a C function with two arguments. | 730 // Call to a C function with two arguments. |
736 Node* CallCFunction2(MachineType return_type, MachineType arg0_type, | 731 Node* CallCFunction2(MachineType return_type, MachineType arg0_type, |
737 MachineType arg1_type, Node* function, Node* arg0, | 732 MachineType arg1_type, Node* function, Node* arg0, |
738 Node* arg1); | 733 Node* arg1); |
739 // Call to a C function with eight arguments. | 734 // Call to a C function with eight arguments. |
740 Node* CallCFunction8(MachineType return_type, MachineType arg0_type, | 735 Node* CallCFunction8(MachineType return_type, MachineType arg0_type, |
741 MachineType arg1_type, MachineType arg2_type, | 736 MachineType arg1_type, MachineType arg2_type, |
742 MachineType arg3_type, MachineType arg4_type, | 737 MachineType arg3_type, MachineType arg4_type, |
743 MachineType arg5_type, MachineType arg6_type, | 738 MachineType arg5_type, MachineType arg6_type, |
744 MachineType arg7_type, Node* function, Node* arg0, | 739 MachineType arg7_type, Node* function, Node* arg0, |
745 Node* arg1, Node* arg2, Node* arg3, Node* arg4, | 740 Node* arg1, Node* arg2, Node* arg3, Node* arg4, |
746 Node* arg5, Node* arg6, Node* arg7); | 741 Node* arg5, Node* arg6, Node* arg7); |
747 | 742 |
748 // Tail call the given call descriptor and the given arguments. | 743 // Tail call the given call descriptor and the given arguments. |
749 Node* TailCallN(CallDescriptor* call_descriptor, Node* function, Node** args); | 744 Node* TailCallN(CallDescriptor* call_descriptor, Node* function, Node** args); |
750 // Tail call to a runtime function with zero arguments. | |
751 Node* TailCallRuntime0(Runtime::FunctionId function, Node* context); | |
752 // Tail call to a runtime function with one argument. | |
753 Node* TailCallRuntime1(Runtime::FunctionId function, Node* arg0, | |
754 Node* context); | |
755 // Tail call to a runtime function with two arguments. | |
756 Node* TailCallRuntime2(Runtime::FunctionId function, Node* arg1, Node* arg2, | |
757 Node* context); | |
758 // Tail call to a runtime function with three arguments. | |
759 Node* TailCallRuntime3(Runtime::FunctionId function, Node* arg1, Node* arg2, | |
760 Node* arg3, Node* context); | |
761 // Tail call to a runtime function with four arguments. | |
762 Node* TailCallRuntime4(Runtime::FunctionId function, Node* arg1, Node* arg2, | |
763 Node* arg3, Node* arg4, Node* context); | |
764 // Tail call to a runtime function with five arguments. | |
765 Node* TailCallRuntime5(Runtime::FunctionId function, Node* arg1, Node* arg2, | |
766 Node* arg3, Node* arg4, Node* arg5, Node* context); | |
767 // Tail call to a runtime function with six arguments. | |
768 Node* TailCallRuntime6(Runtime::FunctionId function, Node* arg1, Node* arg2, | |
769 Node* arg3, Node* arg4, Node* arg5, Node* arg6, | |
770 Node* context); | |
771 | 745 |
772 // =========================================================================== | 746 // =========================================================================== |
773 // The following utility methods deal with control flow, hence might switch | 747 // The following utility methods deal with control flow, hence might switch |
774 // the current basic block or create new basic blocks for labels. | 748 // the current basic block or create new basic blocks for labels. |
775 | 749 |
776 // Control flow. | 750 // Control flow. |
777 void Goto(RawMachineLabel* label); | 751 void Goto(RawMachineLabel* label); |
778 void Branch(Node* condition, RawMachineLabel* true_val, | 752 void Branch(Node* condition, RawMachineLabel* true_val, |
779 RawMachineLabel* false_val); | 753 RawMachineLabel* false_val); |
780 void Switch(Node* index, RawMachineLabel* default_label, | 754 void Switch(Node* index, RawMachineLabel* default_label, |
(...skipping 44 matching lines...) Loading... | |
825 Node* buffer[] = {n1, args...}; | 799 Node* buffer[] = {n1, args...}; |
826 return AddNode(op, sizeof...(args) + 1, buffer); | 800 return AddNode(op, sizeof...(args) + 1, buffer); |
827 } | 801 } |
828 | 802 |
829 private: | 803 private: |
830 Node* MakeNode(const Operator* op, int input_count, Node* const* inputs); | 804 Node* MakeNode(const Operator* op, int input_count, Node* const* inputs); |
831 BasicBlock* Use(RawMachineLabel* label); | 805 BasicBlock* Use(RawMachineLabel* label); |
832 BasicBlock* EnsureBlock(RawMachineLabel* label); | 806 BasicBlock* EnsureBlock(RawMachineLabel* label); |
833 BasicBlock* CurrentBlock(); | 807 BasicBlock* CurrentBlock(); |
834 | 808 |
809 Node* TailCallN(CallDescriptor* desc, int input_count, Node* const* inputs); | |
810 | |
835 Schedule* schedule() { return schedule_; } | 811 Schedule* schedule() { return schedule_; } |
836 size_t parameter_count() const { return call_descriptor_->ParameterCount(); } | 812 size_t parameter_count() const { return call_descriptor_->ParameterCount(); } |
837 | 813 |
838 Isolate* isolate_; | 814 Isolate* isolate_; |
839 Graph* graph_; | 815 Graph* graph_; |
840 Schedule* schedule_; | 816 Schedule* schedule_; |
841 MachineOperatorBuilder machine_; | 817 MachineOperatorBuilder machine_; |
842 CommonOperatorBuilder common_; | 818 CommonOperatorBuilder common_; |
843 CallDescriptor* call_descriptor_; | 819 CallDescriptor* call_descriptor_; |
844 NodeVector parameters_; | 820 NodeVector parameters_; |
(...skipping 17 matching lines...) Loading... | |
862 bool deferred_; | 838 bool deferred_; |
863 friend class RawMachineAssembler; | 839 friend class RawMachineAssembler; |
864 DISALLOW_COPY_AND_ASSIGN(RawMachineLabel); | 840 DISALLOW_COPY_AND_ASSIGN(RawMachineLabel); |
865 }; | 841 }; |
866 | 842 |
867 } // namespace compiler | 843 } // namespace compiler |
868 } // namespace internal | 844 } // namespace internal |
869 } // namespace v8 | 845 } // namespace v8 |
870 | 846 |
871 #endif // V8_COMPILER_RAW_MACHINE_ASSEMBLER_H_ | 847 #endif // V8_COMPILER_RAW_MACHINE_ASSEMBLER_H_ |
OLD | NEW |