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 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); 75 int field_offset(uint index) const; 76 ciType* field_type(uint index) const; 77 bool field_is_flattened(uint index) const; 78 bool field_is_flattenable(uint index) const; 79 80 // Replace ValueTypeNodes in debug info at safepoints with SafePointScalarObjectNodes 81 void make_scalar_in_safepoints(Node* root, PhaseGVN* gvn); 82 83 // Store the value type as a flattened (headerless) representation 84 void store_flattened(GraphKit* kit, Node* base, Node* ptr, ciInstanceKlass* holder = NULL, int holder_offset = 0) const; 85 // Store the field values to memory 86 void store(GraphKit* kit, Node* base, Node* ptr, ciInstanceKlass* holder, int holder_offset = 0, bool deoptimize_on_exception = false) const; 87 // Initialize the value type by loading its field values from memory 88 void load(GraphKit* kit, Node* base, Node* ptr, ciInstanceKlass* holder, int holder_offset = 0); 89 90 // Allocates the value type (if not yet allocated) 91 ValueTypeBaseNode* allocate(GraphKit* kit, bool deoptimize_on_exception = false); 92 bool is_allocated(PhaseGVN* phase) const; 93 94 void replace_call_results(GraphKit* kit, Node* call, Compile* C); 95 }; 96 97 //------------------------------ValueTypeNode------------------------------------- 98 // Node representing a value type in C2 IR 99 class ValueTypeNode : public ValueTypeBaseNode { 100 friend class ValueTypeBaseNode; 101 friend class ValueTypePtrNode; | 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 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(PhaseIterGVN* igvn, Unique_Node_List& worklist, SafePointNode* sfpt); 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); 75 int field_offset(uint index) const; 76 ciType* field_type(uint index) const; 77 bool field_is_flattened(uint index) const; 78 bool field_is_flattenable(uint index) const; 79 80 // Replace ValueTypeNodes in debug info at safepoints with SafePointScalarObjectNodes 81 void make_scalar_in_safepoints(PhaseIterGVN* igvn); 82 83 // Store the value type as a flattened (headerless) representation 84 void store_flattened(GraphKit* kit, Node* base, Node* ptr, ciInstanceKlass* holder = NULL, int holder_offset = 0) const; 85 // Store the field values to memory 86 void store(GraphKit* kit, Node* base, Node* ptr, ciInstanceKlass* holder, int holder_offset = 0, bool deoptimize_on_exception = false) const; 87 // Initialize the value type by loading its field values from memory 88 void load(GraphKit* kit, Node* base, Node* ptr, ciInstanceKlass* holder, int holder_offset = 0); 89 90 // Allocates the value type (if not yet allocated) 91 ValueTypeBaseNode* allocate(GraphKit* kit, bool deoptimize_on_exception = false); 92 bool is_allocated(PhaseGVN* phase) const; 93 94 void replace_call_results(GraphKit* kit, Node* call, Compile* C); 95 }; 96 97 //------------------------------ValueTypeNode------------------------------------- 98 // Node representing a value type in C2 IR 99 class ValueTypeNode : public ValueTypeBaseNode { 100 friend class ValueTypeBaseNode; 101 friend class ValueTypePtrNode; |