< prev index next >

src/hotspot/share/opto/valuetypenode.hpp

Print this page




  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 TypeInstPtr
  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 TypeInstPtr* value_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(GraphKit* kit, MultiNode* multi, ciValueKlass* vk, int base_offset = 0, int base_input = TypeFunc::Parms+1, bool in = false);
  55 
  56   const TypePtr* field_adr_type(Node* base, int offset, ciInstanceKlass* holder, PhaseGVN& gvn) const;
  57 
  58 public:
  59   // Support for control flow merges
  60   bool has_phi_inputs(Node* region);
  61   ValueTypeBaseNode* clone_with_phis(PhaseGVN* gvn, Node* region);
  62   ValueTypeBaseNode* merge_with(PhaseGVN* gvn, const ValueTypeBaseNode* other, int pnum, bool transform);
  63   void add_new_path(Node* region);
  64 
  65   // Get oop for heap allocated value type (may be TypePtr::NULL_PTR)
  66   Node* get_oop() const    { return in(Oop); }
  67   void  set_oop(Node* oop) { set_req(Oop, oop); }
  68 
  69   // Value type fields
  70   uint          field_count() const { return req() - Values; }
  71   Node*         field_value(uint index) const;
  72   Node*         field_value_by_offset(int offset, bool recursive = false) const;
  73   void      set_field_value(uint index, Node* value);
  74   void      set_field_value_by_offset(int offset, Node* value);


 108 
 109   // Checks if the value type is loaded from memory and if so returns the oop
 110   Node* is_loaded(PhaseGVN* phase, ciValueKlass* vk = NULL, Node* base = NULL, int holder_offset = 0);
 111 
 112   // Checks if the value type fields are all set to default values
 113   bool is_default(PhaseGVN& gvn) const;
 114 
 115   const TypeInstPtr* value_ptr() const { return TypeInstPtr::make(TypePtr::BotPTR, value_klass()); }
 116   ciValueKlass* value_klass() const { return type()->is_valuetype()->value_klass(); }
 117 
 118 public:
 119   // Create uninitialized
 120   static ValueTypeNode* make_uninitialized(PhaseGVN& gvn, ciValueKlass* vk);
 121   // Create with default field values
 122   static ValueTypeNode* make_default(PhaseGVN& gvn, ciValueKlass* vk);
 123   // Create and initialize by loading the field values from an oop
 124   static ValueTypeNode* make_from_oop(GraphKit* kit, Node* oop, ciValueKlass* vk);
 125   // Create and initialize by loading the field values from a flattened field or array
 126   static ValueTypeNode* make_from_flattened(GraphKit* kit, ciValueKlass* vk, Node* obj, Node* ptr, ciInstanceKlass* holder = NULL, int holder_offset = 0);
 127   // Create and initialize with the inputs or outputs of a MultiNode (method entry or call)
 128   static ValueTypeNode* make_from_multi(GraphKit* kit, MultiNode* multi, ciValueKlass* vk, int base_input, bool in);
 129 
 130   // Returns the constant oop of the default value type allocation
 131   static Node* default_oop(PhaseGVN& gvn, ciValueKlass* vk);
 132 
 133   // Allocate all non-flattened value type fields
 134   Node* allocate_fields(GraphKit* kit);
 135 
 136   Node* tagged_klass(PhaseGVN& gvn);
 137   void pass_klass(Node* n, uint pos, const GraphKit& kit);
 138   uint pass_fields(Node* call, int base_input, GraphKit& kit, bool assert_allocated = false, ciValueKlass* base_vk = NULL, int base_offset = 0);
 139 
 140   // Allocation optimizations
 141   void remove_redundant_allocations(PhaseIterGVN* igvn, PhaseIdealLoop* phase);
 142 
 143   virtual Node* Ideal(PhaseGVN* phase, bool can_reshape);
 144   virtual int Opcode() const;
 145 };
 146 
 147 //------------------------------ValueTypePtrNode-------------------------------------
 148 // Node representing a value type as a pointer in C2 IR
 149 class ValueTypePtrNode : public ValueTypeBaseNode {
 150 private:
 151   const TypeInstPtr* value_ptr() const { return type()->isa_instptr(); }
 152   ciValueKlass* value_klass() const { return value_ptr()->value_klass(); }
 153 
 154   ValueTypePtrNode(ciValueKlass* vk, Node* oop)
 155     : ValueTypeBaseNode(TypeInstPtr::make(TypePtr::NotNull, vk), Values + vk->nof_declared_nonstatic_fields()) {
 156     init_class_id(Class_ValueTypePtr);
 157     init_req(Oop, oop);


  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 TypeInstPtr
  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 TypeInstPtr* value_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(GraphKit* kit, MultiNode* multi, ciValueKlass* vk, int base_offset, uint& base_input, bool in);
  55 
  56   const TypePtr* field_adr_type(Node* base, int offset, ciInstanceKlass* holder, PhaseGVN& gvn) const;
  57 
  58 public:
  59   // Support for control flow merges
  60   bool has_phi_inputs(Node* region);
  61   ValueTypeBaseNode* clone_with_phis(PhaseGVN* gvn, Node* region);
  62   ValueTypeBaseNode* merge_with(PhaseGVN* gvn, const ValueTypeBaseNode* other, int pnum, bool transform);
  63   void add_new_path(Node* region);
  64 
  65   // Get oop for heap allocated value type (may be TypePtr::NULL_PTR)
  66   Node* get_oop() const    { return in(Oop); }
  67   void  set_oop(Node* oop) { set_req(Oop, oop); }
  68 
  69   // Value type fields
  70   uint          field_count() const { return req() - Values; }
  71   Node*         field_value(uint index) const;
  72   Node*         field_value_by_offset(int offset, bool recursive = false) const;
  73   void      set_field_value(uint index, Node* value);
  74   void      set_field_value_by_offset(int offset, Node* value);


 108 
 109   // Checks if the value type is loaded from memory and if so returns the oop
 110   Node* is_loaded(PhaseGVN* phase, ciValueKlass* vk = NULL, Node* base = NULL, int holder_offset = 0);
 111 
 112   // Checks if the value type fields are all set to default values
 113   bool is_default(PhaseGVN& gvn) const;
 114 
 115   const TypeInstPtr* value_ptr() const { return TypeInstPtr::make(TypePtr::BotPTR, value_klass()); }
 116   ciValueKlass* value_klass() const { return type()->is_valuetype()->value_klass(); }
 117 
 118 public:
 119   // Create uninitialized
 120   static ValueTypeNode* make_uninitialized(PhaseGVN& gvn, ciValueKlass* vk);
 121   // Create with default field values
 122   static ValueTypeNode* make_default(PhaseGVN& gvn, ciValueKlass* vk);
 123   // Create and initialize by loading the field values from an oop
 124   static ValueTypeNode* make_from_oop(GraphKit* kit, Node* oop, ciValueKlass* vk);
 125   // Create and initialize by loading the field values from a flattened field or array
 126   static ValueTypeNode* make_from_flattened(GraphKit* kit, ciValueKlass* vk, Node* obj, Node* ptr, ciInstanceKlass* holder = NULL, int holder_offset = 0);
 127   // Create and initialize with the inputs or outputs of a MultiNode (method entry or call)
 128   static ValueTypeNode* make_from_multi(GraphKit* kit, MultiNode* multi, ciValueKlass* vk, uint& base_input, bool in);
 129 
 130   // Returns the constant oop of the default value type allocation
 131   static Node* default_oop(PhaseGVN& gvn, ciValueKlass* vk);
 132 
 133   // Allocate all non-flattened value type fields
 134   Node* allocate_fields(GraphKit* kit);
 135 
 136   Node* tagged_klass(PhaseGVN& gvn);

 137   uint pass_fields(Node* call, int base_input, GraphKit& kit, bool assert_allocated = false, ciValueKlass* base_vk = NULL, int base_offset = 0);
 138 
 139   // Allocation optimizations
 140   void remove_redundant_allocations(PhaseIterGVN* igvn, PhaseIdealLoop* phase);
 141 
 142   virtual Node* Ideal(PhaseGVN* phase, bool can_reshape);
 143   virtual int Opcode() const;
 144 };
 145 
 146 //------------------------------ValueTypePtrNode-------------------------------------
 147 // Node representing a value type as a pointer in C2 IR
 148 class ValueTypePtrNode : public ValueTypeBaseNode {
 149 private:
 150   const TypeInstPtr* value_ptr() const { return type()->isa_instptr(); }
 151   ciValueKlass* value_klass() const { return value_ptr()->value_klass(); }
 152 
 153   ValueTypePtrNode(ciValueKlass* vk, Node* oop)
 154     : ValueTypeBaseNode(TypeInstPtr::make(TypePtr::NotNull, vk), Values + vk->nof_declared_nonstatic_fields()) {
 155     init_class_id(Class_ValueTypePtr);
 156     init_req(Oop, oop);
< prev index next >