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...) Expand 10 before | Expand all | Expand 10 after 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 // The call target is passed as part of the {inputs} array. |
712 Node* CallRuntime(Runtime::FunctionId function, Node* context, | 711 Node* CallN(CallDescriptor* desc, int input_count, Node* const* inputs); |
713 TArgs... args) { | |
714 int argc = static_cast<int>(sizeof...(args)); | |
715 CallDescriptor* descriptor = Linkage::GetRuntimeCallDescriptor( | |
716 zone(), function, argc, Operator::kNoProperties, | |
717 CallDescriptor::kNoFlags); | |
718 int return_count = static_cast<int>(descriptor->ReturnCount()); | |
719 | 712 |
720 Node* centry = | 713 // Tail call a given call descriptor and the given arguments. |
721 HeapConstant(CodeFactory::RuntimeCEntry(isolate(), return_count)); | 714 // The call target is passed as part of the {inputs} array. |
722 Node* ref = AddNode( | 715 Node* TailCallN(CallDescriptor* desc, int input_count, Node* const* inputs); |
723 common()->ExternalConstant(ExternalReference(function, isolate()))); | |
724 Node* arity = Int32Constant(argc); | |
725 | |
726 return AddNode(common()->Call(descriptor), centry, args..., ref, arity, | |
727 context); | |
728 } | |
729 | 716 |
730 // Call to a C function with zero arguments. | 717 // Call to a C function with zero arguments. |
731 Node* CallCFunction0(MachineType return_type, Node* function); | 718 Node* CallCFunction0(MachineType return_type, Node* function); |
732 // Call to a C function with one parameter. | 719 // Call to a C function with one parameter. |
733 Node* CallCFunction1(MachineType return_type, MachineType arg0_type, | 720 Node* CallCFunction1(MachineType return_type, MachineType arg0_type, |
734 Node* function, Node* arg0); | 721 Node* function, Node* arg0); |
735 // Call to a C function with two arguments. | 722 // Call to a C function with two arguments. |
736 Node* CallCFunction2(MachineType return_type, MachineType arg0_type, | 723 Node* CallCFunction2(MachineType return_type, MachineType arg0_type, |
737 MachineType arg1_type, Node* function, Node* arg0, | 724 MachineType arg1_type, Node* function, Node* arg0, |
738 Node* arg1); | 725 Node* arg1); |
739 // Call to a C function with eight arguments. | 726 // Call to a C function with eight arguments. |
740 Node* CallCFunction8(MachineType return_type, MachineType arg0_type, | 727 Node* CallCFunction8(MachineType return_type, MachineType arg0_type, |
741 MachineType arg1_type, MachineType arg2_type, | 728 MachineType arg1_type, MachineType arg2_type, |
742 MachineType arg3_type, MachineType arg4_type, | 729 MachineType arg3_type, MachineType arg4_type, |
743 MachineType arg5_type, MachineType arg6_type, | 730 MachineType arg5_type, MachineType arg6_type, |
744 MachineType arg7_type, Node* function, Node* arg0, | 731 MachineType arg7_type, Node* function, Node* arg0, |
745 Node* arg1, Node* arg2, Node* arg3, Node* arg4, | 732 Node* arg1, Node* arg2, Node* arg3, Node* arg4, |
746 Node* arg5, Node* arg6, Node* arg7); | 733 Node* arg5, Node* arg6, Node* arg7); |
747 | 734 |
748 // Tail call the given call descriptor and the given arguments. | 735 // Tail call the given call descriptor and the given arguments. |
749 Node* TailCallN(CallDescriptor* call_descriptor, Node* function, Node** args); | 736 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 | 737 |
772 // =========================================================================== | 738 // =========================================================================== |
773 // The following utility methods deal with control flow, hence might switch | 739 // The following utility methods deal with control flow, hence might switch |
774 // the current basic block or create new basic blocks for labels. | 740 // the current basic block or create new basic blocks for labels. |
775 | 741 |
776 // Control flow. | 742 // Control flow. |
777 void Goto(RawMachineLabel* label); | 743 void Goto(RawMachineLabel* label); |
778 void Branch(Node* condition, RawMachineLabel* true_val, | 744 void Branch(Node* condition, RawMachineLabel* true_val, |
779 RawMachineLabel* false_val); | 745 RawMachineLabel* false_val); |
780 void Switch(Node* index, RawMachineLabel* default_label, | 746 void Switch(Node* index, RawMachineLabel* default_label, |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
862 bool deferred_; | 828 bool deferred_; |
863 friend class RawMachineAssembler; | 829 friend class RawMachineAssembler; |
864 DISALLOW_COPY_AND_ASSIGN(RawMachineLabel); | 830 DISALLOW_COPY_AND_ASSIGN(RawMachineLabel); |
865 }; | 831 }; |
866 | 832 |
867 } // namespace compiler | 833 } // namespace compiler |
868 } // namespace internal | 834 } // namespace internal |
869 } // namespace v8 | 835 } // namespace v8 |
870 | 836 |
871 #endif // V8_COMPILER_RAW_MACHINE_ASSEMBLER_H_ | 837 #endif // V8_COMPILER_RAW_MACHINE_ASSEMBLER_H_ |
OLD | NEW |