59 //------------------------------StartNode--------------------------------------
60 // The method start node
61 class StartNode : public MultiNode {
62 virtual bool cmp( const Node &n ) const;
63 virtual uint size_of() const; // Size is bigger
64 public:
65 const TypeTuple *_domain;
66 StartNode( Node *root, const TypeTuple *domain ) : MultiNode(2), _domain(domain) {
67 init_class_id(Class_Start);
68 init_req(0,this);
69 init_req(1,root);
70 }
71 virtual int Opcode() const;
72 virtual bool pinned() const { return true; };
73 virtual const Type *bottom_type() const;
74 virtual const TypePtr *adr_type() const { return TypePtr::BOTTOM; }
75 virtual const Type* Value(PhaseGVN* phase) const;
76 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
77 virtual void calling_convention( BasicType* sig_bt, VMRegPair *parm_reg, uint length ) const;
78 virtual const RegMask &in_RegMask(uint) const;
79 virtual Node *match( const ProjNode *proj, const Matcher *m );
80 virtual uint ideal_reg() const { return 0; }
81 #ifndef PRODUCT
82 virtual void dump_spec(outputStream *st) const;
83 virtual void dump_compact_spec(outputStream *st) const;
84 #endif
85 };
86
87 //------------------------------StartOSRNode-----------------------------------
88 // The method start node for on stack replacement code
89 class StartOSRNode : public StartNode {
90 public:
91 StartOSRNode( Node *root, const TypeTuple *domain ) : StartNode(root, domain) {}
92 virtual int Opcode() const;
93 static const TypeTuple *osr_domain();
94 };
95
96
97 //------------------------------ParmNode---------------------------------------
98 // Incoming parameters
99 class ParmNode : public ProjNode {
100 static const char * const names[TypeFunc::Parms+1];
101 public:
102 ParmNode( StartNode *src, uint con ) : ProjNode(src,con) {
103 init_class_id(Class_Parm);
104 }
105 virtual int Opcode() const;
106 virtual bool is_CFG() const { return (_con == TypeFunc::Control); }
107 virtual uint ideal_reg() const;
108 #ifndef PRODUCT
109 virtual void dump_spec(outputStream *st) const;
110 virtual void dump_compact_spec(outputStream *st) const;
111 #endif
112 };
113
707 assert(jvms != nullptr, "JVMS reference is null.");
708 return jvms->scloff() + _merge_pointer_idx + 1;
709 }
710
711 // Assumes that "this" is an argument to a safepoint node "s", and that
712 // "new_call" is being created to correspond to "s". But the difference
713 // between the start index of the jvmstates of "new_call" and "s" is
714 // "jvms_adj". Produce and return a SafePointScalarObjectNode that
715 // corresponds appropriately to "this" in "new_call". Assumes that
716 // "sosn_map" is a map, specific to the translation of "s" to "new_call",
717 // mapping old SafePointScalarObjectNodes to new, to avoid multiple copies.
718 SafePointScalarMergeNode* clone(Dict* sosn_map, bool& new_node) const;
719
720 #ifndef PRODUCT
721 virtual void dump_spec(outputStream *st) const;
722 #endif
723 };
724
725 // Simple container for the outgoing projections of a call. Useful
726 // for serious surgery on calls.
727 class CallProjections : public StackObj {
728 public:
729 Node* fallthrough_proj;
730 Node* fallthrough_catchproj;
731 Node* fallthrough_memproj;
732 Node* fallthrough_ioproj;
733 Node* catchall_catchproj;
734 Node* catchall_memproj;
735 Node* catchall_ioproj;
736 Node* resproj;
737 Node* exobj;
738 };
739
740 class CallGenerator;
741
742 //------------------------------CallNode---------------------------------------
743 // Call nodes now subsume the function of debug nodes at callsites, so they
744 // contain the functionality of a full scope chain of debug nodes.
745 class CallNode : public SafePointNode {
746
747 protected:
748 bool may_modify_arraycopy_helper(const TypeOopPtr* dest_t, const TypeOopPtr* t_oop, PhaseValues* phase) const;
749
750 public:
751 const TypeFunc* _tf; // Function type
752 address _entry_point; // Address of method being called
753 float _cnt; // Estimate of number of times called
754 CallGenerator* _generator; // corresponding CallGenerator for some late inline calls
755 const char* _name; // Printable name, if _method is null
756
757 CallNode(const TypeFunc* tf, address addr, const TypePtr* adr_type, JVMState* jvms = nullptr)
758 : SafePointNode(tf->domain()->cnt(), jvms, adr_type),
759 _tf(tf),
760 _entry_point(addr),
761 _cnt(COUNT_UNKNOWN),
762 _generator(nullptr),
763 _name(nullptr)
764 {
765 init_class_id(Class_Call);
766 }
767
768 const TypeFunc* tf() const { return _tf; }
769 address entry_point() const { return _entry_point; }
770 float cnt() const { return _cnt; }
771 CallGenerator* generator() const { return _generator; }
772
773 void set_tf(const TypeFunc* tf) { _tf = tf; }
774 void set_entry_point(address p) { _entry_point = p; }
775 void set_cnt(float c) { _cnt = c; }
776 void set_generator(CallGenerator* cg) { _generator = cg; }
777
778 virtual const Type* bottom_type() const;
779 virtual const Type* Value(PhaseGVN* phase) const;
780 virtual Node* Ideal(PhaseGVN* phase, bool can_reshape);
781 virtual Node* Identity(PhaseGVN* phase) { return this; }
782 virtual bool cmp(const Node &n) const;
783 virtual uint size_of() const = 0;
784 virtual void calling_convention(BasicType* sig_bt, VMRegPair* parm_regs, uint argcnt) const;
785 virtual Node* match(const ProjNode* proj, const Matcher* m);
786 virtual uint ideal_reg() const { return NotAMachineReg; }
787 // Are we guaranteed that this node is a safepoint? Not true for leaf calls and
788 // for some macro nodes whose expansion does not have a safepoint on the fast path.
789 virtual bool guaranteed_safepoint() { return true; }
790 // For macro nodes, the JVMState gets modified during expansion. If calls
791 // use MachConstantBase, it gets modified during matching. If the call is
792 // late inlined, it also needs the full JVMState. So when cloning the
793 // node the JVMState must be deep cloned. Default is to shallow clone.
794 virtual bool needs_deep_clone_jvms(Compile* C) { return _generator != nullptr || C->needs_deep_clone_jvms(); }
795
796 // Returns true if the call may modify n
797 virtual bool may_modify(const TypeOopPtr* t_oop, PhaseValues* phase) const;
798 // Does this node have a use of n other than in debug information?
799 bool has_non_debug_use(const Node* n);
800 // Returns the unique CheckCastPP of a call
801 // or result projection is there are several CheckCastPP
802 // or returns null if there is no one.
803 Node* result_cast();
804 // Does this node returns pointer?
805 bool returns_pointer() const {
806 const TypeTuple* r = tf()->range();
807 return (r->cnt() > TypeFunc::Parms &&
808 r->field_at(TypeFunc::Parms)->isa_ptr());
809 }
810
811 // Collect all the interesting edges from a call for use in
812 // replacing the call by something else. Used by macro expansion
813 // and the late inlining support.
814 void extract_projections(CallProjections* projs,
815 bool separate_io_proj,
816 bool do_asserts = true,
817 bool allow_handlers = false) const;
818
819 virtual uint match_edge(uint idx) const;
820
821 bool is_call_to_arraycopystub() const;
822 bool is_call_to_multianewarray_stub() const;
823
824 virtual void copy_call_debug_info(PhaseIterGVN* phase, SafePointNode* sfpt) {}
825
826 #ifndef PRODUCT
827 virtual void dump_req(outputStream* st = tty, DumpConfig* dc = nullptr) const;
828 virtual void dump_spec(outputStream* st) const;
829 #endif
830 };
831
832
833 //------------------------------CallJavaNode-----------------------------------
834 // Make a static or dynamic subroutine call node using Java calling
835 // convention. (The "Java" calling convention is the compiler's calling
836 // convention, as opposed to the interpreter's or that of native C.)
837 class CallJavaNode : public CallNode {
867 void register_for_late_inline();
868
869 DEBUG_ONLY( bool validate_symbolic_info() const; )
870
871 #ifndef PRODUCT
872 virtual void dump_spec(outputStream *st) const;
873 virtual void dump_compact_spec(outputStream *st) const;
874 #endif
875 };
876
877 //------------------------------CallStaticJavaNode-----------------------------
878 // Make a direct subroutine call using Java calling convention (for static
879 // calls and optimized virtual calls, plus calls to wrappers for run-time
880 // routines); generates static stub.
881 class CallStaticJavaNode : public CallJavaNode {
882 // If this is an uncommon trap guarded by some condition, is it safe to change the condition to a narrower condition?
883 // See comment in PhaseIdealLoop::do_split_if()
884 bool _safe_for_fold_compare;
885 virtual bool cmp( const Node &n ) const;
886 virtual uint size_of() const; // Size is bigger
887 public:
888 CallStaticJavaNode(Compile* C, const TypeFunc* tf, address addr, ciMethod* method)
889 : CallJavaNode(tf, addr, method), _safe_for_fold_compare(true) {
890 init_class_id(Class_CallStaticJava);
891 if (C->eliminate_boxing() && (method != nullptr) && method->is_boxing_method()) {
892 init_flags(Flag_is_macro);
893 C->add_macro_node(this);
894 }
895 }
896 CallStaticJavaNode(const TypeFunc* tf, address addr, const char* name, const TypePtr* adr_type)
897 : CallJavaNode(tf, addr, nullptr), _safe_for_fold_compare(true) {
898 init_class_id(Class_CallStaticJava);
899 // This node calls a runtime stub, which often has narrow memory effects.
900 _adr_type = adr_type;
901 _name = name;
902 }
903
904 // If this is an uncommon trap, return the request code, else zero.
905 int uncommon_trap_request() const;
906 bool is_uncommon_trap() const;
907 static int extract_uncommon_trap_request(const Node* call);
908
909 bool is_boxing_method() const {
910 return is_macro() && (method() != nullptr) && method()->is_boxing_method();
911 }
912 // Late inlining modifies the JVMState, so we need to deep clone it
913 // when the call node is cloned (because it is macro node).
914 virtual bool needs_deep_clone_jvms(Compile* C) {
1021 init_class_id(Class_CallLeafPure);
1022 }
1023 int Opcode() const override;
1024 Node* Ideal(PhaseGVN* phase, bool can_reshape) override;
1025
1026 CallLeafPureNode* inline_call_leaf_pure_node(Node* control = nullptr) const;
1027 };
1028
1029 //------------------------------CallLeafNoFPNode-------------------------------
1030 // CallLeafNode, not using floating point or using it in the same manner as
1031 // the generated code
1032 class CallLeafNoFPNode : public CallLeafNode {
1033 public:
1034 CallLeafNoFPNode(const TypeFunc* tf, address addr, const char* name,
1035 const TypePtr* adr_type)
1036 : CallLeafNode(tf, addr, name, adr_type)
1037 {
1038 init_class_id(Class_CallLeafNoFP);
1039 }
1040 virtual int Opcode() const;
1041 };
1042
1043 //------------------------------CallLeafVectorNode-------------------------------
1044 // CallLeafNode but calling with vector calling convention instead.
1045 class CallLeafVectorNode : public CallLeafNode {
1046 private:
1047 uint _num_bits;
1048 protected:
1049 virtual bool cmp( const Node &n ) const;
1050 virtual uint size_of() const; // Size is bigger
1051 public:
1052 CallLeafVectorNode(const TypeFunc* tf, address addr, const char* name,
1053 const TypePtr* adr_type, uint num_bits)
1054 : CallLeafNode(tf, addr, name, adr_type), _num_bits(num_bits)
1055 {
1056 }
1057 virtual int Opcode() const;
1058 virtual void calling_convention( BasicType* sig_bt, VMRegPair *parm_regs, uint argcnt ) const;
1059 };
1060
1063 // High-level memory allocation
1064 //
1065 // AllocateNode and AllocateArrayNode are subclasses of CallNode because they will
1066 // get expanded into a code sequence containing a call. Unlike other CallNodes,
1067 // they have 2 memory projections and 2 i_o projections (which are distinguished by
1068 // the _is_io_use flag in the projection.) This is needed when expanding the node in
1069 // order to differentiate the uses of the projection on the normal control path from
1070 // those on the exception return path.
1071 //
1072 class AllocateNode : public CallNode {
1073 public:
1074 enum {
1075 // Output:
1076 RawAddress = TypeFunc::Parms, // the newly-allocated raw address
1077 // Inputs:
1078 AllocSize = TypeFunc::Parms, // size (in bytes) of the new object
1079 KlassNode, // type (maybe dynamic) of the obj.
1080 InitialTest, // slow-path test (may be constant)
1081 ALength, // array length (or TOP if none)
1082 ValidLengthTest,
1083 ParmLimit
1084 };
1085
1086 static const TypeFunc* alloc_type(const Type* t) {
1087 const Type** fields = TypeTuple::fields(ParmLimit - TypeFunc::Parms);
1088 fields[AllocSize] = TypeInt::POS;
1089 fields[KlassNode] = TypeInstPtr::NOTNULL;
1090 fields[InitialTest] = TypeInt::BOOL;
1091 fields[ALength] = t; // length (can be a bad length)
1092 fields[ValidLengthTest] = TypeInt::BOOL;
1093
1094 const TypeTuple *domain = TypeTuple::make(ParmLimit, fields);
1095
1096 // create result type (range)
1097 fields = TypeTuple::fields(1);
1098 fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop
1099
1100 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
1101
1102 return TypeFunc::make(domain, range);
1103 }
1104
1105 // Result of Escape Analysis
1106 bool _is_scalar_replaceable;
1107 bool _is_non_escaping;
1108 // True when MemBar for new is redundant with MemBar at initialzer exit
1109 bool _is_allocation_MemBar_redundant;
1110
1111 virtual uint size_of() const; // Size is bigger
1112 AllocateNode(Compile* C, const TypeFunc *atype, Node *ctrl, Node *mem, Node *abio,
1113 Node *size, Node *klass_node, Node *initial_test);
1114 // Expansion modifies the JVMState, so we need to deep clone it
1115 virtual bool needs_deep_clone_jvms(Compile* C) { return true; }
1116 virtual int Opcode() const;
1117 virtual uint ideal_reg() const { return Op_RegP; }
1118 virtual bool guaranteed_safepoint() { return false; }
1119
1120 // allocations do not modify their arguments
1121 virtual bool may_modify(const TypeOopPtr* t_oop, PhaseValues* phase) const { return false; }
1122
1123 // Pattern-match a possible usage of AllocateNode.
1124 // Return null if no allocation is recognized.
1125 // The operand is the pointer produced by the (possible) allocation.
1126 // It must be a projection of the Allocate or its subsequent CastPP.
1127 // (Note: This function is defined in file graphKit.cpp, near
1128 // GraphKit::new_instance/new_array, whose output it recognizes.)
1129 // The 'ptr' may not have an offset unless the 'offset' argument is given.
1130 static AllocateNode* Ideal_allocation(Node* ptr);
1131
1132 // Fancy version which uses AddPNode::Ideal_base_and_offset to strip
1133 // an offset, which is reported back to the caller.
1170
1171 // If object doesn't escape in <.init> method and there is memory barrier
1172 // inserted at exit of its <.init>, memory barrier for new is not necessary.
1173 // Inovke this method when MemBar at exit of initializer and post-dominate
1174 // allocation node.
1175 void compute_MemBar_redundancy(ciMethod* initializer);
1176 bool is_allocation_MemBar_redundant() { return _is_allocation_MemBar_redundant; }
1177
1178 Node* make_ideal_mark(PhaseGVN* phase, Node* control, Node* mem);
1179
1180 NOT_PRODUCT(virtual void dump_spec(outputStream* st) const;)
1181 };
1182
1183 //------------------------------AllocateArray---------------------------------
1184 //
1185 // High-level array allocation
1186 //
1187 class AllocateArrayNode : public AllocateNode {
1188 public:
1189 AllocateArrayNode(Compile* C, const TypeFunc* atype, Node* ctrl, Node* mem, Node* abio, Node* size, Node* klass_node,
1190 Node* initial_test, Node* count_val, Node* valid_length_test)
1191 : AllocateNode(C, atype, ctrl, mem, abio, size, klass_node,
1192 initial_test)
1193 {
1194 init_class_id(Class_AllocateArray);
1195 set_req(AllocateNode::ALength, count_val);
1196 set_req(AllocateNode::ValidLengthTest, valid_length_test);
1197 }
1198 virtual int Opcode() const;
1199
1200 // Dig the length operand out of a array allocation site.
1201 Node* Ideal_length() {
1202 return in(AllocateNode::ALength);
1203 }
1204
1205 // Dig the length operand out of a array allocation site and narrow the
1206 // type with a CastII, if necesssary
1207 Node* make_ideal_length(const TypeOopPtr* ary_type, PhaseValues* phase, bool can_create = true);
1208
1209 // Pattern-match a possible usage of AllocateArrayNode.
1210 // Return null if no allocation is recognized.
1211 static AllocateArrayNode* Ideal_array_allocation(Node* ptr) {
1212 AllocateNode* allo = Ideal_allocation(ptr);
1213 return (allo == nullptr || !allo->is_AllocateArray())
1214 ? nullptr : allo->as_AllocateArray();
1215 }
1216 };
1217
|
59 //------------------------------StartNode--------------------------------------
60 // The method start node
61 class StartNode : public MultiNode {
62 virtual bool cmp( const Node &n ) const;
63 virtual uint size_of() const; // Size is bigger
64 public:
65 const TypeTuple *_domain;
66 StartNode( Node *root, const TypeTuple *domain ) : MultiNode(2), _domain(domain) {
67 init_class_id(Class_Start);
68 init_req(0,this);
69 init_req(1,root);
70 }
71 virtual int Opcode() const;
72 virtual bool pinned() const { return true; };
73 virtual const Type *bottom_type() const;
74 virtual const TypePtr *adr_type() const { return TypePtr::BOTTOM; }
75 virtual const Type* Value(PhaseGVN* phase) const;
76 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
77 virtual void calling_convention( BasicType* sig_bt, VMRegPair *parm_reg, uint length ) const;
78 virtual const RegMask &in_RegMask(uint) const;
79 virtual Node *match(const ProjNode *proj, const Matcher *m, const RegMask* mask);
80 virtual uint ideal_reg() const { return 0; }
81 #ifndef PRODUCT
82 virtual void dump_spec(outputStream *st) const;
83 virtual void dump_compact_spec(outputStream *st) const;
84 #endif
85 };
86
87 //------------------------------StartOSRNode-----------------------------------
88 // The method start node for on stack replacement code
89 class StartOSRNode : public StartNode {
90 public:
91 StartOSRNode( Node *root, const TypeTuple *domain ) : StartNode(root, domain) {}
92 virtual int Opcode() const;
93 };
94
95
96 //------------------------------ParmNode---------------------------------------
97 // Incoming parameters
98 class ParmNode : public ProjNode {
99 static const char * const names[TypeFunc::Parms+1];
100 public:
101 ParmNode( StartNode *src, uint con ) : ProjNode(src,con) {
102 init_class_id(Class_Parm);
103 }
104 virtual int Opcode() const;
105 virtual bool is_CFG() const { return (_con == TypeFunc::Control); }
106 virtual uint ideal_reg() const;
107 #ifndef PRODUCT
108 virtual void dump_spec(outputStream *st) const;
109 virtual void dump_compact_spec(outputStream *st) const;
110 #endif
111 };
112
706 assert(jvms != nullptr, "JVMS reference is null.");
707 return jvms->scloff() + _merge_pointer_idx + 1;
708 }
709
710 // Assumes that "this" is an argument to a safepoint node "s", and that
711 // "new_call" is being created to correspond to "s". But the difference
712 // between the start index of the jvmstates of "new_call" and "s" is
713 // "jvms_adj". Produce and return a SafePointScalarObjectNode that
714 // corresponds appropriately to "this" in "new_call". Assumes that
715 // "sosn_map" is a map, specific to the translation of "s" to "new_call",
716 // mapping old SafePointScalarObjectNodes to new, to avoid multiple copies.
717 SafePointScalarMergeNode* clone(Dict* sosn_map, bool& new_node) const;
718
719 #ifndef PRODUCT
720 virtual void dump_spec(outputStream *st) const;
721 #endif
722 };
723
724 // Simple container for the outgoing projections of a call. Useful
725 // for serious surgery on calls.
726 class CallProjections {
727 public:
728 Node* fallthrough_proj;
729 Node* fallthrough_catchproj;
730 Node* fallthrough_memproj;
731 Node* fallthrough_ioproj;
732 Node* catchall_catchproj;
733 Node* catchall_memproj;
734 Node* catchall_ioproj;
735 Node* exobj;
736 uint nb_resproj;
737 Node* resproj[1]; // at least one projection
738
739 CallProjections(uint nbres) {
740 fallthrough_proj = nullptr;
741 fallthrough_catchproj = nullptr;
742 fallthrough_memproj = nullptr;
743 fallthrough_ioproj = nullptr;
744 catchall_catchproj = nullptr;
745 catchall_memproj = nullptr;
746 catchall_ioproj = nullptr;
747 exobj = nullptr;
748 nb_resproj = nbres;
749 resproj[0] = nullptr;
750 for (uint i = 1; i < nb_resproj; i++) {
751 resproj[i] = nullptr;
752 }
753 }
754
755 };
756
757 class CallGenerator;
758
759 //------------------------------CallNode---------------------------------------
760 // Call nodes now subsume the function of debug nodes at callsites, so they
761 // contain the functionality of a full scope chain of debug nodes.
762 class CallNode : public SafePointNode {
763
764 protected:
765 bool may_modify_arraycopy_helper(const TypeOopPtr* dest_t, const TypeOopPtr* t_oop, PhaseValues* phase) const;
766
767 public:
768 const TypeFunc* _tf; // Function type
769 address _entry_point; // Address of method being called
770 float _cnt; // Estimate of number of times called
771 CallGenerator* _generator; // corresponding CallGenerator for some late inline calls
772 const char* _name; // Printable name, if _method is null
773
774 CallNode(const TypeFunc* tf, address addr, const TypePtr* adr_type, JVMState* jvms = nullptr)
775 : SafePointNode(tf->domain_cc()->cnt(), jvms, adr_type),
776 _tf(tf),
777 _entry_point(addr),
778 _cnt(COUNT_UNKNOWN),
779 _generator(nullptr),
780 _name(nullptr)
781 {
782 init_class_id(Class_Call);
783 }
784
785 const TypeFunc* tf() const { return _tf; }
786 address entry_point() const { return _entry_point; }
787 float cnt() const { return _cnt; }
788 CallGenerator* generator() const { return _generator; }
789
790 void set_tf(const TypeFunc* tf) { _tf = tf; }
791 void set_entry_point(address p) { _entry_point = p; }
792 void set_cnt(float c) { _cnt = c; }
793 void set_generator(CallGenerator* cg) { _generator = cg; }
794
795 virtual const Type* bottom_type() const;
796 virtual const Type* Value(PhaseGVN* phase) const;
797 virtual Node* Ideal(PhaseGVN* phase, bool can_reshape);
798 virtual Node* Identity(PhaseGVN* phase) { return this; }
799 virtual bool cmp(const Node &n) const;
800 virtual uint size_of() const = 0;
801 virtual void calling_convention(BasicType* sig_bt, VMRegPair* parm_regs, uint argcnt) const;
802 virtual Node* match(const ProjNode* proj, const Matcher* m, const RegMask* mask);
803 virtual uint ideal_reg() const { return NotAMachineReg; }
804 // Are we guaranteed that this node is a safepoint? Not true for leaf calls and
805 // for some macro nodes whose expansion does not have a safepoint on the fast path.
806 virtual bool guaranteed_safepoint() { return true; }
807 // For macro nodes, the JVMState gets modified during expansion. If calls
808 // use MachConstantBase, it gets modified during matching. If the call is
809 // late inlined, it also needs the full JVMState. So when cloning the
810 // node the JVMState must be deep cloned. Default is to shallow clone.
811 virtual bool needs_deep_clone_jvms(Compile* C) { return _generator != nullptr || C->needs_deep_clone_jvms(); }
812
813 // Returns true if the call may modify n
814 virtual bool may_modify(const TypeOopPtr* t_oop, PhaseValues* phase) const;
815 // Does this node have a use of n other than in debug information?
816 bool has_non_debug_use(const Node* n);
817 bool has_debug_use(const Node* n) const;
818 // Returns the unique CheckCastPP of a call
819 // or result projection is there are several CheckCastPP
820 // or returns null if there is no one.
821 Node* result_cast();
822 // Does this node returns pointer?
823 bool returns_pointer() const {
824 const TypeTuple* r = tf()->range_sig();
825 return (!tf()->returns_inline_type_as_fields() &&
826 r->cnt() > TypeFunc::Parms &&
827 r->field_at(TypeFunc::Parms)->isa_ptr());
828 }
829
830 // Collect all the interesting edges from a call for use in
831 // replacing the call by something else. Used by macro expansion
832 // and the late inlining support.
833 CallProjections* extract_projections(bool separate_io_proj,
834 bool do_asserts = true,
835 bool allow_handlers = false) const;
836
837 virtual uint match_edge(uint idx) const;
838
839 bool is_call_to_arraycopystub() const;
840 bool is_call_to_multianewarray_stub() const;
841
842 virtual void copy_call_debug_info(PhaseIterGVN* phase, SafePointNode* sfpt) {}
843
844 #ifndef PRODUCT
845 virtual void dump_req(outputStream* st = tty, DumpConfig* dc = nullptr) const;
846 virtual void dump_spec(outputStream* st) const;
847 #endif
848 };
849
850
851 //------------------------------CallJavaNode-----------------------------------
852 // Make a static or dynamic subroutine call node using Java calling
853 // convention. (The "Java" calling convention is the compiler's calling
854 // convention, as opposed to the interpreter's or that of native C.)
855 class CallJavaNode : public CallNode {
885 void register_for_late_inline();
886
887 DEBUG_ONLY( bool validate_symbolic_info() const; )
888
889 #ifndef PRODUCT
890 virtual void dump_spec(outputStream *st) const;
891 virtual void dump_compact_spec(outputStream *st) const;
892 #endif
893 };
894
895 //------------------------------CallStaticJavaNode-----------------------------
896 // Make a direct subroutine call using Java calling convention (for static
897 // calls and optimized virtual calls, plus calls to wrappers for run-time
898 // routines); generates static stub.
899 class CallStaticJavaNode : public CallJavaNode {
900 // If this is an uncommon trap guarded by some condition, is it safe to change the condition to a narrower condition?
901 // See comment in PhaseIdealLoop::do_split_if()
902 bool _safe_for_fold_compare;
903 virtual bool cmp( const Node &n ) const;
904 virtual uint size_of() const; // Size is bigger
905
906 bool remove_unknown_flat_array_load(PhaseIterGVN* igvn, Node* ctl, Node* mem, Node* unc_arg);
907 Node* replace_is_substitutable(PhaseIterGVN* igvn);
908
909 public:
910 CallStaticJavaNode(Compile* C, const TypeFunc* tf, address addr, ciMethod* method)
911 : CallJavaNode(tf, addr, method), _safe_for_fold_compare(true) {
912 init_class_id(Class_CallStaticJava);
913 if (C->eliminate_boxing() && (method != nullptr) && method->is_boxing_method()) {
914 init_flags(Flag_is_macro);
915 C->add_macro_node(this);
916 }
917 const TypeTuple *r = tf->range_sig();
918 if (InlineTypeReturnedAsFields &&
919 method != nullptr &&
920 method->is_method_handle_intrinsic() &&
921 r->cnt() > TypeFunc::Parms &&
922 r->field_at(TypeFunc::Parms)->isa_oopptr() &&
923 r->field_at(TypeFunc::Parms)->is_oopptr()->can_be_inline_type()) {
924 // Make sure this call is processed by PhaseMacroExpand::expand_mh_intrinsic_return
925 init_flags(Flag_is_macro);
926 C->add_macro_node(this);
927 }
928 }
929 CallStaticJavaNode(const TypeFunc* tf, address addr, const char* name, const TypePtr* adr_type)
930 : CallJavaNode(tf, addr, nullptr), _safe_for_fold_compare(true) {
931 init_class_id(Class_CallStaticJava);
932 // This node calls a runtime stub, which often has narrow memory effects.
933 _adr_type = adr_type;
934 _name = name;
935 }
936
937 // If this is an uncommon trap, return the request code, else zero.
938 int uncommon_trap_request() const;
939 bool is_uncommon_trap() const;
940 static int extract_uncommon_trap_request(const Node* call);
941
942 bool is_boxing_method() const {
943 return is_macro() && (method() != nullptr) && method()->is_boxing_method();
944 }
945 // Late inlining modifies the JVMState, so we need to deep clone it
946 // when the call node is cloned (because it is macro node).
947 virtual bool needs_deep_clone_jvms(Compile* C) {
1054 init_class_id(Class_CallLeafPure);
1055 }
1056 int Opcode() const override;
1057 Node* Ideal(PhaseGVN* phase, bool can_reshape) override;
1058
1059 CallLeafPureNode* inline_call_leaf_pure_node(Node* control = nullptr) const;
1060 };
1061
1062 //------------------------------CallLeafNoFPNode-------------------------------
1063 // CallLeafNode, not using floating point or using it in the same manner as
1064 // the generated code
1065 class CallLeafNoFPNode : public CallLeafNode {
1066 public:
1067 CallLeafNoFPNode(const TypeFunc* tf, address addr, const char* name,
1068 const TypePtr* adr_type)
1069 : CallLeafNode(tf, addr, name, adr_type)
1070 {
1071 init_class_id(Class_CallLeafNoFP);
1072 }
1073 virtual int Opcode() const;
1074 virtual uint match_edge(uint idx) const;
1075 };
1076
1077 //------------------------------CallLeafVectorNode-------------------------------
1078 // CallLeafNode but calling with vector calling convention instead.
1079 class CallLeafVectorNode : public CallLeafNode {
1080 private:
1081 uint _num_bits;
1082 protected:
1083 virtual bool cmp( const Node &n ) const;
1084 virtual uint size_of() const; // Size is bigger
1085 public:
1086 CallLeafVectorNode(const TypeFunc* tf, address addr, const char* name,
1087 const TypePtr* adr_type, uint num_bits)
1088 : CallLeafNode(tf, addr, name, adr_type), _num_bits(num_bits)
1089 {
1090 }
1091 virtual int Opcode() const;
1092 virtual void calling_convention( BasicType* sig_bt, VMRegPair *parm_regs, uint argcnt ) const;
1093 };
1094
1097 // High-level memory allocation
1098 //
1099 // AllocateNode and AllocateArrayNode are subclasses of CallNode because they will
1100 // get expanded into a code sequence containing a call. Unlike other CallNodes,
1101 // they have 2 memory projections and 2 i_o projections (which are distinguished by
1102 // the _is_io_use flag in the projection.) This is needed when expanding the node in
1103 // order to differentiate the uses of the projection on the normal control path from
1104 // those on the exception return path.
1105 //
1106 class AllocateNode : public CallNode {
1107 public:
1108 enum {
1109 // Output:
1110 RawAddress = TypeFunc::Parms, // the newly-allocated raw address
1111 // Inputs:
1112 AllocSize = TypeFunc::Parms, // size (in bytes) of the new object
1113 KlassNode, // type (maybe dynamic) of the obj.
1114 InitialTest, // slow-path test (may be constant)
1115 ALength, // array length (or TOP if none)
1116 ValidLengthTest,
1117 InlineType, // InlineTypeNode if this is an inline type allocation
1118 InitValue, // Init value for null-free inline type arrays
1119 RawInitValue, // Same as above but as raw machine word
1120 ParmLimit
1121 };
1122
1123 static const TypeFunc* alloc_type(const Type* t) {
1124 const Type** fields = TypeTuple::fields(ParmLimit - TypeFunc::Parms);
1125 fields[AllocSize] = TypeInt::POS;
1126 fields[KlassNode] = TypeInstPtr::NOTNULL;
1127 fields[InitialTest] = TypeInt::BOOL;
1128 fields[ALength] = t; // length (can be a bad length)
1129 fields[ValidLengthTest] = TypeInt::BOOL;
1130 fields[InlineType] = Type::BOTTOM;
1131 fields[InitValue] = TypeInstPtr::NOTNULL;
1132 fields[RawInitValue] = TypeX_X;
1133
1134 const TypeTuple *domain = TypeTuple::make(ParmLimit, fields);
1135
1136 // create result type (range)
1137 fields = TypeTuple::fields(1);
1138 fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop
1139
1140 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
1141
1142 return TypeFunc::make(domain, range);
1143 }
1144
1145 // Result of Escape Analysis
1146 bool _is_scalar_replaceable;
1147 bool _is_non_escaping;
1148 // True when MemBar for new is redundant with MemBar at initialzer exit
1149 bool _is_allocation_MemBar_redundant;
1150
1151 virtual uint size_of() const; // Size is bigger
1152 AllocateNode(Compile* C, const TypeFunc *atype, Node *ctrl, Node *mem, Node *abio,
1153 Node *size, Node *klass_node, Node *initial_test,
1154 InlineTypeNode* inline_type_node = nullptr);
1155 // Expansion modifies the JVMState, so we need to deep clone it
1156 virtual bool needs_deep_clone_jvms(Compile* C) { return true; }
1157 virtual int Opcode() const;
1158 virtual uint ideal_reg() const { return Op_RegP; }
1159 virtual bool guaranteed_safepoint() { return false; }
1160
1161 // allocations do not modify their arguments
1162 virtual bool may_modify(const TypeOopPtr* t_oop, PhaseValues* phase) const { return false; }
1163
1164 // Pattern-match a possible usage of AllocateNode.
1165 // Return null if no allocation is recognized.
1166 // The operand is the pointer produced by the (possible) allocation.
1167 // It must be a projection of the Allocate or its subsequent CastPP.
1168 // (Note: This function is defined in file graphKit.cpp, near
1169 // GraphKit::new_instance/new_array, whose output it recognizes.)
1170 // The 'ptr' may not have an offset unless the 'offset' argument is given.
1171 static AllocateNode* Ideal_allocation(Node* ptr);
1172
1173 // Fancy version which uses AddPNode::Ideal_base_and_offset to strip
1174 // an offset, which is reported back to the caller.
1211
1212 // If object doesn't escape in <.init> method and there is memory barrier
1213 // inserted at exit of its <.init>, memory barrier for new is not necessary.
1214 // Inovke this method when MemBar at exit of initializer and post-dominate
1215 // allocation node.
1216 void compute_MemBar_redundancy(ciMethod* initializer);
1217 bool is_allocation_MemBar_redundant() { return _is_allocation_MemBar_redundant; }
1218
1219 Node* make_ideal_mark(PhaseGVN* phase, Node* control, Node* mem);
1220
1221 NOT_PRODUCT(virtual void dump_spec(outputStream* st) const;)
1222 };
1223
1224 //------------------------------AllocateArray---------------------------------
1225 //
1226 // High-level array allocation
1227 //
1228 class AllocateArrayNode : public AllocateNode {
1229 public:
1230 AllocateArrayNode(Compile* C, const TypeFunc* atype, Node* ctrl, Node* mem, Node* abio, Node* size, Node* klass_node,
1231 Node* initial_test, Node* count_val, Node* valid_length_test,
1232 Node* init_value, Node* raw_init_value)
1233 : AllocateNode(C, atype, ctrl, mem, abio, size, klass_node,
1234 initial_test)
1235 {
1236 init_class_id(Class_AllocateArray);
1237 set_req(AllocateNode::ALength, count_val);
1238 set_req(AllocateNode::ValidLengthTest, valid_length_test);
1239 init_req(AllocateNode::InitValue, init_value);
1240 init_req(AllocateNode::RawInitValue, raw_init_value);
1241 }
1242 virtual uint size_of() const { return sizeof(*this); }
1243 virtual int Opcode() const;
1244
1245 // Dig the length operand out of a array allocation site.
1246 Node* Ideal_length() {
1247 return in(AllocateNode::ALength);
1248 }
1249
1250 // Dig the length operand out of a array allocation site and narrow the
1251 // type with a CastII, if necesssary
1252 Node* make_ideal_length(const TypeOopPtr* ary_type, PhaseValues* phase, bool can_create = true);
1253
1254 // Pattern-match a possible usage of AllocateArrayNode.
1255 // Return null if no allocation is recognized.
1256 static AllocateArrayNode* Ideal_array_allocation(Node* ptr) {
1257 AllocateNode* allo = Ideal_allocation(ptr);
1258 return (allo == nullptr || !allo->is_AllocateArray())
1259 ? nullptr : allo->as_AllocateArray();
1260 }
1261 };
1262
|