< prev index next >

src/hotspot/share/opto/valuetypenode.hpp

Print this page




  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_OPTO_VALUETYPENODE_HPP
  26 #define SHARE_VM_OPTO_VALUETYPENODE_HPP
  27 
  28 #include "opto/node.hpp"
  29 #include "opto/connode.hpp"
  30 
  31 class GraphKit;
  32 
  33 class ValueTypeBaseNode : public TypeNode {
  34 protected:
  35   ValueTypeBaseNode(const Type* t, int nb_fields, Compile* C)
  36     : TypeNode(t, nb_fields) {
  37     init_class_id(Class_ValueTypeBase);
  38     C->add_value_type(this);
  39   }
  40 
  41   enum { Control,   // Control input
  42          Oop,       // Oop of TypeValueTypePtr
  43          Values     // Nodes corresponding to values of the value type's fields.
  44                     // Nodes are connected in increasing order of the index of the field
  45                     // they correspond to. Field indeces are defined in ciValueKlass::_field_index_map.
  46   };
  47 
  48   virtual const TypeValueTypePtr* value_type_ptr() const = 0;
  49   // Get the klass defining the field layout of the value type
  50   virtual ciValueKlass* value_klass() const = 0;

  51   int make_scalar_in_safepoint(Unique_Node_List& worklist, SafePointNode* sfpt, Node* root, PhaseGVN* gvn);
  52 
  53   static void make(PhaseGVN* gvn, Node*& ctl, Node* mem, Node* n, ValueTypeBaseNode* vt, ciValueKlass* base_vk, int base_offset, int base_input, bool in);

  54 
  55 public:
  56   // Support for control flow merges
  57   bool has_phi_inputs(Node* region);
  58   ValueTypeBaseNode* clone_with_phis(PhaseGVN* gvn, Node* region);
  59   ValueTypeBaseNode* merge_with(PhaseGVN* gvn, const ValueTypeBaseNode* other, int pnum, bool transform);
  60 
  61   // Get oop for heap allocated value type (may be TypePtr::NULL_PTR)
  62   Node* get_oop() const    { return in(Oop); }
  63   void  set_oop(Node* oop) { set_req(Oop, oop); }
  64 
  65   // Value type fields
  66   uint          field_count() const { return req() - Values; }
  67   Node*         field_value(uint index) const;
  68   Node*         field_value_by_offset(int offset, bool recursive = false) const;
  69   void      set_field_value(uint index, Node* value);
  70   int           field_offset(uint index) const;
  71   ciType*       field_type(uint index) const;
  72   bool          field_is_flattened(uint index) const;
  73 
  74   // Replace ValueTypeNodes in debug info at safepoints with SafePointScalarObjectNodes
  75   void make_scalar_in_safepoints(Node* root, PhaseGVN* gvn);
  76 
  77   // Store the value type as a flattened (headerless) representation
  78   void store_flattened(GraphKit* kit, Node* base, Node* ptr, ciInstanceKlass* holder = NULL, int holder_offset = 0) const;
  79   // Store the field values to memory
  80   void store(GraphKit* kit, Node* base, Node* ptr, ciInstanceKlass* holder, int holder_offset = 0) const;
  81 
  82   // Initialize the value type by loading its field values from memory
  83   void load(PhaseGVN& gvn, Node*& ctl, Node* mem, Node* base, Node* ptr, ciInstanceKlass* holder, int holder_offset = 0);
  84 
  85   // Allocates the value type (if not yet allocated) and returns the oop
  86   ValueTypeBaseNode* allocate(GraphKit* kit);
  87   bool is_allocated(PhaseGVN* phase) const;
  88 
  89   void replace_call_results(GraphKit* kit, Node* call, Compile* C);
  90 };
  91 
  92 //------------------------------ValueTypeNode-------------------------------------
  93 // Node representing a value type in C2 IR
  94 class ValueTypeNode : public ValueTypeBaseNode {
  95   friend class ValueTypeBaseNode;

  96 private:
  97   ValueTypeNode(const TypeValueType* t, Node* oop, Compile* C)
  98     : ValueTypeBaseNode(t, Values + t->value_klass()->nof_declared_nonstatic_fields(), C) {
  99     init_class_id(Class_ValueType);
 100     init_req(Oop, oop);
 101   }
 102 
 103   // Checks if the value type is loaded from memory and if so returns the oop
 104   Node* is_loaded(PhaseGVN* phase, const TypeValueType* t, Node* base = NULL, int holder_offset = 0);
 105 
 106   const TypeValueTypePtr* value_type_ptr() const { return TypeValueTypePtr::make(bottom_type()->isa_valuetype()); }
 107   // Get the klass defining the field layout of the value type
 108   ciValueKlass* value_klass() const { return type()->is_valuetype()->value_klass(); }
 109 
 110 public:
 111   // Create a new ValueTypeNode with uninitialized values
 112   static ValueTypeNode* make(PhaseGVN& gvn, ciValueKlass* klass);
 113   // Create a new ValueTypeNode with default values
 114   static Node* make_default(PhaseGVN& gvn, ciValueKlass* vk);
 115   // Create a new ValueTypeNode and load its values from an oop
 116   static Node* make(GraphKit* kit, Node* oop, bool null_check = false);
 117   static Node* make(PhaseGVN& gvn, Node*& ctl, Node* mem, Node* oop, bool null_check = false);
 118   // Create a new ValueTypeNode and load its values from a flattened value type field or array
 119   static Node* make(GraphKit* kit, ciValueKlass* vk, Node* obj, Node* ptr, ciInstanceKlass* holder = NULL, int holder_offset = 0);
 120   static Node* make(PhaseGVN& gvn, ciValueKlass* vk, Node*& ctl, Node* mem, Node* obj, Node* ptr, ciInstanceKlass* holder = NULL, int holder_offset = 0);
 121   // Create value type node from arguments at method entry and calls
 122   static Node* make(PhaseGVN& gvn, Node*& ctl, Node* mem, Node* n, ciValueKlass* vk, int base_input, bool in);
 123 
 124   // Allocate all non-flattened value type fields
 125   Node* allocate_fields(GraphKit* kit);
 126 
 127   Node* tagged_klass(PhaseGVN& gvn);
 128   void pass_klass(Node* n, uint pos, const GraphKit& kit);
 129   uint pass_fields(Node* call, int base_input, GraphKit& kit, bool assert_allocated = false, ciValueKlass* base_vk = NULL, int base_offset = 0);
 130 
 131   // Allocation optimizations
 132   void remove_redundant_allocations(PhaseIterGVN* igvn, PhaseIdealLoop* phase);
 133 
 134   virtual Node* Ideal(PhaseGVN* phase, bool can_reshape);
 135   virtual int Opcode() const;
 136 
 137 #ifndef PRODUCT
 138   virtual void dump_spec(outputStream* st) const;
 139 #endif
 140 };
 141 
 142 //------------------------------ValueTypePtrNode-------------------------------------
 143 // Node representing a value type as a pointer in C2 IR
 144 class ValueTypePtrNode : public ValueTypeBaseNode {
 145 private:
 146   ciValueKlass* value_klass() const { return type()->is_valuetypeptr()->value_type()->value_klass(); }
 147   const TypeValueTypePtr* value_type_ptr() const { return bottom_type()->isa_valuetypeptr(); }
 148 
 149   ValueTypePtrNode(ciValueKlass* vk, Node* oop, Compile* C)
 150     : ValueTypeBaseNode(TypeValueTypePtr::make(TypePtr::NotNull, vk), Values + vk->nof_declared_nonstatic_fields(), C) {
 151     init_class_id(Class_ValueTypePtr);
 152     init_req(Oop, oop);
 153   }
 154 public:
 155 
 156   ValueTypePtrNode(ValueTypeNode* vt, Node* oop, Compile* C)
 157     : ValueTypeBaseNode(TypeValueTypePtr::make(vt->type()->is_valuetype())->cast_to_ptr_type(TypePtr::NotNull), vt->req(), C) {
 158     init_class_id(Class_ValueTypePtr);
 159     for (uint i = Oop+1; i < vt->req(); i++) {
 160       init_req(i, vt->in(i));
 161     }
 162     init_req(Oop, oop);
 163   }
 164 
 165   static ValueTypePtrNode* make(GraphKit* kit, ciValueKlass* vk, CallNode* call);
 166   static ValueTypePtrNode* make(PhaseGVN& gvn, Node*& ctl, Node* mem, Node* oop);
 167   virtual int Opcode() const;
 168 };
 169 
 170 #endif // SHARE_VM_OPTO_VALUETYPENODE_HPP


  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_OPTO_VALUETYPENODE_HPP
  26 #define SHARE_VM_OPTO_VALUETYPENODE_HPP
  27 
  28 #include "opto/node.hpp"
  29 #include "opto/connode.hpp"
  30 
  31 class GraphKit;
  32 
  33 class ValueTypeBaseNode : public TypeNode {
  34 protected:
  35   ValueTypeBaseNode(const Type* t, int nb_fields)
  36     : TypeNode(t, nb_fields) {
  37     init_class_id(Class_ValueTypeBase);
  38     Compile::current()->add_value_type(this);
  39   }
  40 
  41   enum { Control,   // Control input
  42          Oop,       // Oop of TypeValueTypePtr
  43          Values     // Nodes corresponding to values of the value type's fields.
  44                     // Nodes are connected in increasing order of the index of the field they correspond to.

  45   };
  46 
  47   virtual const TypeValueTypePtr* value_type_ptr() const = 0;
  48   // Get the klass defining the field layout of the value type
  49   virtual ciValueKlass* value_klass() const = 0;
  50 
  51   int make_scalar_in_safepoint(Unique_Node_List& worklist, SafePointNode* sfpt, Node* root, PhaseGVN* gvn);
  52 
  53   // Initialize the value type fields with the inputs or outputs of a MultiNode
  54   void initialize(PhaseGVN* gvn, Node*& ctl, Node* mem, MultiNode* multi, ciValueKlass* vk, int base_offset = 0, int base_input = TypeFunc::Parms+1, bool in = false);
  55 
  56 public:
  57   // Support for control flow merges
  58   bool has_phi_inputs(Node* region);
  59   ValueTypeBaseNode* clone_with_phis(PhaseGVN* gvn, Node* region);
  60   ValueTypeBaseNode* merge_with(PhaseGVN* gvn, const ValueTypeBaseNode* other, int pnum, bool transform);
  61 
  62   // Get oop for heap allocated value type (may be TypePtr::NULL_PTR)
  63   Node* get_oop() const    { return in(Oop); }
  64   void  set_oop(Node* oop) { set_req(Oop, oop); }
  65 
  66   // Value type fields
  67   uint          field_count() const { return req() - Values; }
  68   Node*         field_value(uint index) const;
  69   Node*         field_value_by_offset(int offset, bool recursive = false) const;
  70   void      set_field_value(uint index, Node* value);
  71   int           field_offset(uint index) const;
  72   ciType*       field_type(uint index) const;
  73   bool          field_is_flattened(uint index) const;
  74 
  75   // Replace ValueTypeNodes in debug info at safepoints with SafePointScalarObjectNodes
  76   void make_scalar_in_safepoints(Node* root, PhaseGVN* gvn);
  77 
  78   // Store the value type as a flattened (headerless) representation
  79   void store_flattened(GraphKit* kit, Node* base, Node* ptr, ciInstanceKlass* holder = NULL, int holder_offset = 0) const;
  80   // Store the field values to memory
  81   void store(GraphKit* kit, Node* base, Node* ptr, ciInstanceKlass* holder, int holder_offset = 0) const;

  82   // Initialize the value type by loading its field values from memory
  83   void load(PhaseGVN& gvn, Node*& ctl, Node* mem, Node* base, Node* ptr, ciInstanceKlass* holder, int holder_offset = 0);
  84 
  85   // Allocates the value type (if not yet allocated)
  86   ValueTypeBaseNode* allocate(GraphKit* kit);
  87   bool is_allocated(PhaseGVN* phase) const;
  88 
  89   void replace_call_results(GraphKit* kit, Node* call, Compile* C);
  90 };
  91 
  92 //------------------------------ValueTypeNode-------------------------------------
  93 // Node representing a value type in C2 IR
  94 class ValueTypeNode : public ValueTypeBaseNode {
  95   friend class ValueTypeBaseNode;
  96   friend class ValueTypePtrNode;
  97 private:
  98   ValueTypeNode(const TypeValueType* t, Node* oop)
  99     : ValueTypeBaseNode(t, Values + t->value_klass()->nof_declared_nonstatic_fields()) {
 100     init_class_id(Class_ValueType);
 101     init_req(Oop, oop);
 102   }
 103 
 104   // Checks if the value type is loaded from memory and if so returns the oop
 105   Node* is_loaded(PhaseGVN* phase, ciValueKlass* vk = NULL, Node* base = NULL, int holder_offset = 0);
 106 
 107   const TypeValueTypePtr* value_type_ptr() const { return TypeValueTypePtr::make(TypePtr::BotPTR, value_klass()); }

 108   ciValueKlass* value_klass() const { return type()->is_valuetype()->value_klass(); }
 109 
 110 public:
 111   // Create uninitialized
 112   static ValueTypeNode* make_uninitialized(PhaseGVN& gvn, ciValueKlass* klass);
 113   // Create with default field values
 114   static ValueTypeNode* make_default(PhaseGVN& gvn, ciValueKlass* vk);
 115   // Create and initialize by loading the field values from an oop
 116   static ValueTypeNode* make_from_oop(GraphKit* kit, Node* oop, bool null_check = false);
 117   static ValueTypeNode* make_from_oop(PhaseGVN& gvn, Node*& ctl, Node* mem, Node* oop, bool null_check = false);
 118   // Create and initialize by loading the field values from a flattened field or array
 119   static ValueTypeNode* make_from_flattened(GraphKit* kit, ciValueKlass* vk, Node* obj, Node* ptr, ciInstanceKlass* holder = NULL, int holder_offset = 0);
 120   static ValueTypeNode* make_from_flattened(PhaseGVN& gvn, ciValueKlass* vk, Node*& ctl, Node* mem, Node* obj, Node* ptr, ciInstanceKlass* holder = NULL, int holder_offset = 0);
 121   // Create and initialize with the inputs or outputs of a MultiNode (method entry or call)
 122   static ValueTypeNode* make_from_multi(PhaseGVN& gvn, Node*& ctl, Node* mem, MultiNode* multi, ciValueKlass* vk, int base_input, bool in);
 123 
 124   // Allocate all non-flattened value type fields
 125   Node* allocate_fields(GraphKit* kit);
 126 
 127   Node* tagged_klass(PhaseGVN& gvn);
 128   void pass_klass(Node* n, uint pos, const GraphKit& kit);
 129   uint pass_fields(Node* call, int base_input, GraphKit& kit, bool assert_allocated = false, ciValueKlass* base_vk = NULL, int base_offset = 0);
 130 
 131   // Allocation optimizations
 132   void remove_redundant_allocations(PhaseIterGVN* igvn, PhaseIdealLoop* phase);
 133 
 134   virtual Node* Ideal(PhaseGVN* phase, bool can_reshape);
 135   virtual int Opcode() const;




 136 };
 137 
 138 //------------------------------ValueTypePtrNode-------------------------------------
 139 // Node representing a value type as a pointer in C2 IR
 140 class ValueTypePtrNode : public ValueTypeBaseNode {
 141 private:
 142   const TypeValueTypePtr* value_type_ptr() const { return type()->isa_valuetypeptr(); }
 143   ciValueKlass* value_klass() const { return value_type_ptr()->value_klass(); }
 144 
 145   ValueTypePtrNode(ciValueKlass* vk, Node* oop)
 146     : ValueTypeBaseNode(TypeValueTypePtr::make(TypePtr::NotNull, vk), Values + vk->nof_declared_nonstatic_fields()) {
 147     init_class_id(Class_ValueTypePtr);
 148     init_req(Oop, oop);
 149   }

 150 
 151 public:
 152   // Create and initialize with the values of a ValueTypeNode
 153   static ValueTypePtrNode* make_from_value_type(PhaseGVN& gvn, ValueTypeNode* vt);
 154   // Create and initialize with the result values of a call
 155   static ValueTypePtrNode* make_from_call(GraphKit* kit, ciValueKlass* vk, CallNode* call);
 156   // Create and initialize by loading the field values from an oop
 157   static ValueTypePtrNode* make_from_oop(PhaseGVN& gvn, Node*& ctl, Node* mem, Node* oop);

 158 


 159   virtual int Opcode() const;
 160 };
 161 
 162 #endif // SHARE_VM_OPTO_VALUETYPENODE_HPP
< prev index next >