< prev index next >

src/hotspot/share/opto/callnode.hpp

Print this page

  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 

 647     assert(jvms != nullptr, "JVMS reference is null.");
 648     return jvms->scloff() + _merge_pointer_idx + 1;
 649   }
 650 
 651   // Assumes that "this" is an argument to a safepoint node "s", and that
 652   // "new_call" is being created to correspond to "s".  But the difference
 653   // between the start index of the jvmstates of "new_call" and "s" is
 654   // "jvms_adj".  Produce and return a SafePointScalarObjectNode that
 655   // corresponds appropriately to "this" in "new_call".  Assumes that
 656   // "sosn_map" is a map, specific to the translation of "s" to "new_call",
 657   // mapping old SafePointScalarObjectNodes to new, to avoid multiple copies.
 658   SafePointScalarMergeNode* clone(Dict* sosn_map, bool& new_node) const;
 659 
 660 #ifndef PRODUCT
 661   virtual void              dump_spec(outputStream *st) const;
 662 #endif
 663 };
 664 
 665 // Simple container for the outgoing projections of a call.  Useful
 666 // for serious surgery on calls.
 667 class CallProjections : public StackObj {
 668 public:
 669   Node* fallthrough_proj;
 670   Node* fallthrough_catchproj;
 671   Node* fallthrough_memproj;
 672   Node* fallthrough_ioproj;
 673   Node* catchall_catchproj;
 674   Node* catchall_memproj;
 675   Node* catchall_ioproj;
 676   Node* resproj;
 677   Node* exobj;



















 678 };
 679 
 680 class CallGenerator;
 681 
 682 //------------------------------CallNode---------------------------------------
 683 // Call nodes now subsume the function of debug nodes at callsites, so they
 684 // contain the functionality of a full scope chain of debug nodes.
 685 class CallNode : public SafePointNode {
 686 
 687 protected:
 688   bool may_modify_arraycopy_helper(const TypeOopPtr* dest_t, const TypeOopPtr* t_oop, PhaseValues* phase);
 689 
 690 public:
 691   const TypeFunc* _tf;          // Function type
 692   address         _entry_point; // Address of method being called
 693   float           _cnt;         // Estimate of number of times called
 694   CallGenerator*  _generator;   // corresponding CallGenerator for some late inline calls
 695   const char*     _name;        // Printable name, if _method is null
 696 
 697   CallNode(const TypeFunc* tf, address addr, const TypePtr* adr_type, JVMState* jvms = nullptr)
 698     : SafePointNode(tf->domain()->cnt(), jvms, adr_type),
 699       _tf(tf),
 700       _entry_point(addr),
 701       _cnt(COUNT_UNKNOWN),
 702       _generator(nullptr),
 703       _name(nullptr)
 704   {
 705     init_class_id(Class_Call);
 706   }
 707 
 708   const TypeFunc* tf()         const { return _tf; }
 709   address  entry_point()       const { return _entry_point; }
 710   float    cnt()               const { return _cnt; }
 711   CallGenerator* generator()   const { return _generator; }
 712 
 713   void set_tf(const TypeFunc* tf)       { _tf = tf; }
 714   void set_entry_point(address p)       { _entry_point = p; }
 715   void set_cnt(float c)                 { _cnt = c; }
 716   void set_generator(CallGenerator* cg) { _generator = cg; }
 717 
 718   virtual const Type* bottom_type() const;
 719   virtual const Type* Value(PhaseGVN* phase) const;
 720   virtual Node* Ideal(PhaseGVN* phase, bool can_reshape);
 721   virtual Node* Identity(PhaseGVN* phase) { return this; }
 722   virtual bool        cmp(const Node &n) const;
 723   virtual uint        size_of() const = 0;
 724   virtual void        calling_convention(BasicType* sig_bt, VMRegPair* parm_regs, uint argcnt) const;
 725   virtual Node*       match(const ProjNode* proj, const Matcher* m);
 726   virtual uint        ideal_reg() const { return NotAMachineReg; }
 727   // Are we guaranteed that this node is a safepoint?  Not true for leaf calls and
 728   // for some macro nodes whose expansion does not have a safepoint on the fast path.
 729   virtual bool        guaranteed_safepoint()  { return true; }
 730   // For macro nodes, the JVMState gets modified during expansion. If calls
 731   // use MachConstantBase, it gets modified during matching. If the call is
 732   // late inlined, it also needs the full JVMState. So when cloning the
 733   // node the JVMState must be deep cloned. Default is to shallow clone.
 734   virtual bool needs_deep_clone_jvms(Compile* C) { return _generator != nullptr || C->needs_deep_clone_jvms(); }
 735 
 736   // Returns true if the call may modify n
 737   virtual bool        may_modify(const TypeOopPtr* t_oop, PhaseValues* phase);
 738   // Does this node have a use of n other than in debug information?
 739   bool                has_non_debug_use(Node* n);

 740   // Returns the unique CheckCastPP of a call
 741   // or result projection is there are several CheckCastPP
 742   // or returns null if there is no one.
 743   Node* result_cast();
 744   // Does this node returns pointer?
 745   bool returns_pointer() const {
 746     const TypeTuple* r = tf()->range();
 747     return (r->cnt() > TypeFunc::Parms &&

 748             r->field_at(TypeFunc::Parms)->isa_ptr());
 749   }
 750 
 751   // Collect all the interesting edges from a call for use in
 752   // replacing the call by something else.  Used by macro expansion
 753   // and the late inlining support.
 754   void extract_projections(CallProjections* projs, bool separate_io_proj, bool do_asserts = true) const;
 755 
 756   virtual uint match_edge(uint idx) const;
 757 
 758   bool is_call_to_arraycopystub() const;
 759   bool is_call_to_multianewarray_stub() const;
 760 
 761   virtual void copy_call_debug_info(PhaseIterGVN* phase, SafePointNode* sfpt) {}
 762 
 763 #ifndef PRODUCT
 764   virtual void        dump_req(outputStream* st = tty, DumpConfig* dc = nullptr) const;
 765   virtual void        dump_spec(outputStream* st) const;
 766 #endif
 767 };
 768 
 769 
 770 //------------------------------CallJavaNode-----------------------------------
 771 // Make a static or dynamic subroutine call node using Java calling
 772 // convention.  (The "Java" calling convention is the compiler's calling
 773 // convention, as opposed to the interpreter's or that of native C.)
 774 class CallJavaNode : public CallNode {

 801   void  set_arg_escape(bool f)             { _arg_escape = f; }
 802   bool  arg_escape() const                 { return _arg_escape; }
 803   void copy_call_debug_info(PhaseIterGVN* phase, SafePointNode *sfpt);
 804   void register_for_late_inline();
 805 
 806   DEBUG_ONLY( bool validate_symbolic_info() const; )
 807 
 808 #ifndef PRODUCT
 809   virtual void  dump_spec(outputStream *st) const;
 810   virtual void  dump_compact_spec(outputStream *st) const;
 811 #endif
 812 };
 813 
 814 //------------------------------CallStaticJavaNode-----------------------------
 815 // Make a direct subroutine call using Java calling convention (for static
 816 // calls and optimized virtual calls, plus calls to wrappers for run-time
 817 // routines); generates static stub.
 818 class CallStaticJavaNode : public CallJavaNode {
 819   virtual bool cmp( const Node &n ) const;
 820   virtual uint size_of() const; // Size is bigger



 821 public:
 822   CallStaticJavaNode(Compile* C, const TypeFunc* tf, address addr, ciMethod* method)
 823     : CallJavaNode(tf, addr, method) {
 824     init_class_id(Class_CallStaticJava);
 825     if (C->eliminate_boxing() && (method != nullptr) && method->is_boxing_method()) {
 826       init_flags(Flag_is_macro);
 827       C->add_macro_node(this);
 828     }











 829   }
 830   CallStaticJavaNode(const TypeFunc* tf, address addr, const char* name, const TypePtr* adr_type)
 831     : CallJavaNode(tf, addr, nullptr) {
 832     init_class_id(Class_CallStaticJava);
 833     // This node calls a runtime stub, which often has narrow memory effects.
 834     _adr_type = adr_type;
 835     _name = name;
 836   }
 837 
 838   // If this is an uncommon trap, return the request code, else zero.
 839   int uncommon_trap_request() const;
 840   bool is_uncommon_trap() const;
 841   static int extract_uncommon_trap_request(const Node* call);
 842 
 843   bool is_boxing_method() const {
 844     return is_macro() && (method() != nullptr) && method()->is_boxing_method();
 845   }
 846   // Late inlining modifies the JVMState, so we need to deep clone it
 847   // when the call node is cloned (because it is macro node).
 848   virtual bool needs_deep_clone_jvms(Compile* C) {

 945   CallLeafPureNode(const TypeFunc* tf, address addr, const char* name)
 946       : CallLeafNode(tf, addr, name, nullptr) {
 947     init_class_id(Class_CallLeafPure);
 948   }
 949   int Opcode() const override;
 950   Node* Ideal(PhaseGVN* phase, bool can_reshape) override;
 951 };
 952 
 953 //------------------------------CallLeafNoFPNode-------------------------------
 954 // CallLeafNode, not using floating point or using it in the same manner as
 955 // the generated code
 956 class CallLeafNoFPNode : public CallLeafNode {
 957 public:
 958   CallLeafNoFPNode(const TypeFunc* tf, address addr, const char* name,
 959                    const TypePtr* adr_type)
 960     : CallLeafNode(tf, addr, name, adr_type)
 961   {
 962     init_class_id(Class_CallLeafNoFP);
 963   }
 964   virtual int   Opcode() const;

 965 };
 966 
 967 //------------------------------CallLeafVectorNode-------------------------------
 968 // CallLeafNode but calling with vector calling convention instead.
 969 class CallLeafVectorNode : public CallLeafNode {
 970 private:
 971   uint _num_bits;
 972 protected:
 973   virtual bool cmp( const Node &n ) const;
 974   virtual uint size_of() const; // Size is bigger
 975 public:
 976   CallLeafVectorNode(const TypeFunc* tf, address addr, const char* name,
 977                    const TypePtr* adr_type, uint num_bits)
 978     : CallLeafNode(tf, addr, name, adr_type), _num_bits(num_bits)
 979   {
 980   }
 981   virtual int   Opcode() const;
 982   virtual void  calling_convention( BasicType* sig_bt, VMRegPair *parm_regs, uint argcnt ) const;
 983 };
 984 

 987 // High-level memory allocation
 988 //
 989 //  AllocateNode and AllocateArrayNode are subclasses of CallNode because they will
 990 //  get expanded into a code sequence containing a call.  Unlike other CallNodes,
 991 //  they have 2 memory projections and 2 i_o projections (which are distinguished by
 992 //  the _is_io_use flag in the projection.)  This is needed when expanding the node in
 993 //  order to differentiate the uses of the projection on the normal control path from
 994 //  those on the exception return path.
 995 //
 996 class AllocateNode : public CallNode {
 997 public:
 998   enum {
 999     // Output:
1000     RawAddress  = TypeFunc::Parms,    // the newly-allocated raw address
1001     // Inputs:
1002     AllocSize   = TypeFunc::Parms,    // size (in bytes) of the new object
1003     KlassNode,                        // type (maybe dynamic) of the obj.
1004     InitialTest,                      // slow-path test (may be constant)
1005     ALength,                          // array length (or TOP if none)
1006     ValidLengthTest,



1007     ParmLimit
1008   };
1009 
1010   static const TypeFunc* alloc_type(const Type* t) {
1011     const Type** fields = TypeTuple::fields(ParmLimit - TypeFunc::Parms);
1012     fields[AllocSize]   = TypeInt::POS;
1013     fields[KlassNode]   = TypeInstPtr::NOTNULL;
1014     fields[InitialTest] = TypeInt::BOOL;
1015     fields[ALength]     = t;  // length (can be a bad length)
1016     fields[ValidLengthTest] = TypeInt::BOOL;



1017 
1018     const TypeTuple *domain = TypeTuple::make(ParmLimit, fields);
1019 
1020     // create result type (range)
1021     fields = TypeTuple::fields(1);
1022     fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop
1023 
1024     const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
1025 
1026     return TypeFunc::make(domain, range);
1027   }
1028 
1029   // Result of Escape Analysis
1030   bool _is_scalar_replaceable;
1031   bool _is_non_escaping;
1032   // True when MemBar for new is redundant with MemBar at initialzer exit
1033   bool _is_allocation_MemBar_redundant;

1034 
1035   virtual uint size_of() const; // Size is bigger
1036   AllocateNode(Compile* C, const TypeFunc *atype, Node *ctrl, Node *mem, Node *abio,
1037                Node *size, Node *klass_node, Node *initial_test);

1038   // Expansion modifies the JVMState, so we need to deep clone it
1039   virtual bool needs_deep_clone_jvms(Compile* C) { return true; }
1040   virtual int Opcode() const;
1041   virtual uint ideal_reg() const { return Op_RegP; }
1042   virtual bool        guaranteed_safepoint()  { return false; }
1043 
1044   // allocations do not modify their arguments
1045   virtual bool        may_modify(const TypeOopPtr* t_oop, PhaseValues* phase) { return false;}
1046 
1047   // Pattern-match a possible usage of AllocateNode.
1048   // Return null if no allocation is recognized.
1049   // The operand is the pointer produced by the (possible) allocation.
1050   // It must be a projection of the Allocate or its subsequent CastPP.
1051   // (Note:  This function is defined in file graphKit.cpp, near
1052   // GraphKit::new_instance/new_array, whose output it recognizes.)
1053   // The 'ptr' may not have an offset unless the 'offset' argument is given.
1054   static AllocateNode* Ideal_allocation(Node* ptr);
1055 
1056   // Fancy version which uses AddPNode::Ideal_base_and_offset to strip
1057   // an offset, which is reported back to the caller.

1094 
1095   // If object doesn't escape in <.init> method and there is memory barrier
1096   // inserted at exit of its <.init>, memory barrier for new is not necessary.
1097   // Inovke this method when MemBar at exit of initializer and post-dominate
1098   // allocation node.
1099   void compute_MemBar_redundancy(ciMethod* initializer);
1100   bool is_allocation_MemBar_redundant() { return _is_allocation_MemBar_redundant; }
1101 
1102   Node* make_ideal_mark(PhaseGVN* phase, Node* control, Node* mem);
1103 
1104   NOT_PRODUCT(virtual void dump_spec(outputStream* st) const;)
1105 };
1106 
1107 //------------------------------AllocateArray---------------------------------
1108 //
1109 // High-level array allocation
1110 //
1111 class AllocateArrayNode : public AllocateNode {
1112 public:
1113   AllocateArrayNode(Compile* C, const TypeFunc* atype, Node* ctrl, Node* mem, Node* abio, Node* size, Node* klass_node,
1114                     Node* initial_test, Node* count_val, Node* valid_length_test)

1115     : AllocateNode(C, atype, ctrl, mem, abio, size, klass_node,
1116                    initial_test)
1117   {
1118     init_class_id(Class_AllocateArray);
1119     set_req(AllocateNode::ALength,        count_val);
1120     set_req(AllocateNode::ValidLengthTest, valid_length_test);


1121   }

1122   virtual int Opcode() const;
1123 
1124   // Dig the length operand out of a array allocation site.
1125   Node* Ideal_length() {
1126     return in(AllocateNode::ALength);
1127   }
1128 
1129   // Dig the length operand out of a array allocation site and narrow the
1130   // type with a CastII, if necesssary
1131   Node* make_ideal_length(const TypeOopPtr* ary_type, PhaseValues* phase, bool can_create = true);
1132 
1133   // Pattern-match a possible usage of AllocateArrayNode.
1134   // Return null if no allocation is recognized.
1135   static AllocateArrayNode* Ideal_array_allocation(Node* ptr) {
1136     AllocateNode* allo = Ideal_allocation(ptr);
1137     return (allo == nullptr || !allo->is_AllocateArray())
1138            ? nullptr : allo->as_AllocateArray();
1139   }
1140 };
1141 

  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 

 646     assert(jvms != nullptr, "JVMS reference is null.");
 647     return jvms->scloff() + _merge_pointer_idx + 1;
 648   }
 649 
 650   // Assumes that "this" is an argument to a safepoint node "s", and that
 651   // "new_call" is being created to correspond to "s".  But the difference
 652   // between the start index of the jvmstates of "new_call" and "s" is
 653   // "jvms_adj".  Produce and return a SafePointScalarObjectNode that
 654   // corresponds appropriately to "this" in "new_call".  Assumes that
 655   // "sosn_map" is a map, specific to the translation of "s" to "new_call",
 656   // mapping old SafePointScalarObjectNodes to new, to avoid multiple copies.
 657   SafePointScalarMergeNode* clone(Dict* sosn_map, bool& new_node) const;
 658 
 659 #ifndef PRODUCT
 660   virtual void              dump_spec(outputStream *st) const;
 661 #endif
 662 };
 663 
 664 // Simple container for the outgoing projections of a call.  Useful
 665 // for serious surgery on calls.
 666 class CallProjections {
 667 public:
 668   Node* fallthrough_proj;
 669   Node* fallthrough_catchproj;
 670   Node* fallthrough_memproj;
 671   Node* fallthrough_ioproj;
 672   Node* catchall_catchproj;
 673   Node* catchall_memproj;
 674   Node* catchall_ioproj;

 675   Node* exobj;
 676   uint nb_resproj;
 677   Node* resproj[1]; // at least one projection
 678 
 679   CallProjections(uint nbres) {
 680     fallthrough_proj      = nullptr;
 681     fallthrough_catchproj = nullptr;
 682     fallthrough_memproj   = nullptr;
 683     fallthrough_ioproj    = nullptr;
 684     catchall_catchproj    = nullptr;
 685     catchall_memproj      = nullptr;
 686     catchall_ioproj       = nullptr;
 687     exobj                 = nullptr;
 688     nb_resproj            = nbres;
 689     resproj[0]            = nullptr;
 690     for (uint i = 1; i < nb_resproj; i++) {
 691       resproj[i]          = nullptr;
 692     }
 693   }
 694 
 695 };
 696 
 697 class CallGenerator;
 698 
 699 //------------------------------CallNode---------------------------------------
 700 // Call nodes now subsume the function of debug nodes at callsites, so they
 701 // contain the functionality of a full scope chain of debug nodes.
 702 class CallNode : public SafePointNode {
 703 
 704 protected:
 705   bool may_modify_arraycopy_helper(const TypeOopPtr* dest_t, const TypeOopPtr* t_oop, PhaseValues* phase);
 706 
 707 public:
 708   const TypeFunc* _tf;          // Function type
 709   address         _entry_point; // Address of method being called
 710   float           _cnt;         // Estimate of number of times called
 711   CallGenerator*  _generator;   // corresponding CallGenerator for some late inline calls
 712   const char*     _name;        // Printable name, if _method is null
 713 
 714   CallNode(const TypeFunc* tf, address addr, const TypePtr* adr_type, JVMState* jvms = nullptr)
 715     : SafePointNode(tf->domain_cc()->cnt(), jvms, adr_type),
 716       _tf(tf),
 717       _entry_point(addr),
 718       _cnt(COUNT_UNKNOWN),
 719       _generator(nullptr),
 720       _name(nullptr)
 721   {
 722     init_class_id(Class_Call);
 723   }
 724 
 725   const TypeFunc* tf()         const { return _tf; }
 726   address  entry_point()       const { return _entry_point; }
 727   float    cnt()               const { return _cnt; }
 728   CallGenerator* generator()   const { return _generator; }
 729 
 730   void set_tf(const TypeFunc* tf)       { _tf = tf; }
 731   void set_entry_point(address p)       { _entry_point = p; }
 732   void set_cnt(float c)                 { _cnt = c; }
 733   void set_generator(CallGenerator* cg) { _generator = cg; }
 734 
 735   virtual const Type* bottom_type() const;
 736   virtual const Type* Value(PhaseGVN* phase) const;
 737   virtual Node* Ideal(PhaseGVN* phase, bool can_reshape);
 738   virtual Node* Identity(PhaseGVN* phase) { return this; }
 739   virtual bool        cmp(const Node &n) const;
 740   virtual uint        size_of() const = 0;
 741   virtual void        calling_convention(BasicType* sig_bt, VMRegPair* parm_regs, uint argcnt) const;
 742   virtual Node*       match(const ProjNode* proj, const Matcher* m, const RegMask* mask);
 743   virtual uint        ideal_reg() const { return NotAMachineReg; }
 744   // Are we guaranteed that this node is a safepoint?  Not true for leaf calls and
 745   // for some macro nodes whose expansion does not have a safepoint on the fast path.
 746   virtual bool        guaranteed_safepoint()  { return true; }
 747   // For macro nodes, the JVMState gets modified during expansion. If calls
 748   // use MachConstantBase, it gets modified during matching. If the call is
 749   // late inlined, it also needs the full JVMState. So when cloning the
 750   // node the JVMState must be deep cloned. Default is to shallow clone.
 751   virtual bool needs_deep_clone_jvms(Compile* C) { return _generator != nullptr || C->needs_deep_clone_jvms(); }
 752 
 753   // Returns true if the call may modify n
 754   virtual bool        may_modify(const TypeOopPtr* t_oop, PhaseValues* phase);
 755   // Does this node have a use of n other than in debug information?
 756   bool                has_non_debug_use(Node* n);
 757   bool                has_debug_use(Node* n);
 758   // Returns the unique CheckCastPP of a call
 759   // or result projection is there are several CheckCastPP
 760   // or returns null if there is no one.
 761   Node* result_cast();
 762   // Does this node returns pointer?
 763   bool returns_pointer() const {
 764     const TypeTuple* r = tf()->range_sig();
 765     return (!tf()->returns_inline_type_as_fields() &&
 766             r->cnt() > TypeFunc::Parms &&
 767             r->field_at(TypeFunc::Parms)->isa_ptr());
 768   }
 769 
 770   // Collect all the interesting edges from a call for use in
 771   // replacing the call by something else.  Used by macro expansion
 772   // and the late inlining support.
 773   CallProjections* extract_projections(bool separate_io_proj, bool do_asserts = true) const;
 774 
 775   virtual uint match_edge(uint idx) const;
 776 
 777   bool is_call_to_arraycopystub() const;
 778   bool is_call_to_multianewarray_stub() const;
 779 
 780   virtual void copy_call_debug_info(PhaseIterGVN* phase, SafePointNode* sfpt) {}
 781 
 782 #ifndef PRODUCT
 783   virtual void        dump_req(outputStream* st = tty, DumpConfig* dc = nullptr) const;
 784   virtual void        dump_spec(outputStream* st) const;
 785 #endif
 786 };
 787 
 788 
 789 //------------------------------CallJavaNode-----------------------------------
 790 // Make a static or dynamic subroutine call node using Java calling
 791 // convention.  (The "Java" calling convention is the compiler's calling
 792 // convention, as opposed to the interpreter's or that of native C.)
 793 class CallJavaNode : public CallNode {

 820   void  set_arg_escape(bool f)             { _arg_escape = f; }
 821   bool  arg_escape() const                 { return _arg_escape; }
 822   void copy_call_debug_info(PhaseIterGVN* phase, SafePointNode *sfpt);
 823   void register_for_late_inline();
 824 
 825   DEBUG_ONLY( bool validate_symbolic_info() const; )
 826 
 827 #ifndef PRODUCT
 828   virtual void  dump_spec(outputStream *st) const;
 829   virtual void  dump_compact_spec(outputStream *st) const;
 830 #endif
 831 };
 832 
 833 //------------------------------CallStaticJavaNode-----------------------------
 834 // Make a direct subroutine call using Java calling convention (for static
 835 // calls and optimized virtual calls, plus calls to wrappers for run-time
 836 // routines); generates static stub.
 837 class CallStaticJavaNode : public CallJavaNode {
 838   virtual bool cmp( const Node &n ) const;
 839   virtual uint size_of() const; // Size is bigger
 840 
 841   bool remove_unknown_flat_array_load(PhaseIterGVN* igvn, Node* ctl, Node* mem, Node* unc_arg);
 842 
 843 public:
 844   CallStaticJavaNode(Compile* C, const TypeFunc* tf, address addr, ciMethod* method)
 845     : CallJavaNode(tf, addr, method) {
 846     init_class_id(Class_CallStaticJava);
 847     if (C->eliminate_boxing() && (method != nullptr) && method->is_boxing_method()) {
 848       init_flags(Flag_is_macro);
 849       C->add_macro_node(this);
 850     }
 851     const TypeTuple *r = tf->range_sig();
 852     if (InlineTypeReturnedAsFields &&
 853         method != nullptr &&
 854         method->is_method_handle_intrinsic() &&
 855         r->cnt() > TypeFunc::Parms &&
 856         r->field_at(TypeFunc::Parms)->isa_oopptr() &&
 857         r->field_at(TypeFunc::Parms)->is_oopptr()->can_be_inline_type()) {
 858       // Make sure this call is processed by PhaseMacroExpand::expand_mh_intrinsic_return
 859       init_flags(Flag_is_macro);
 860       C->add_macro_node(this);
 861     }
 862   }
 863   CallStaticJavaNode(const TypeFunc* tf, address addr, const char* name, const TypePtr* adr_type)
 864     : CallJavaNode(tf, addr, nullptr) {
 865     init_class_id(Class_CallStaticJava);
 866     // This node calls a runtime stub, which often has narrow memory effects.
 867     _adr_type = adr_type;
 868     _name = name;
 869   }
 870 
 871   // If this is an uncommon trap, return the request code, else zero.
 872   int uncommon_trap_request() const;
 873   bool is_uncommon_trap() const;
 874   static int extract_uncommon_trap_request(const Node* call);
 875 
 876   bool is_boxing_method() const {
 877     return is_macro() && (method() != nullptr) && method()->is_boxing_method();
 878   }
 879   // Late inlining modifies the JVMState, so we need to deep clone it
 880   // when the call node is cloned (because it is macro node).
 881   virtual bool needs_deep_clone_jvms(Compile* C) {

 978   CallLeafPureNode(const TypeFunc* tf, address addr, const char* name)
 979       : CallLeafNode(tf, addr, name, nullptr) {
 980     init_class_id(Class_CallLeafPure);
 981   }
 982   int Opcode() const override;
 983   Node* Ideal(PhaseGVN* phase, bool can_reshape) override;
 984 };
 985 
 986 //------------------------------CallLeafNoFPNode-------------------------------
 987 // CallLeafNode, not using floating point or using it in the same manner as
 988 // the generated code
 989 class CallLeafNoFPNode : public CallLeafNode {
 990 public:
 991   CallLeafNoFPNode(const TypeFunc* tf, address addr, const char* name,
 992                    const TypePtr* adr_type)
 993     : CallLeafNode(tf, addr, name, adr_type)
 994   {
 995     init_class_id(Class_CallLeafNoFP);
 996   }
 997   virtual int   Opcode() const;
 998   virtual uint match_edge(uint idx) const;
 999 };
1000 
1001 //------------------------------CallLeafVectorNode-------------------------------
1002 // CallLeafNode but calling with vector calling convention instead.
1003 class CallLeafVectorNode : public CallLeafNode {
1004 private:
1005   uint _num_bits;
1006 protected:
1007   virtual bool cmp( const Node &n ) const;
1008   virtual uint size_of() const; // Size is bigger
1009 public:
1010   CallLeafVectorNode(const TypeFunc* tf, address addr, const char* name,
1011                    const TypePtr* adr_type, uint num_bits)
1012     : CallLeafNode(tf, addr, name, adr_type), _num_bits(num_bits)
1013   {
1014   }
1015   virtual int   Opcode() const;
1016   virtual void  calling_convention( BasicType* sig_bt, VMRegPair *parm_regs, uint argcnt ) const;
1017 };
1018 

1021 // High-level memory allocation
1022 //
1023 //  AllocateNode and AllocateArrayNode are subclasses of CallNode because they will
1024 //  get expanded into a code sequence containing a call.  Unlike other CallNodes,
1025 //  they have 2 memory projections and 2 i_o projections (which are distinguished by
1026 //  the _is_io_use flag in the projection.)  This is needed when expanding the node in
1027 //  order to differentiate the uses of the projection on the normal control path from
1028 //  those on the exception return path.
1029 //
1030 class AllocateNode : public CallNode {
1031 public:
1032   enum {
1033     // Output:
1034     RawAddress  = TypeFunc::Parms,    // the newly-allocated raw address
1035     // Inputs:
1036     AllocSize   = TypeFunc::Parms,    // size (in bytes) of the new object
1037     KlassNode,                        // type (maybe dynamic) of the obj.
1038     InitialTest,                      // slow-path test (may be constant)
1039     ALength,                          // array length (or TOP if none)
1040     ValidLengthTest,
1041     InlineType,                       // InlineTypeNode if this is an inline type allocation
1042     InitValue,                        // Init value for null-free inline type arrays
1043     RawInitValue,                     // Same as above but as raw machine word
1044     ParmLimit
1045   };
1046 
1047   static const TypeFunc* alloc_type(const Type* t) {
1048     const Type** fields = TypeTuple::fields(ParmLimit - TypeFunc::Parms);
1049     fields[AllocSize]   = TypeInt::POS;
1050     fields[KlassNode]   = TypeInstPtr::NOTNULL;
1051     fields[InitialTest] = TypeInt::BOOL;
1052     fields[ALength]     = t;  // length (can be a bad length)
1053     fields[ValidLengthTest] = TypeInt::BOOL;
1054     fields[InlineType] = Type::BOTTOM;
1055     fields[InitValue] = TypeInstPtr::NOTNULL;
1056     fields[RawInitValue] = TypeX_X;
1057 
1058     const TypeTuple *domain = TypeTuple::make(ParmLimit, fields);
1059 
1060     // create result type (range)
1061     fields = TypeTuple::fields(1);
1062     fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop
1063 
1064     const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
1065 
1066     return TypeFunc::make(domain, range);
1067   }
1068 
1069   // Result of Escape Analysis
1070   bool _is_scalar_replaceable;
1071   bool _is_non_escaping;
1072   // True when MemBar for new is redundant with MemBar at initialzer exit
1073   bool _is_allocation_MemBar_redundant;
1074   bool _larval;
1075 
1076   virtual uint size_of() const; // Size is bigger
1077   AllocateNode(Compile* C, const TypeFunc *atype, Node *ctrl, Node *mem, Node *abio,
1078                Node *size, Node *klass_node, Node *initial_test,
1079                InlineTypeNode* inline_type_node = nullptr);
1080   // Expansion modifies the JVMState, so we need to deep clone it
1081   virtual bool needs_deep_clone_jvms(Compile* C) { return true; }
1082   virtual int Opcode() const;
1083   virtual uint ideal_reg() const { return Op_RegP; }
1084   virtual bool        guaranteed_safepoint()  { return false; }
1085 
1086   // allocations do not modify their arguments
1087   virtual bool        may_modify(const TypeOopPtr* t_oop, PhaseValues* phase) { return false;}
1088 
1089   // Pattern-match a possible usage of AllocateNode.
1090   // Return null if no allocation is recognized.
1091   // The operand is the pointer produced by the (possible) allocation.
1092   // It must be a projection of the Allocate or its subsequent CastPP.
1093   // (Note:  This function is defined in file graphKit.cpp, near
1094   // GraphKit::new_instance/new_array, whose output it recognizes.)
1095   // The 'ptr' may not have an offset unless the 'offset' argument is given.
1096   static AllocateNode* Ideal_allocation(Node* ptr);
1097 
1098   // Fancy version which uses AddPNode::Ideal_base_and_offset to strip
1099   // an offset, which is reported back to the caller.

1136 
1137   // If object doesn't escape in <.init> method and there is memory barrier
1138   // inserted at exit of its <.init>, memory barrier for new is not necessary.
1139   // Inovke this method when MemBar at exit of initializer and post-dominate
1140   // allocation node.
1141   void compute_MemBar_redundancy(ciMethod* initializer);
1142   bool is_allocation_MemBar_redundant() { return _is_allocation_MemBar_redundant; }
1143 
1144   Node* make_ideal_mark(PhaseGVN* phase, Node* control, Node* mem);
1145 
1146   NOT_PRODUCT(virtual void dump_spec(outputStream* st) const;)
1147 };
1148 
1149 //------------------------------AllocateArray---------------------------------
1150 //
1151 // High-level array allocation
1152 //
1153 class AllocateArrayNode : public AllocateNode {
1154 public:
1155   AllocateArrayNode(Compile* C, const TypeFunc* atype, Node* ctrl, Node* mem, Node* abio, Node* size, Node* klass_node,
1156                     Node* initial_test, Node* count_val, Node* valid_length_test,
1157                     Node* init_value, Node* raw_init_value)
1158     : AllocateNode(C, atype, ctrl, mem, abio, size, klass_node,
1159                    initial_test)
1160   {
1161     init_class_id(Class_AllocateArray);
1162     set_req(AllocateNode::ALength, count_val);
1163     set_req(AllocateNode::ValidLengthTest, valid_length_test);
1164     init_req(AllocateNode::InitValue, init_value);
1165     init_req(AllocateNode::RawInitValue, raw_init_value);
1166   }
1167   virtual uint size_of() const { return sizeof(*this); }
1168   virtual int Opcode() const;
1169 
1170   // Dig the length operand out of a array allocation site.
1171   Node* Ideal_length() {
1172     return in(AllocateNode::ALength);
1173   }
1174 
1175   // Dig the length operand out of a array allocation site and narrow the
1176   // type with a CastII, if necesssary
1177   Node* make_ideal_length(const TypeOopPtr* ary_type, PhaseValues* phase, bool can_create = true);
1178 
1179   // Pattern-match a possible usage of AllocateArrayNode.
1180   // Return null if no allocation is recognized.
1181   static AllocateArrayNode* Ideal_array_allocation(Node* ptr) {
1182     AllocateNode* allo = Ideal_allocation(ptr);
1183     return (allo == nullptr || !allo->is_AllocateArray())
1184            ? nullptr : allo->as_AllocateArray();
1185   }
1186 };
1187 
< prev index next >