< prev index next >

src/hotspot/share/opto/parse3.cpp

Print this page

147       type = TypeInstPtr::BOTTOM;
148       must_assert_null = true;
149     } else if (field->is_static_constant()) {
150       // This can happen if the constant oop is non-perm.
151       ciObject* con = field->constant_value().as_object();
152       // Do not "join" in the previous type; it doesn't add value,
153       // and may yield a vacuous result if the field is of interface type.
154       if (con->is_null_object()) {
155         type = TypePtr::NULL_PTR;
156       } else {
157         type = TypeOopPtr::make_from_constant(con)->isa_oopptr();
158       }
159       assert(type != nullptr, "field singleton type must be consistent");
160     } else {
161       type = TypeOopPtr::make_from_klass(field_klass->as_klass());
162     }
163   } else {
164     type = Type::get_const_basic_type(bt);
165   }
166 
167   Node* ld = access_load_at(obj, adr, adr_type, type, bt, decorators);
168 

















169   // Adjust Java stack
170   if (type2size[bt] == 1)
171     push(ld);
172   else
173     push_pair(ld);
174 
175   if (must_assert_null) {
176     // Do not take a trap here.  It's possible that the program
177     // will never load the field's class, and will happily see
178     // null values in this field forever.  Don't stumble into a
179     // trap for such a program, or we might get a long series
180     // of useless recompilations.  (Or, we might load a class
181     // which should not be loaded.)  If we ever see a non-null
182     // value, we will then trap and recompile.  (The trap will
183     // not need to mention the class index, since the class will
184     // already have been loaded if we ever see a non-null value.)
185     // uncommon_trap(iter().get_field_signature_index());
186     if (PrintOpto && (Verbose || WizardMode)) {
187       method()->print_name(); tty->print_cr(" asserting nullness of field at bci: %d", bci());
188     }

207   BasicType bt = field->layout_type();
208   // Value to be stored
209   Node* val = type2size[bt] == 1 ? pop() : pop_pair();
210 
211   DecoratorSet decorators = IN_HEAP;
212   decorators |= is_vol ? MO_SEQ_CST : MO_UNORDERED;
213 
214   bool is_obj = is_reference_type(bt);
215 
216   // Store the value.
217   const Type* field_type;
218   if (!field->type()->is_loaded()) {
219     field_type = TypeInstPtr::BOTTOM;
220   } else {
221     if (is_obj) {
222       field_type = TypeOopPtr::make_from_klass(field->type()->as_klass());
223     } else {
224       field_type = Type::BOTTOM;
225     }
226   }



















227   access_store_at(obj, adr, adr_type, val, field_type, bt, decorators);
228 
229   if (is_field) {
230     // Remember we wrote a volatile field.
231     // For not multiple copy atomic cpu (ppc64) a barrier should be issued
232     // in constructors which have such stores. See do_exits() in parse1.cpp.
233     if (is_vol) {
234       set_wrote_volatile(true);
235     }
236     set_wrote_fields(true);
237 
238     // If the field is final, the rules of Java say we are in <init> or <clinit>.
239     // Note the presence of writes to final non-static fields, so that we
240     // can insert a memory barrier later on to keep the writes from floating
241     // out of the constructor.
242     // Any method can write a @Stable field; insert memory barriers after those also.
243     if (field->is_final()) {
244       set_wrote_final(true);
245       if (AllocateNode::Ideal_allocation(obj) != nullptr) {
246         // Preserve allocation ptr to create precedent edge to it in membar

147       type = TypeInstPtr::BOTTOM;
148       must_assert_null = true;
149     } else if (field->is_static_constant()) {
150       // This can happen if the constant oop is non-perm.
151       ciObject* con = field->constant_value().as_object();
152       // Do not "join" in the previous type; it doesn't add value,
153       // and may yield a vacuous result if the field is of interface type.
154       if (con->is_null_object()) {
155         type = TypePtr::NULL_PTR;
156       } else {
157         type = TypeOopPtr::make_from_constant(con)->isa_oopptr();
158       }
159       assert(type != nullptr, "field singleton type must be consistent");
160     } else {
161       type = TypeOopPtr::make_from_klass(field_klass->as_klass());
162     }
163   } else {
164     type = Type::get_const_basic_type(bt);
165   }
166 
167   Node* ld = nullptr;
168 
169   if (DoPartialEscapeAnalysis && is_field) { // non-static field a global
170     PEAState& as = jvms()->alloc_state();
171     VirtualState* vs = as.as_virtual(PEA(), obj);
172     if (vs != nullptr) { // obj is a virtual object
173       Node* val = vs->get_field(field);
174       // val is nullptr because the field is not explicitly initialized. It is 'null'.
175       // We only replace an instance pointer here. for array pointer, we need to cast 'val' from oop-ptr to aryptr.
176       if (is_obj && val != nullptr && type->isa_instptr()) {
177         ld = val;
178       }
179       // theoretically, we can replace ld with val if val is scalar or even nullptr.
180       // Graal has a feature called 'ReadElimination to do so.
181     }
182   }
183   if (ld == nullptr) {
184     ld = access_load_at(obj, adr, adr_type, type, bt, decorators);
185   }
186   // Adjust Java stack
187   if (type2size[bt] == 1)
188     push(ld);
189   else
190     push_pair(ld);
191 
192   if (must_assert_null) {
193     // Do not take a trap here.  It's possible that the program
194     // will never load the field's class, and will happily see
195     // null values in this field forever.  Don't stumble into a
196     // trap for such a program, or we might get a long series
197     // of useless recompilations.  (Or, we might load a class
198     // which should not be loaded.)  If we ever see a non-null
199     // value, we will then trap and recompile.  (The trap will
200     // not need to mention the class index, since the class will
201     // already have been loaded if we ever see a non-null value.)
202     // uncommon_trap(iter().get_field_signature_index());
203     if (PrintOpto && (Verbose || WizardMode)) {
204       method()->print_name(); tty->print_cr(" asserting nullness of field at bci: %d", bci());
205     }

224   BasicType bt = field->layout_type();
225   // Value to be stored
226   Node* val = type2size[bt] == 1 ? pop() : pop_pair();
227 
228   DecoratorSet decorators = IN_HEAP;
229   decorators |= is_vol ? MO_SEQ_CST : MO_UNORDERED;
230 
231   bool is_obj = is_reference_type(bt);
232 
233   // Store the value.
234   const Type* field_type;
235   if (!field->type()->is_loaded()) {
236     field_type = TypeInstPtr::BOTTOM;
237   } else {
238     if (is_obj) {
239       field_type = TypeOopPtr::make_from_klass(field->type()->as_klass());
240     } else {
241       field_type = Type::BOTTOM;
242     }
243   }
244 
245   // if val is a valid object and the current path isn't dead
246   if (DoPartialEscapeAnalysis && !stopped()) {
247     PartialEscapeAnalysis* pea = PEA();
248     PEAState& state = jvms()->alloc_state();
249 
250     // val is escaped if obj is escaped or is not trackable.
251     if (is_obj && !val->is_top()) {
252       // put_static_field or unknown dst or dst is escaped.
253       if (state.as_virtual(pea, val) != nullptr && (!is_field || state.as_virtual(pea, obj) == nullptr)) {
254         val = state.materialize(this, val);
255       }
256     }
257     VirtualState* vs = nullptr;
258     if (is_field && (vs = state.as_virtual(pea, obj)) != nullptr) {
259       vs->set_field(field, val);
260     }
261   }
262 
263   access_store_at(obj, adr, adr_type, val, field_type, bt, decorators);
264 
265   if (is_field) {
266     // Remember we wrote a volatile field.
267     // For not multiple copy atomic cpu (ppc64) a barrier should be issued
268     // in constructors which have such stores. See do_exits() in parse1.cpp.
269     if (is_vol) {
270       set_wrote_volatile(true);
271     }
272     set_wrote_fields(true);
273 
274     // If the field is final, the rules of Java say we are in <init> or <clinit>.
275     // Note the presence of writes to final non-static fields, so that we
276     // can insert a memory barrier later on to keep the writes from floating
277     // out of the constructor.
278     // Any method can write a @Stable field; insert memory barriers after those also.
279     if (field->is_final()) {
280       set_wrote_final(true);
281       if (AllocateNode::Ideal_allocation(obj) != nullptr) {
282         // Preserve allocation ptr to create precedent edge to it in membar
< prev index next >