< prev index next >

src/share/vm/opto/valuetypenode.hpp

Print this page




  13  * accompanied this code).
  14  *
  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 //------------------------------ValueTypeNode-------------------------------------
  34 // Node representing a value type in C2 IR
  35 class ValueTypeNode : public TypeNode {

  36 private:
  37   ValueTypeNode(const TypeValueType* t, Node* oop)
  38     : TypeNode(t, Values + t->value_klass()->nof_declared_nonstatic_fields()) {
  39     init_class_id(Class_ValueType);
  40     init_req(Oop, oop);
  41   }
  42 
  43   ValueTypeNode(const TypeValueType* t, Node* oop, int field_count)
  44     : TypeNode(t, Values + field_count) {
  45     init_class_id(Class_ValueType);
  46     init_req(Oop, oop);
  47   }
  48 
  49   // Get the klass defining the field layout of the value type
  50   ciValueKlass* value_klass() const { return type()->is_valuetype()->value_klass(); }
  51   // Initialize the value type by loading its field values from memory
  52   void load(PhaseGVN& gvn, Node* mem, Node* base, Node* ptr, ciInstanceKlass* holder, int holder_offset = 0);
  53   // Checks if the value type is loaded from memory and if so returns the oop
  54   Node* is_loaded(PhaseGVN* phase, const TypeValueType* t, Node* base = NULL, int holder_offset = 0);
  55 
  56   enum { Control,   // Control input
  57          Oop,       // Oop of TypeValueTypePtr
  58          Values     // Nodes corresponding to values of the value type's fields.
  59                     // Nodes are connected in increasing order of the index of the field
  60                     // they correspond to. Field indeces are defined in ciValueKlass::_field_index_map.
  61   };
  62 
  63 public:
  64   // Create a new ValueTypeNode with uninitialized values
  65   static ValueTypeNode* make(PhaseGVN& gvn, ciValueKlass* klass);
  66   // Create a new ValueTypeNode with default values
  67   static Node* make_default(PhaseGVN& gvn, ciValueKlass* vk);
  68   // Create a new ValueTypeNode and load its values from an oop
  69   static Node* make(PhaseGVN& gvn, Node* mem, Node* oop);
  70   // Create a new ValueTypeNode and load its values from a flattened value type field or array
  71   static Node* make(PhaseGVN& gvn, ciValueKlass* vk, Node* mem, Node* obj, Node* ptr, ciInstanceKlass* holder = NULL, int holder_offset = 0);
  72 
  73   // Support for control flow merges
  74   ValueTypeNode* clone_with_phis(PhaseGVN* gvn, Node* region);
  75   bool  has_phi_inputs(Node* region);
  76   ValueTypeNode* merge_with(PhaseGVN* gvn, const ValueTypeNode* other, int pnum, bool transform);
  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 
  83   // Get oop for heap allocated value type (may be TypePtr::NULL_PTR)
  84   Node* get_oop() const    { return in(Oop); }
  85   void  set_oop(Node* oop) { set_req(Oop, oop); }
  86   // Allocates the value type (if not yet allocated) and returns the oop
  87   Node* allocate(GraphKit* kit);
  88   bool  is_allocated(PhaseGVN* phase) const;
  89 
  90   // Value type fields
  91   uint          field_count() const { return req() - Values; }
  92   Node*         field_value(uint index) const;
  93   Node*         field_value_by_offset(int offset, bool recursive = false) const;
  94   void      set_field_value(uint index, Node* value);
  95   int           field_offset(uint index) const;
  96   ciType*       field_type(uint index) const;
  97 
  98   // Replace ValueTypeNodes in debug info at safepoints with SafePointScalarObjectNodes
  99   void make_scalar_in_safepoints(Compile* C);
 100   void pass_klass(Node* n, uint pos, const GraphKit& kit);
 101   uint pass_fields(Node* call, int base_input, const GraphKit& kit, ciValueKlass* base_vk = NULL, int base_offset = 0);
 102   void replace_call_results(Node* call, Compile* C);
 103 
 104   // Allocation optimizations
 105   void remove_redundant_allocations(PhaseIterGVN* igvn, PhaseIdealLoop* phase);
 106 
 107   virtual Node* Ideal(PhaseGVN* phase, bool can_reshape);
 108   virtual int Opcode() const;
 109 
 110 #ifndef PRODUCT
 111   virtual void dump_spec(outputStream* st) const;
 112 #endif





















 113 };
 114 
 115 #endif // SHARE_VM_OPTO_VALUETYPENODE_HPP


  13  * accompanied this code).
  14  *
  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   }
  39 
  40   enum { Control,   // Control input
  41          Oop,       // Oop of TypeValueTypePtr
  42          Values     // Nodes corresponding to values of the value type's fields.
  43                     // Nodes are connected in increasing order of the index of the field
  44                     // they correspond to. Field indeces are defined in ciValueKlass::_field_index_map.
  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   int make_scalar_in_safepoint(SafePointNode* sfpt, Node* root, PhaseGVN* gvn);
  51 public:
  52   // Support for control flow merges
  53   bool  has_phi_inputs(Node* region);
  54   ValueTypeBaseNode* clone_with_phis(PhaseGVN* gvn, Node* region);
  55   ValueTypeBaseNode* merge_with(PhaseGVN* gvn, const ValueTypeBaseNode* other, int pnum, bool transform);
  56 
  57   // Get oop for heap allocated value type (may be TypePtr::NULL_PTR)
  58   Node* get_oop() const    { return in(Oop); }
  59   void  set_oop(Node* oop) { set_req(Oop, oop); }
  60 
  61   // Value type fields
  62   uint          field_count() const { return req() - Values; }
  63   Node*         field_value(uint index) const;
  64   Node*         field_value_by_offset(int offset, bool recursive = false) const;
  65   void      set_field_value(uint index, Node* value);
  66   int           field_offset(uint index) const;
  67   ciType*       field_type(uint index) const;
  68 
  69   // Replace ValueTypeNodes in debug info at safepoints with SafePointScalarObjectNodes
  70   void make_scalar_in_safepoints(Node* root, PhaseGVN* gvn);
  71 };
  72 
  73 //------------------------------ValueTypeNode-------------------------------------
  74 // Node representing a value type in C2 IR
  75 class ValueTypeNode : public ValueTypeBaseNode {
  76   friend class ValueTypeBaseNode;
  77 private:
  78   ValueTypeNode(const TypeValueType* t, Node* oop)
  79     : ValueTypeBaseNode(t, Values + t->value_klass()->nof_declared_nonstatic_fields()) {
  80     init_class_id(Class_ValueType);
  81     init_req(Oop, oop);
  82   }
  83 
  84   ValueTypeNode(const TypeValueType* t, Node* oop, int field_count)
  85     : ValueTypeBaseNode(t, Values + field_count) {
  86     init_class_id(Class_ValueType);
  87     init_req(Oop, oop);
  88   }
  89 


  90   // Initialize the value type by loading its field values from memory
  91   void load(PhaseGVN& gvn, Node* mem, Node* base, Node* ptr, ciInstanceKlass* holder, int holder_offset = 0);
  92   // Checks if the value type is loaded from memory and if so returns the oop
  93   Node* is_loaded(PhaseGVN* phase, const TypeValueType* t, Node* base = NULL, int holder_offset = 0);
  94 
  95   const TypeValueTypePtr* value_type_ptr() const { return TypeValueTypePtr::make(bottom_type()->isa_valuetype()); }
  96   // Get the klass defining the field layout of the value type
  97   ciValueKlass* value_klass() const { return type()->is_valuetype()->value_klass(); }



  98 
  99 public:
 100   // Create a new ValueTypeNode with uninitialized values
 101   static ValueTypeNode* make(PhaseGVN& gvn, ciValueKlass* klass);
 102   // Create a new ValueTypeNode with default values
 103   static Node* make_default(PhaseGVN& gvn, ciValueKlass* vk);
 104   // Create a new ValueTypeNode and load its values from an oop
 105   static Node* make(PhaseGVN& gvn, Node* mem, Node* oop);
 106   // Create a new ValueTypeNode and load its values from a flattened value type field or array
 107   static Node* make(PhaseGVN& gvn, ciValueKlass* vk, Node* mem, Node* obj, Node* ptr, ciInstanceKlass* holder = NULL, int holder_offset = 0);
 108 




 109 
 110   // Store the value type as a flattened (headerless) representation
 111   void store_flattened(GraphKit* kit, Node* base, Node* ptr, ciInstanceKlass* holder = NULL, int holder_offset = 0) const;
 112   // Store the field values to memory
 113   void store(GraphKit* kit, Node* base, Node* ptr, ciInstanceKlass* holder, int holder_offset = 0) const;
 114 



 115   // Allocates the value type (if not yet allocated) and returns the oop
 116   Node* allocate(GraphKit* kit);
 117   bool  is_allocated(PhaseGVN* phase) const;
 118 










 119   void pass_klass(Node* n, uint pos, const GraphKit& kit);
 120   uint pass_fields(Node* call, int base_input, const GraphKit& kit, ciValueKlass* base_vk = NULL, int base_offset = 0);
 121   void replace_call_results(Node* call, Compile* C);
 122 
 123   // Allocation optimizations
 124   void remove_redundant_allocations(PhaseIterGVN* igvn, PhaseIdealLoop* phase);
 125 
 126   virtual Node* Ideal(PhaseGVN* phase, bool can_reshape);
 127   virtual int Opcode() const;
 128 
 129 #ifndef PRODUCT
 130   virtual void dump_spec(outputStream* st) const;
 131 #endif
 132 };
 133 
 134 //------------------------------ValueTypeNode-------------------------------------
 135 // Node representing a value type as a pointer in C2 IR
 136 class ValueTypePtrNode : public ValueTypeBaseNode {
 137 private:
 138   ciValueKlass* value_klass() const { return type()->is_valuetypeptr()->value_type()->value_klass(); }
 139   const TypeValueTypePtr* value_type_ptr() const { return bottom_type()->isa_valuetypeptr(); }
 140 public:
 141 
 142   ValueTypePtrNode(ValueTypeNode* vt, Node* oop, Compile* C)
 143     : ValueTypeBaseNode(TypeValueTypePtr::make(vt->type()->is_valuetype())->cast_to_ptr_type(TypePtr::NotNull), vt->req()) {
 144     init_class_id(Class_ValueTypePtr);
 145     for (uint i = Oop+1; i < vt->req(); i++) {
 146       init_req(i, vt->in(i));
 147     }
 148     init_req(Oop, oop);
 149     C->add_value_type_ptr(this);
 150   }
 151 
 152   virtual int Opcode() const;
 153 };
 154 
 155 #endif // SHARE_VM_OPTO_VALUETYPENODE_HPP
< prev index next >