153 // Keep consistent with types found by ciTypeFlow: for an
154 // unloaded field type, ciTypeFlow::StateVector::do_getstatic()
155 // speculates the field is null. The code in the rest of this
156 // method does the same. We must not bypass it and use a non
157 // null constant here.
158 (bt != T_OBJECT || field->type()->is_loaded())) {
159 // final or stable field
160 Node* con = make_constant_from_field(field, obj);
161 if (con != NULL) {
162 push_node(field->layout_type(), con);
163 return;
164 }
165 }
166
167 ciType* field_klass = field->type();
168 bool is_vol = field->is_volatile();
169
170 // Compute address and memory type.
171 int offset = field->offset_in_bytes();
172 const TypePtr* adr_type = C->alias_type(field)->adr_type();
173
174 Node *adr = basic_plus_adr(obj, obj, offset);
175
176 // Build the resultant type of the load
177 const Type *type;
178
179 bool must_assert_null = false;
180
181 DecoratorSet decorators = IN_HEAP;
182 decorators |= is_vol ? MO_SEQ_CST : MO_UNORDERED;
183
184 bool is_obj = bt == T_OBJECT || bt == T_ARRAY;
185
186 if (is_obj) {
187 if (!field->type()->is_loaded()) {
188 type = TypeInstPtr::BOTTOM;
189 must_assert_null = true;
190 } else if (field->is_static_constant()) {
191 // This can happen if the constant oop is non-perm.
192 ciObject* con = field->constant_value().as_object();
193 // Do not "join" in the previous type; it doesn't add value,
194 // and may yield a vacuous result if the field is of interface type.
195 if (con->is_null_object()) {
196 type = TypePtr::NULL_PTR;
197 } else {
198 type = TypeOopPtr::make_from_constant(con)->isa_oopptr();
199 }
200 assert(type != NULL, "field singleton type must be consistent");
201 } else {
202 type = TypeOopPtr::make_from_klass(field_klass->as_klass());
203 }
204 } else {
205 type = Type::get_const_basic_type(bt);
206 }
207
208 Node* ld = access_load_at(obj, adr, adr_type, type, bt, decorators);
209
210 #if INCLUDE_SHENANDOAHGC
211 // Only enabled for Shenandoah. Can this be useful in general?
212 if (UseShenandoahGC && ShenandoahOptimizeStableFinals && UseImplicitStableValues) {
213 if (field->holder()->name() == ciSymbol::java_lang_String() &&
214 field->offset() == java_lang_String::value_offset_in_bytes()) {
215 const TypeAryPtr* value_type = TypeAryPtr::make(TypePtr::NotNull,
216 TypeAry::make(TypeInt::BYTE, TypeInt::POS),
217 ciTypeArrayKlass::make(T_BYTE), true, 0);
218 ld = cast_array_to_stable(ld, value_type);
219 }
220 }
221 #endif
222
223 // Adjust Java stack
224 if (type2size[bt] == 1)
225 push(ld);
226 else
227 push_pair(ld);
228
229 if (must_assert_null) {
230 // Do not take a trap here. It's possible that the program
231 // will never load the field's class, and will happily see
232 // null values in this field forever. Don't stumble into a
233 // trap for such a program, or we might get a long series
234 // of useless recompilations. (Or, we might load a class
235 // which should not be loaded.) If we ever see a non-null
236 // value, we will then trap and recompile. (The trap will
237 // not need to mention the class index, since the class will
238 // already have been loaded if we ever see a non-null value.)
239 // uncommon_trap(iter().get_field_signature_index());
240 if (PrintOpto && (Verbose || WizardMode)) {
241 method()->print_name(); tty->print_cr(" asserting nullness of field at bci: %d", bci());
|
153 // Keep consistent with types found by ciTypeFlow: for an
154 // unloaded field type, ciTypeFlow::StateVector::do_getstatic()
155 // speculates the field is null. The code in the rest of this
156 // method does the same. We must not bypass it and use a non
157 // null constant here.
158 (bt != T_OBJECT || field->type()->is_loaded())) {
159 // final or stable field
160 Node* con = make_constant_from_field(field, obj);
161 if (con != NULL) {
162 push_node(field->layout_type(), con);
163 return;
164 }
165 }
166
167 ciType* field_klass = field->type();
168 bool is_vol = field->is_volatile();
169
170 // Compute address and memory type.
171 int offset = field->offset_in_bytes();
172 const TypePtr* adr_type = C->alias_type(field)->adr_type();
173 Node *adr = basic_plus_adr(obj, obj, offset);
174
175 // Build the resultant type of the load
176 const Type *type;
177
178 bool must_assert_null = false;
179
180 DecoratorSet decorators = IN_HEAP;
181 decorators |= is_vol ? MO_SEQ_CST : MO_UNORDERED;
182
183 bool is_obj = bt == T_OBJECT || bt == T_ARRAY;
184
185 if (is_obj) {
186 if (!field->type()->is_loaded()) {
187 type = TypeInstPtr::BOTTOM;
188 must_assert_null = true;
189 } else if (field->is_static_constant()) {
190 // This can happen if the constant oop is non-perm.
191 ciObject* con = field->constant_value().as_object();
192 // Do not "join" in the previous type; it doesn't add value,
193 // and may yield a vacuous result if the field is of interface type.
194 if (con->is_null_object()) {
195 type = TypePtr::NULL_PTR;
196 } else {
197 type = TypeOopPtr::make_from_constant(con)->isa_oopptr();
198 }
199 assert(type != NULL, "field singleton type must be consistent");
200 } else {
201 type = TypeOopPtr::make_from_klass(field_klass->as_klass());
202 }
203 } else {
204 type = Type::get_const_basic_type(bt);
205 }
206
207 Node* ld = access_load_at(obj, adr, adr_type, type, bt, decorators);
208
209 // Adjust Java stack
210 if (type2size[bt] == 1)
211 push(ld);
212 else
213 push_pair(ld);
214
215 if (must_assert_null) {
216 // Do not take a trap here. It's possible that the program
217 // will never load the field's class, and will happily see
218 // null values in this field forever. Don't stumble into a
219 // trap for such a program, or we might get a long series
220 // of useless recompilations. (Or, we might load a class
221 // which should not be loaded.) If we ever see a non-null
222 // value, we will then trap and recompile. (The trap will
223 // not need to mention the class index, since the class will
224 // already have been loaded if we ever see a non-null value.)
225 // uncommon_trap(iter().get_field_signature_index());
226 if (PrintOpto && (Verbose || WizardMode)) {
227 method()->print_name(); tty->print_cr(" asserting nullness of field at bci: %d", bci());
|