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) {
915 return is_boxing_method() || CallNode::needs_deep_clone_jvms(C);
916 }
917
918 virtual int Opcode() const;
919 virtual Node* Ideal(PhaseGVN* phase, bool can_reshape);
920
921 void clear_safe_for_fold_compare() {
922 _safe_for_fold_compare = false;
923 }
924
925 bool safe_for_fold_compare() const {
926 return _safe_for_fold_compare;
927 }
928
929 #ifndef PRODUCT
930 virtual void dump_spec(outputStream *st) const;
931 virtual void dump_compact_spec(outputStream *st) const;
932 #endif
933 };
934
935 //------------------------------CallDynamicJavaNode----------------------------
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() || method->is_unboxing_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
946 bool is_unboxing_method() const {
947 return is_macro() && (method() != nullptr) && method()->is_unboxing_method();
948 }
949
950 // Late inlining modifies the JVMState, so we need to deep clone it
951 // when the call node is cloned (because it is macro node).
952 virtual bool needs_deep_clone_jvms(Compile* C) {
953 return is_boxing_method() || is_unboxing_method() || CallNode::needs_deep_clone_jvms(C);
954 }
955
956 virtual int Opcode() const;
957 virtual Node* Ideal(PhaseGVN* phase, bool can_reshape);
958
959 void clear_safe_for_fold_compare() {
960 _safe_for_fold_compare = false;
961 }
962
963 bool safe_for_fold_compare() const {
964 return _safe_for_fold_compare;
965 }
966
967 #ifndef PRODUCT
968 virtual void dump_spec(outputStream *st) const;
969 virtual void dump_compact_spec(outputStream *st) const;
970 #endif
971 };
972
973 //------------------------------CallDynamicJavaNode----------------------------
1059 init_class_id(Class_CallLeafPure);
1060 }
1061 int Opcode() const override;
1062 Node* Ideal(PhaseGVN* phase, bool can_reshape) override;
1063
1064 CallLeafPureNode* inline_call_leaf_pure_node(Node* control = nullptr) const;
1065 };
1066
1067 //------------------------------CallLeafNoFPNode-------------------------------
1068 // CallLeafNode, not using floating point or using it in the same manner as
1069 // the generated code
1070 class CallLeafNoFPNode : public CallLeafNode {
1071 public:
1072 CallLeafNoFPNode(const TypeFunc* tf, address addr, const char* name,
1073 const TypePtr* adr_type)
1074 : CallLeafNode(tf, addr, name, adr_type)
1075 {
1076 init_class_id(Class_CallLeafNoFP);
1077 }
1078 virtual int Opcode() const;
1079 virtual uint match_edge(uint idx) const;
1080 };
1081
1082 //------------------------------CallLeafVectorNode-------------------------------
1083 // CallLeafNode but calling with vector calling convention instead.
1084 class CallLeafVectorNode : public CallLeafNode {
1085 private:
1086 uint _num_bits;
1087 protected:
1088 virtual bool cmp( const Node &n ) const;
1089 virtual uint size_of() const; // Size is bigger
1090 public:
1091 CallLeafVectorNode(const TypeFunc* tf, address addr, const char* name,
1092 const TypePtr* adr_type, uint num_bits)
1093 : CallLeafNode(tf, addr, name, adr_type), _num_bits(num_bits)
1094 {
1095 }
1096 virtual int Opcode() const;
1097 virtual void calling_convention( BasicType* sig_bt, VMRegPair *parm_regs, uint argcnt ) const;
1098 };
1099
1102 // High-level memory allocation
1103 //
1104 // AllocateNode and AllocateArrayNode are subclasses of CallNode because they will
1105 // get expanded into a code sequence containing a call. Unlike other CallNodes,
1106 // they have 2 memory projections and 2 i_o projections (which are distinguished by
1107 // the _is_io_use flag in the projection.) This is needed when expanding the node in
1108 // order to differentiate the uses of the projection on the normal control path from
1109 // those on the exception return path.
1110 //
1111 class AllocateNode : public CallNode {
1112 public:
1113 enum {
1114 // Output:
1115 RawAddress = TypeFunc::Parms, // the newly-allocated raw address
1116 // Inputs:
1117 AllocSize = TypeFunc::Parms, // size (in bytes) of the new object
1118 KlassNode, // type (maybe dynamic) of the obj.
1119 InitialTest, // slow-path test (may be constant)
1120 ALength, // array length (or TOP if none)
1121 ValidLengthTest,
1122 InlineType, // InlineTypeNode if this is an inline type allocation
1123 InitValue, // Init value for null-free inline type arrays
1124 RawInitValue, // Same as above but as raw machine word
1125 ParmLimit
1126 };
1127
1128 static const TypeFunc* alloc_type(const Type* t) {
1129 const Type** fields = TypeTuple::fields(ParmLimit - TypeFunc::Parms);
1130 fields[AllocSize] = TypeInt::POS;
1131 fields[KlassNode] = TypeInstPtr::NOTNULL;
1132 fields[InitialTest] = TypeInt::BOOL;
1133 fields[ALength] = t; // length (can be a bad length)
1134 fields[ValidLengthTest] = TypeInt::BOOL;
1135 fields[InlineType] = Type::BOTTOM;
1136 fields[InitValue] = TypeInstPtr::NOTNULL;
1137 fields[RawInitValue] = TypeX_X;
1138
1139 const TypeTuple *domain = TypeTuple::make(ParmLimit, fields);
1140
1141 // create result type (range)
1142 fields = TypeTuple::fields(1);
1143 fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop
1144
1145 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
1146
1147 return TypeFunc::make(domain, range);
1148 }
1149
1150 // Result of Escape Analysis
1151 bool _is_scalar_replaceable;
1152 bool _is_non_escaping;
1153 // True when MemBar for new is redundant with MemBar at initialzer exit
1154 bool _is_allocation_MemBar_redundant;
1155
1156 virtual uint size_of() const; // Size is bigger
1157 AllocateNode(Compile* C, const TypeFunc *atype, Node *ctrl, Node *mem, Node *abio,
1158 Node *size, Node *klass_node, Node *initial_test,
1159 InlineTypeNode* inline_type_node = nullptr);
1160 // Expansion modifies the JVMState, so we need to deep clone it
1161 virtual bool needs_deep_clone_jvms(Compile* C) { return true; }
1162 virtual int Opcode() const;
1163 virtual uint ideal_reg() const { return Op_RegP; }
1164 virtual bool guaranteed_safepoint() { return false; }
1165
1166 // allocations do not modify their arguments
1167 virtual bool may_modify(const TypeOopPtr* t_oop, PhaseValues* phase) const { return false; }
1168
1169 // Pattern-match a possible usage of AllocateNode.
1170 // Return null if no allocation is recognized.
1171 // The operand is the pointer produced by the (possible) allocation.
1172 // It must be a projection of the Allocate or its subsequent CastPP.
1173 // (Note: This function is defined in file graphKit.cpp, near
1174 // GraphKit::new_instance/new_array, whose output it recognizes.)
1175 // The 'ptr' may not have an offset unless the 'offset' argument is given.
1176 static AllocateNode* Ideal_allocation(Node* ptr);
1177
1178 // Fancy version which uses AddPNode::Ideal_base_and_offset to strip
1179 // an offset, which is reported back to the caller.
1216
1217 // If object doesn't escape in <.init> method and there is memory barrier
1218 // inserted at exit of its <.init>, memory barrier for new is not necessary.
1219 // Inovke this method when MemBar at exit of initializer and post-dominate
1220 // allocation node.
1221 void compute_MemBar_redundancy(ciMethod* initializer);
1222 bool is_allocation_MemBar_redundant() { return _is_allocation_MemBar_redundant; }
1223
1224 Node* make_ideal_mark(PhaseGVN* phase, Node* control, Node* mem);
1225
1226 NOT_PRODUCT(virtual void dump_spec(outputStream* st) const;)
1227 };
1228
1229 //------------------------------AllocateArray---------------------------------
1230 //
1231 // High-level array allocation
1232 //
1233 class AllocateArrayNode : public AllocateNode {
1234 public:
1235 AllocateArrayNode(Compile* C, const TypeFunc* atype, Node* ctrl, Node* mem, Node* abio, Node* size, Node* klass_node,
1236 Node* initial_test, Node* count_val, Node* valid_length_test,
1237 Node* init_value, Node* raw_init_value)
1238 : AllocateNode(C, atype, ctrl, mem, abio, size, klass_node,
1239 initial_test)
1240 {
1241 init_class_id(Class_AllocateArray);
1242 set_req(AllocateNode::ALength, count_val);
1243 set_req(AllocateNode::ValidLengthTest, valid_length_test);
1244 init_req(AllocateNode::InitValue, init_value);
1245 init_req(AllocateNode::RawInitValue, raw_init_value);
1246 }
1247 virtual uint size_of() const { return sizeof(*this); }
1248 virtual int Opcode() const;
1249
1250 // Dig the length operand out of a array allocation site.
1251 Node* Ideal_length() {
1252 return in(AllocateNode::ALength);
1253 }
1254
1255 // Dig the length operand out of a array allocation site and narrow the
1256 // type with a CastII, if necesssary
1257 Node* make_ideal_length(const TypeOopPtr* ary_type, PhaseValues* phase, bool can_create = true);
1258
1259 // Pattern-match a possible usage of AllocateArrayNode.
1260 // Return null if no allocation is recognized.
1261 static AllocateArrayNode* Ideal_array_allocation(Node* ptr) {
1262 AllocateNode* allo = Ideal_allocation(ptr);
1263 return (allo == nullptr || !allo->is_AllocateArray())
1264 ? nullptr : allo->as_AllocateArray();
1265 }
1266 };
1267
|