< prev index next >

src/hotspot/share/opto/parse3.cpp

Print this page




 149       // Keep consistent with types found by ciTypeFlow: for an
 150       // unloaded field type, ciTypeFlow::StateVector::do_getstatic()
 151       // speculates the field is null. The code in the rest of this
 152       // method does the same. We must not bypass it and use a non
 153       // null constant here.
 154       (bt != T_OBJECT || field->type()->is_loaded())) {
 155     // final or stable field
 156     Node* con = make_constant_from_field(field, obj);
 157     if (con != NULL) {
 158       push_node(field->layout_type(), con);
 159       return;
 160     }
 161   }
 162 
 163   ciType* field_klass = field->type();
 164   bool is_vol = field->is_volatile();
 165 
 166   // Compute address and memory type.
 167   int offset = field->offset_in_bytes();
 168   const TypePtr* adr_type = C->alias_type(field)->adr_type();












 169   Node *adr = basic_plus_adr(obj, obj, offset);
 170 
 171   // Build the resultant type of the load
 172   const Type *type;
 173 
 174   bool must_assert_null = false;
 175 
 176   DecoratorSet decorators = IN_HEAP;
 177   decorators |= is_vol ? MO_SEQ_CST : MO_UNORDERED;
 178 
 179   bool is_obj = bt == T_OBJECT || bt == T_ARRAY;
 180 
 181   if (is_obj) {
 182     if (!field->type()->is_loaded()) {
 183       type = TypeInstPtr::BOTTOM;
 184       must_assert_null = true;
 185     } else if (field->is_static_constant()) {
 186       // This can happen if the constant oop is non-perm.
 187       ciObject* con = field->constant_value().as_object();
 188       // Do not "join" in the previous type; it doesn't add value,
 189       // and may yield a vacuous result if the field is of interface type.
 190       if (con->is_null_object()) {
 191         type = TypePtr::NULL_PTR;
 192       } else {
 193         type = TypeOopPtr::make_from_constant(con)->isa_oopptr();
 194       }
 195       assert(type != NULL, "field singleton type must be consistent");
 196     } else {
 197       type = TypeOopPtr::make_from_klass(field_klass->as_klass());
 198     }
 199   } else {
 200     type = Type::get_const_basic_type(bt);
 201   }
 202 
 203   Node* ld = access_load_at(obj, adr, adr_type, type, bt, decorators);
 204 













 205   // Adjust Java stack
 206   if (type2size[bt] == 1)
 207     push(ld);
 208   else
 209     push_pair(ld);
 210 
 211   if (must_assert_null) {
 212     // Do not take a trap here.  It's possible that the program
 213     // will never load the field's class, and will happily see
 214     // null values in this field forever.  Don't stumble into a
 215     // trap for such a program, or we might get a long series
 216     // of useless recompilations.  (Or, we might load a class
 217     // which should not be loaded.)  If we ever see a non-null
 218     // value, we will then trap and recompile.  (The trap will
 219     // not need to mention the class index, since the class will
 220     // already have been loaded if we ever see a non-null value.)
 221     // uncommon_trap(iter().get_field_signature_index());
 222     if (PrintOpto && (Verbose || WizardMode)) {
 223       method()->print_name(); tty->print_cr(" asserting nullness of field at bci: %d", bci());
 224     }
 225     if (C->log() != NULL) {
 226       C->log()->elem("assert_null reason='field' klass='%d'",
 227                      C->log()->identify(field->type()));
 228     }
 229     // If there is going to be a trap, put it at the next bytecode:
 230     set_bci(iter().next_bci());
 231     null_assert(peek());
 232     set_bci(iter().cur_bci()); // put it back
 233   }
 234 }
 235 
 236 void Parse::do_put_xxx(Node* obj, ciField* field, bool is_field) {
 237   bool is_vol = field->is_volatile();



 238 
 239   // Compute address and memory type.
 240   int offset = field->offset_in_bytes();
 241   const TypePtr* adr_type = C->alias_type(field)->adr_type();
 242   Node* adr = basic_plus_adr(obj, obj, offset);
 243   BasicType bt = field->layout_type();
 244   // Value to be stored
 245   Node* val = type2size[bt] == 1 ? pop() : pop_pair();
 246 
 247   DecoratorSet decorators = IN_HEAP;
 248   decorators |= is_vol ? MO_SEQ_CST : MO_UNORDERED;
 249 
 250   bool is_obj = bt == T_OBJECT || bt == T_ARRAY;
 251 
 252   // Store the value.
 253   const Type* field_type;
 254   if (!field->type()->is_loaded()) {
 255     field_type = TypeInstPtr::BOTTOM;
 256   } else {
 257     if (is_obj) {




 149       // Keep consistent with types found by ciTypeFlow: for an
 150       // unloaded field type, ciTypeFlow::StateVector::do_getstatic()
 151       // speculates the field is null. The code in the rest of this
 152       // method does the same. We must not bypass it and use a non
 153       // null constant here.
 154       (bt != T_OBJECT || field->type()->is_loaded())) {
 155     // final or stable field
 156     Node* con = make_constant_from_field(field, obj);
 157     if (con != NULL) {
 158       push_node(field->layout_type(), con);
 159       return;
 160     }
 161   }
 162 
 163   ciType* field_klass = field->type();
 164   bool is_vol = field->is_volatile();
 165 
 166   // Compute address and memory type.
 167   int offset = field->offset_in_bytes();
 168   const TypePtr* adr_type = C->alias_type(field)->adr_type();
 169 
 170 #if INCLUDE_SHENANDOAHGC
 171   // Insert read barrier for Shenandoah.
 172   if ((ShenandoahOptimizeStaticFinals   && field->is_static()  && field->is_final()) ||
 173       (ShenandoahOptimizeInstanceFinals && !field->is_static() && field->is_final()) ||
 174       (ShenandoahOptimizeStableFinals   && field->is_stable())) {
 175     // Skip the barrier for special fields
 176   } else {
 177     obj = access_resolve_for_read(obj);
 178   }
 179 #endif
 180 
 181   Node *adr = basic_plus_adr(obj, obj, offset);
 182 
 183   // Build the resultant type of the load
 184   const Type *type;
 185 
 186   bool must_assert_null = false;
 187 
 188   DecoratorSet decorators = IN_HEAP;
 189   decorators |= is_vol ? MO_SEQ_CST : MO_UNORDERED;
 190 
 191   bool is_obj = bt == T_OBJECT || bt == T_ARRAY;
 192 
 193   if (is_obj) {
 194     if (!field->type()->is_loaded()) {
 195       type = TypeInstPtr::BOTTOM;
 196       must_assert_null = true;
 197     } else if (field->is_static_constant()) {
 198       // This can happen if the constant oop is non-perm.
 199       ciObject* con = field->constant_value().as_object();
 200       // Do not "join" in the previous type; it doesn't add value,
 201       // and may yield a vacuous result if the field is of interface type.
 202       if (con->is_null_object()) {
 203         type = TypePtr::NULL_PTR;
 204       } else {
 205         type = TypeOopPtr::make_from_constant(con)->isa_oopptr();
 206       }
 207       assert(type != NULL, "field singleton type must be consistent");
 208     } else {
 209       type = TypeOopPtr::make_from_klass(field_klass->as_klass());
 210     }
 211   } else {
 212     type = Type::get_const_basic_type(bt);
 213   }
 214 
 215   Node* ld = access_load_at(obj, adr, adr_type, type, bt, decorators);
 216 
 217 #if INCLUDE_SHENANDOAHGC
 218   // Only enabled for Shenandoah. Can this be useful in general?
 219   if (UseShenandoahGC && ShenandoahOptimizeStableFinals && UseImplicitStableValues) {
 220     if (field->holder()->name() == ciSymbol::java_lang_String() &&
 221         field->offset() == java_lang_String::value_offset_in_bytes()) {
 222       const TypeAryPtr* value_type = TypeAryPtr::make(TypePtr::NotNull,
 223                                                       TypeAry::make(TypeInt::BYTE, TypeInt::POS),
 224                                                       ciTypeArrayKlass::make(T_BYTE), true, 0);
 225       ld = cast_array_to_stable(ld, value_type);
 226     }
 227   }
 228 #endif
 229 
 230   // Adjust Java stack
 231   if (type2size[bt] == 1)
 232     push(ld);
 233   else
 234     push_pair(ld);
 235 
 236   if (must_assert_null) {
 237     // Do not take a trap here.  It's possible that the program
 238     // will never load the field's class, and will happily see
 239     // null values in this field forever.  Don't stumble into a
 240     // trap for such a program, or we might get a long series
 241     // of useless recompilations.  (Or, we might load a class
 242     // which should not be loaded.)  If we ever see a non-null
 243     // value, we will then trap and recompile.  (The trap will
 244     // not need to mention the class index, since the class will
 245     // already have been loaded if we ever see a non-null value.)
 246     // uncommon_trap(iter().get_field_signature_index());
 247     if (PrintOpto && (Verbose || WizardMode)) {
 248       method()->print_name(); tty->print_cr(" asserting nullness of field at bci: %d", bci());
 249     }
 250     if (C->log() != NULL) {
 251       C->log()->elem("assert_null reason='field' klass='%d'",
 252                      C->log()->identify(field->type()));
 253     }
 254     // If there is going to be a trap, put it at the next bytecode:
 255     set_bci(iter().next_bci());
 256     null_assert(peek());
 257     set_bci(iter().cur_bci()); // put it back
 258   }
 259 }
 260 
 261 void Parse::do_put_xxx(Node* obj, ciField* field, bool is_field) {
 262   bool is_vol = field->is_volatile();
 263 
 264   // Insert write barrier for Shenandoah.
 265   obj = access_resolve_for_write(obj);
 266 
 267   // Compute address and memory type.
 268   int offset = field->offset_in_bytes();
 269   const TypePtr* adr_type = C->alias_type(field)->adr_type();
 270   Node* adr = basic_plus_adr(obj, obj, offset);
 271   BasicType bt = field->layout_type();
 272   // Value to be stored
 273   Node* val = type2size[bt] == 1 ? pop() : pop_pair();
 274 
 275   DecoratorSet decorators = IN_HEAP;
 276   decorators |= is_vol ? MO_SEQ_CST : MO_UNORDERED;
 277 
 278   bool is_obj = bt == T_OBJECT || bt == T_ARRAY;
 279 
 280   // Store the value.
 281   const Type* field_type;
 282   if (!field->type()->is_loaded()) {
 283     field_type = TypeInstPtr::BOTTOM;
 284   } else {
 285     if (is_obj) {


< prev index next >