95 if (!static_field_ok_in_clinit(field, method())) {
96 uncommon_trap(Deoptimization::Reason_uninitialized,
97 Deoptimization::Action_reinterpret,
98 NULL, "!static_field_ok_in_clinit");
99 return;
100 }
101 }
102
103 assert(field->will_link(method()->holder(), bc()), "getfield: typeflow responsibility");
104
105 // Note: We do not check for an unloaded field type here any more.
106
107 // Generate code for the object pointer.
108 Node* obj;
109 if (is_field) {
110 int obj_depth = is_get ? 0 : field->type()->size();
111 obj = do_null_check(peek(obj_depth), T_OBJECT);
112 // Compile-time detect of null-exception?
113 if (stopped()) return;
114
115 const TypeInstPtr *tjp = TypeInstPtr::make(TypePtr::NotNull, iter().get_declared_field_holder());
116 assert(_gvn.type(obj)->higher_equal(tjp), "cast_up is no longer needed");
117
118 if (is_get) {
119 --_sp; // pop receiver before getting
120 do_get_xxx(tjp, obj, field, is_field);
121 } else {
122 do_put_xxx(tjp, obj, field, is_field);
123 --_sp; // pop receiver after putting
124 }
125 } else {
126 const TypeKlassPtr* tkp = TypeKlassPtr::make(field_holder);
127 obj = _gvn.makecon(tkp);
128 if (is_get) {
129 do_get_xxx(tkp, obj, field, is_field);
130 } else {
131 do_put_xxx(tkp, obj, field, is_field);
132 }
133 }
134 }
135
136
137 void Parse::do_get_xxx(const TypePtr* obj_type, Node* obj, ciField* field, bool is_field) {
138 // Does this field have a constant value? If so, just push the value.
139 if (field->is_constant()) {
140 if (field->is_static()) {
141 // final static field
142 if (push_constant(field->constant_value()))
143 return;
144 }
145 else {
146 // final non-static field of a trusted class (classes in
147 // java.lang.invoke and sun.invoke packages and subpackages).
148 if (obj->is_Con()) {
149 const TypeOopPtr* oop_ptr = obj->bottom_type()->isa_oopptr();
150 ciObject* constant_oop = oop_ptr->const_oop();
151 ciConstant constant = field->constant_value_of(constant_oop);
152
153 if (push_constant(constant, true))
154 return;
155 }
156 }
157 }
214 #endif
215 if (C->log() != NULL) {
216 C->log()->elem("assert_null reason='field' klass='%d'",
217 C->log()->identify(field->type()));
218 }
219 // If there is going to be a trap, put it at the next bytecode:
220 set_bci(iter().next_bci());
221 do_null_assert(peek(), T_OBJECT);
222 set_bci(iter().cur_bci()); // put it back
223 }
224
225 // If reference is volatile, prevent following memory ops from
226 // floating up past the volatile read. Also prevents commoning
227 // another volatile read.
228 if (field->is_volatile()) {
229 // Memory barrier includes bogus read of value to force load BEFORE membar
230 insert_mem_bar(Op_MemBarAcquire, ld);
231 }
232 }
233
234 void Parse::do_put_xxx(const TypePtr* obj_type, Node* obj, ciField* field, bool is_field) {
235 bool is_vol = field->is_volatile();
236 // If reference is volatile, prevent following memory ops from
237 // floating down past the volatile write. Also prevents commoning
238 // another volatile read.
239 if (is_vol) insert_mem_bar(Op_MemBarRelease);
240
241 // Compute address and memory type.
242 int offset = field->offset_in_bytes();
243 const TypePtr* adr_type = C->alias_type(field)->adr_type();
244 Node* adr = basic_plus_adr(obj, obj, offset);
245 BasicType bt = field->layout_type();
246 // Value to be stored
247 Node* val = type2size[bt] == 1 ? pop() : pop_pair();
248 // Round doubles before storing
249 if (bt == T_DOUBLE) val = dstore_rounding(val);
250
251 // Store the value.
252 Node* store;
253 if (bt == T_OBJECT) {
254 const TypeOopPtr* field_type;
|
95 if (!static_field_ok_in_clinit(field, method())) {
96 uncommon_trap(Deoptimization::Reason_uninitialized,
97 Deoptimization::Action_reinterpret,
98 NULL, "!static_field_ok_in_clinit");
99 return;
100 }
101 }
102
103 assert(field->will_link(method()->holder(), bc()), "getfield: typeflow responsibility");
104
105 // Note: We do not check for an unloaded field type here any more.
106
107 // Generate code for the object pointer.
108 Node* obj;
109 if (is_field) {
110 int obj_depth = is_get ? 0 : field->type()->size();
111 obj = do_null_check(peek(obj_depth), T_OBJECT);
112 // Compile-time detect of null-exception?
113 if (stopped()) return;
114
115 #ifdef ASSERT
116 const TypeInstPtr *tjp = TypeInstPtr::make(TypePtr::NotNull, iter().get_declared_field_holder());
117 assert(_gvn.type(obj)->higher_equal(tjp), "cast_up is no longer needed");
118 #endif
119
120 if (is_get) {
121 --_sp; // pop receiver before getting
122 do_get_xxx(obj, field, is_field);
123 } else {
124 do_put_xxx(obj, field, is_field);
125 --_sp; // pop receiver after putting
126 }
127 } else {
128 const TypeInstPtr* tip = TypeInstPtr::make(field_holder->java_mirror());
129 obj = _gvn.makecon(tip);
130 if (is_get) {
131 do_get_xxx(obj, field, is_field);
132 } else {
133 do_put_xxx(obj, field, is_field);
134 }
135 }
136 }
137
138
139 void Parse::do_get_xxx(Node* obj, ciField* field, bool is_field) {
140 // Does this field have a constant value? If so, just push the value.
141 if (field->is_constant()) {
142 if (field->is_static()) {
143 // final static field
144 if (push_constant(field->constant_value()))
145 return;
146 }
147 else {
148 // final non-static field of a trusted class (classes in
149 // java.lang.invoke and sun.invoke packages and subpackages).
150 if (obj->is_Con()) {
151 const TypeOopPtr* oop_ptr = obj->bottom_type()->isa_oopptr();
152 ciObject* constant_oop = oop_ptr->const_oop();
153 ciConstant constant = field->constant_value_of(constant_oop);
154
155 if (push_constant(constant, true))
156 return;
157 }
158 }
159 }
216 #endif
217 if (C->log() != NULL) {
218 C->log()->elem("assert_null reason='field' klass='%d'",
219 C->log()->identify(field->type()));
220 }
221 // If there is going to be a trap, put it at the next bytecode:
222 set_bci(iter().next_bci());
223 do_null_assert(peek(), T_OBJECT);
224 set_bci(iter().cur_bci()); // put it back
225 }
226
227 // If reference is volatile, prevent following memory ops from
228 // floating up past the volatile read. Also prevents commoning
229 // another volatile read.
230 if (field->is_volatile()) {
231 // Memory barrier includes bogus read of value to force load BEFORE membar
232 insert_mem_bar(Op_MemBarAcquire, ld);
233 }
234 }
235
236 void Parse::do_put_xxx(Node* obj, ciField* field, bool is_field) {
237 bool is_vol = field->is_volatile();
238 // If reference is volatile, prevent following memory ops from
239 // floating down past the volatile write. Also prevents commoning
240 // another volatile read.
241 if (is_vol) insert_mem_bar(Op_MemBarRelease);
242
243 // Compute address and memory type.
244 int offset = field->offset_in_bytes();
245 const TypePtr* adr_type = C->alias_type(field)->adr_type();
246 Node* adr = basic_plus_adr(obj, obj, offset);
247 BasicType bt = field->layout_type();
248 // Value to be stored
249 Node* val = type2size[bt] == 1 ? pop() : pop_pair();
250 // Round doubles before storing
251 if (bt == T_DOUBLE) val = dstore_rounding(val);
252
253 // Store the value.
254 Node* store;
255 if (bt == T_OBJECT) {
256 const TypeOopPtr* field_type;
|