hotspot/src/share/vm/opto/parse3.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot-comp Sdiff hotspot/src/share/vm/opto

hotspot/src/share/vm/opto/parse3.cpp

Print this page
rev 5140 : imported patch stable


 130       do_get_xxx(obj, field, is_field);
 131     } else {
 132       do_put_xxx(obj, field, is_field);
 133       (void) pop();  // pop receiver after putting
 134     }
 135   } else {
 136     const TypeInstPtr* tip = TypeInstPtr::make(field_holder->java_mirror());
 137     obj = _gvn.makecon(tip);
 138     if (is_get) {
 139       do_get_xxx(obj, field, is_field);
 140     } else {
 141       do_put_xxx(obj, field, is_field);
 142     }
 143   }
 144 }
 145 
 146 
 147 void Parse::do_get_xxx(Node* obj, ciField* field, bool is_field) {
 148   // Does this field have a constant value?  If so, just push the value.
 149   if (field->is_constant()) {
 150     // final field








 151     if (field->is_static()) {
 152       // final static field
 153       if (C->eliminate_boxing()) {
 154         // The pointers in the autobox arrays are always non-null.
 155         ciSymbol* klass_name = field->holder()->name();
 156         if (field->name() == ciSymbol::cache_field_name() &&
 157             field->holder()->uses_default_loader() &&
 158             (klass_name == ciSymbol::java_lang_Character_CharacterCache() ||
 159              klass_name == ciSymbol::java_lang_Byte_ByteCache() ||
 160              klass_name == ciSymbol::java_lang_Short_ShortCache() ||
 161              klass_name == ciSymbol::java_lang_Integer_IntegerCache() ||
 162              klass_name == ciSymbol::java_lang_Long_LongCache())) {
 163           bool require_const = true;
 164           bool autobox_cache = true;
 165           if (push_constant(field->constant_value(), require_const, autobox_cache)) {
 166             return;
 167           }
 168         }
 169       }
 170       if (push_constant(field->constant_value()))
 171         return;
 172     }
 173     else {
 174       // final non-static field
 175       // Treat final non-static fields of trusted classes (classes in
 176       // java.lang.invoke and sun.invoke packages and subpackages) as
 177       // compile time constants.
 178       if (obj->is_Con()) {
 179         const TypeOopPtr* oop_ptr = obj->bottom_type()->isa_oopptr();
 180         ciObject* constant_oop = oop_ptr->const_oop();
 181         ciConstant constant = field->constant_value_of(constant_oop);
 182         if (push_constant(constant, true))



 183           return;
 184       }
 185     }
 186   }

 187 
 188   ciType* field_klass = field->type();
 189   bool is_vol = field->is_volatile();
 190 
 191   // Compute address and memory type.
 192   int offset = field->offset_in_bytes();
 193   const TypePtr* adr_type = C->alias_type(field)->adr_type();
 194   Node *adr = basic_plus_adr(obj, obj, offset);
 195   BasicType bt = field->layout_type();
 196 
 197   // Build the resultant type of the load
 198   const Type *type;
 199 
 200   bool must_assert_null = false;
 201 
 202   if( bt == T_OBJECT ) {
 203     if (!field->type()->is_loaded()) {
 204       type = TypeInstPtr::BOTTOM;
 205       must_assert_null = true;
 206     } else if (field->is_constant() && field->is_static()) {


 284     if (!field->type()->is_loaded()) {
 285       field_type = TypeInstPtr::BOTTOM;
 286     } else {
 287       field_type = TypeOopPtr::make_from_klass(field->type()->as_klass());
 288     }
 289     store = store_oop_to_object( control(), obj, adr, adr_type, val, field_type, bt);
 290   } else {
 291     store = store_to_memory( control(), adr, val, bt, adr_type, is_vol );
 292   }
 293 
 294   // If reference is volatile, prevent following volatiles ops from
 295   // floating up before the volatile write.
 296   if (is_vol) {
 297     insert_mem_bar(Op_MemBarVolatile); // Use fat membar
 298   }
 299 
 300   // If the field is final, the rules of Java say we are in <init> or <clinit>.
 301   // Note the presence of writes to final non-static fields, so that we
 302   // can insert a memory barrier later on to keep the writes from floating
 303   // out of the constructor.
 304   if (is_field && field->is_final()) {

 305     set_wrote_final(true);
 306     // Preserve allocation ptr to create precedent edge to it in membar
 307     // generated on exit from constructor.
 308     if (C->eliminate_boxing() &&
 309         adr_type->isa_oopptr() && adr_type->is_oopptr()->is_ptr_to_boxed_value() &&
 310         AllocateNode::Ideal_allocation(obj, &_gvn) != NULL) {
 311       set_alloc_with_final(obj);
 312     }
 313   }
 314 }
 315 
 316 
 317 bool Parse::push_constant(ciConstant constant, bool require_constant, bool is_autobox_cache) {


 318   switch (constant.basic_type()) {
 319   case T_BOOLEAN:  push( intcon(constant.as_boolean()) ); break;
 320   case T_INT:      push( intcon(constant.as_int())     ); break;
 321   case T_CHAR:     push( intcon(constant.as_char())    ); break;
 322   case T_BYTE:     push( intcon(constant.as_byte())    ); break;
 323   case T_SHORT:    push( intcon(constant.as_short())   ); break;
 324   case T_FLOAT:    push( makecon(TypeF::make(constant.as_float())) );  break;
 325   case T_DOUBLE:   push_pair( makecon(TypeD::make(constant.as_double())) );  break;
 326   case T_LONG:     push_pair( longcon(constant.as_long()) ); break;
 327   case T_ARRAY:
 328   case T_OBJECT: {
 329     // cases:
 330     //   can_be_constant    = (oop not scavengable || ScavengeRootsInCode != 0)
 331     //   should_be_constant = (oop not scavengable || ScavengeRootsInCode >= 2)
 332     // An oop is not scavengable if it is in the perm gen.
 333     ciObject* oop_constant = constant.as_object();
 334     if (oop_constant->is_null_object()) {
 335       push( zerocon(T_OBJECT) );
 336       break;
 337     } else if (require_constant || oop_constant->should_be_constant()) {
 338       push( makecon(TypeOopPtr::make_from_constant(oop_constant, require_constant, is_autobox_cache)) );
 339       break;
 340     } else {
 341       // we cannot inline the oop, but we can use it later to narrow a type
 342       return false;
 343     }
 344   }
 345   case T_ILLEGAL: {
 346     // Invalid ciConstant returned due to OutOfMemoryError in the CI
 347     assert(C->env()->failing(), "otherwise should not see this");
 348     // These always occur because of object types; we are going to
 349     // bail out anyway, so make the stack depths match up
 350     push( zerocon(T_OBJECT) );
 351     return false;
 352   }
 353   default:
 354     ShouldNotReachHere();

 355     return false;
 356   }
 357 
 358   // success
 359   return true;
 360 }
 361 
 362 
 363 
 364 //=============================================================================
 365 void Parse::do_anewarray() {
 366   bool will_link;
 367   ciKlass* klass = iter().get_klass(will_link);
 368 
 369   // Uncommon Trap when class that array contains is not loaded
 370   // we need the loaded class for the rest of graph; do not
 371   // initialize the container class (see Java spec)!!!
 372   assert(will_link, "anewarray: typeflow responsibility");
 373 
 374   ciObjArrayKlass* array_klass = ciObjArrayKlass::make(klass);
 375   // Check that array_klass object is loaded
 376   if (!array_klass->is_loaded()) {
 377     // Generate uncommon_trap for unloaded array_class
 378     uncommon_trap(Deoptimization::Reason_unloaded,
 379                   Deoptimization::Action_reinterpret,
 380                   array_klass);
 381     return;
 382   }
 383 




 130       do_get_xxx(obj, field, is_field);
 131     } else {
 132       do_put_xxx(obj, field, is_field);
 133       (void) pop();  // pop receiver after putting
 134     }
 135   } else {
 136     const TypeInstPtr* tip = TypeInstPtr::make(field_holder->java_mirror());
 137     obj = _gvn.makecon(tip);
 138     if (is_get) {
 139       do_get_xxx(obj, field, is_field);
 140     } else {
 141       do_put_xxx(obj, field, is_field);
 142     }
 143   }
 144 }
 145 
 146 
 147 void Parse::do_get_xxx(Node* obj, ciField* field, bool is_field) {
 148   // Does this field have a constant value?  If so, just push the value.
 149   if (field->is_constant()) {
 150     // final or stable field
 151     const Type* stable_type = NULL;
 152     if (FoldStableValues && field->is_stable()) {
 153       stable_type = Type::get_const_type(field->type());
 154       if (field->type()->is_array_klass()) {
 155         int stable_dimension = field->type()->as_array_klass()->dimension();
 156         stable_type = stable_type->is_aryptr()->cast_to_stable(true, stable_dimension);
 157       }
 158     }
 159     if (field->is_static()) {
 160       // final static field
 161       if (C->eliminate_boxing()) {
 162         // The pointers in the autobox arrays are always non-null.
 163         ciSymbol* klass_name = field->holder()->name();
 164         if (field->name() == ciSymbol::cache_field_name() &&
 165             field->holder()->uses_default_loader() &&
 166             (klass_name == ciSymbol::java_lang_Character_CharacterCache() ||
 167              klass_name == ciSymbol::java_lang_Byte_ByteCache() ||
 168              klass_name == ciSymbol::java_lang_Short_ShortCache() ||
 169              klass_name == ciSymbol::java_lang_Integer_IntegerCache() ||
 170              klass_name == ciSymbol::java_lang_Long_LongCache())) {
 171           bool require_const = true;
 172           bool autobox_cache = true;
 173           if (push_constant(field->constant_value(), require_const, autobox_cache)) {
 174             return;
 175           }
 176         }
 177       }
 178       if (push_constant(field->constant_value(), false, false, stable_type))
 179         return;
 180     } else {
 181       // final or stable non-static field

 182       // Treat final non-static fields of trusted classes (classes in
 183       // java.lang.invoke and sun.invoke packages and subpackages) as
 184       // compile time constants.
 185       if (obj->is_Con()) {
 186         const TypeOopPtr* oop_ptr = obj->bottom_type()->isa_oopptr();
 187         ciObject* constant_oop = oop_ptr->const_oop();
 188         ciConstant constant = field->constant_value_of(constant_oop);
 189         if (FoldStableValues && field->is_stable() && constant.is_null_or_zero()) {
 190           // fall through to field load; the field is not yet initialized
 191         } else {
 192           if (push_constant(constant, true, false, stable_type))
 193             return;
 194         }
 195       }
 196     }
 197   }
 198 
 199   ciType* field_klass = field->type();
 200   bool is_vol = field->is_volatile();
 201 
 202   // Compute address and memory type.
 203   int offset = field->offset_in_bytes();
 204   const TypePtr* adr_type = C->alias_type(field)->adr_type();
 205   Node *adr = basic_plus_adr(obj, obj, offset);
 206   BasicType bt = field->layout_type();
 207 
 208   // Build the resultant type of the load
 209   const Type *type;
 210 
 211   bool must_assert_null = false;
 212 
 213   if( bt == T_OBJECT ) {
 214     if (!field->type()->is_loaded()) {
 215       type = TypeInstPtr::BOTTOM;
 216       must_assert_null = true;
 217     } else if (field->is_constant() && field->is_static()) {


 295     if (!field->type()->is_loaded()) {
 296       field_type = TypeInstPtr::BOTTOM;
 297     } else {
 298       field_type = TypeOopPtr::make_from_klass(field->type()->as_klass());
 299     }
 300     store = store_oop_to_object( control(), obj, adr, adr_type, val, field_type, bt);
 301   } else {
 302     store = store_to_memory( control(), adr, val, bt, adr_type, is_vol );
 303   }
 304 
 305   // If reference is volatile, prevent following volatiles ops from
 306   // floating up before the volatile write.
 307   if (is_vol) {
 308     insert_mem_bar(Op_MemBarVolatile); // Use fat membar
 309   }
 310 
 311   // If the field is final, the rules of Java say we are in <init> or <clinit>.
 312   // Note the presence of writes to final non-static fields, so that we
 313   // can insert a memory barrier later on to keep the writes from floating
 314   // out of the constructor.
 315   // Any method can write a @Stable field; insert memory barriers after those also.
 316   if (is_field && (field->is_final() || field->is_stable())) {
 317     set_wrote_final(true);
 318     // Preserve allocation ptr to create precedent edge to it in membar
 319     // generated on exit from constructor.
 320     if (C->eliminate_boxing() &&
 321         adr_type->isa_oopptr() && adr_type->is_oopptr()->is_ptr_to_boxed_value() &&
 322         AllocateNode::Ideal_allocation(obj, &_gvn) != NULL) {
 323       set_alloc_with_final(obj);
 324     }
 325   }
 326 }
 327 
 328 
 329 
 330 bool Parse::push_constant(ciConstant constant, bool require_constant, bool is_autobox_cache, const Type* stable_type) {
 331   const Type* con_type = Type::make_from_constant(constant, require_constant, is_autobox_cache);
 332   switch (constant.basic_type()) {








 333   case T_ARRAY:
 334   case T_OBJECT:
 335     // cases:
 336     //   can_be_constant    = (oop not scavengable || ScavengeRootsInCode != 0)
 337     //   should_be_constant = (oop not scavengable || ScavengeRootsInCode >= 2)
 338     // An oop is not scavengable if it is in the perm gen.
 339     if (stable_type != NULL && con_type != NULL && con_type->isa_oopptr())
 340       con_type = con_type->join(stable_type);

 341     break;
 342 
 343   case T_ILLEGAL:







 344     // Invalid ciConstant returned due to OutOfMemoryError in the CI
 345     assert(C->env()->failing(), "otherwise should not see this");
 346     // These always occur because of object types; we are going to
 347     // bail out anyway, so make the stack depths match up
 348     push( zerocon(T_OBJECT) );
 349     return false;
 350   }
 351 
 352   if (con_type == NULL)
 353     // we cannot inline the oop, but we can use it later to narrow a type
 354     return false;

 355 
 356   push_node(constant.basic_type(), makecon(con_type));
 357   return true;
 358 }
 359 
 360 

 361 //=============================================================================
 362 void Parse::do_anewarray() {
 363   bool will_link;
 364   ciKlass* klass = iter().get_klass(will_link);
 365 
 366   // Uncommon Trap when class that array contains is not loaded
 367   // we need the loaded class for the rest of graph; do not
 368   // initialize the container class (see Java spec)!!!
 369   assert(will_link, "anewarray: typeflow responsibility");
 370 
 371   ciObjArrayKlass* array_klass = ciObjArrayKlass::make(klass);
 372   // Check that array_klass object is loaded
 373   if (!array_klass->is_loaded()) {
 374     // Generate uncommon_trap for unloaded array_class
 375     uncommon_trap(Deoptimization::Reason_unloaded,
 376                   Deoptimization::Action_reinterpret,
 377                   array_klass);
 378     return;
 379   }
 380 


hotspot/src/share/vm/opto/parse3.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File