< prev index next >

src/share/vm/opto/parse3.cpp

Print this page




 132     } else {
 133       do_put_xxx(obj, field, is_field);
 134       (void) pop();  // pop receiver after putting
 135     }
 136   } else {
 137     const TypeInstPtr* tip = TypeInstPtr::make(field_holder->java_mirror());
 138     obj = _gvn.makecon(tip);
 139     if (is_get) {
 140       do_get_xxx(obj, field, is_field);
 141     } else {
 142       do_put_xxx(obj, field, is_field);
 143     }
 144   }
 145 }
 146 
 147 
 148 void Parse::do_get_xxx(Node* obj, ciField* field, bool is_field) {
 149   // Does this field have a constant value?  If so, just push the value.
 150   if (field->is_constant()) {
 151     // final or stable field
 152     const Type* stable_type = NULL;
 153     if (FoldStableValues && field->is_stable()) {
 154       stable_type = Type::get_const_type(field->type());
 155       if (field->type()->is_array_klass()) {
 156         int stable_dimension = field->type()->as_array_klass()->dimension();
 157         stable_type = stable_type->is_aryptr()->cast_to_stable(true, stable_dimension);
 158       }
 159     }
 160     if (field->is_static()) {
 161       // final static field
 162       if (C->eliminate_boxing()) {
 163         // The pointers in the autobox arrays are always non-null.
 164         ciSymbol* klass_name = field->holder()->name();
 165         if (field->name() == ciSymbol::cache_field_name() &&
 166             field->holder()->uses_default_loader() &&
 167             (klass_name == ciSymbol::java_lang_Character_CharacterCache() ||
 168              klass_name == ciSymbol::java_lang_Byte_ByteCache() ||
 169              klass_name == ciSymbol::java_lang_Short_ShortCache() ||
 170              klass_name == ciSymbol::java_lang_Integer_IntegerCache() ||
 171              klass_name == ciSymbol::java_lang_Long_LongCache())) {
 172           bool require_const = true;
 173           bool autobox_cache = true;
 174           if (push_constant(field->constant_value(), require_const, autobox_cache)) {
 175             return;
 176           }
 177         }
 178       }
 179       if (push_constant(field->constant_value(), false, false, stable_type))
 180         return;
 181     } else {
 182       // final or stable non-static field
 183       // Treat final non-static fields of trusted classes (classes in
 184       // java.lang.invoke and sun.invoke packages and subpackages) as
 185       // compile time constants.
 186       if (obj->is_Con()) {
 187         const TypeOopPtr* oop_ptr = obj->bottom_type()->isa_oopptr();
 188         ciObject* constant_oop = oop_ptr->const_oop();
 189         ciConstant constant = field->constant_value_of(constant_oop);
 190         if (FoldStableValues && field->is_stable() && constant.is_null_or_zero()) {
 191           // fall through to field load; the field is not yet initialized
 192         } else {
 193           if (push_constant(constant, true, false, stable_type))
 194             return;
 195         }
 196       }
 197     }
 198   }
 199 
 200   ciType* field_klass = field->type();
 201   bool is_vol = field->is_volatile();
 202 
 203   // Compute address and memory type.
 204   int offset = field->offset_in_bytes();
 205   const TypePtr* adr_type = C->alias_type(field)->adr_type();
 206   Node *adr = basic_plus_adr(obj, obj, offset);
 207   BasicType bt = field->layout_type();
 208 
 209   // Build the resultant type of the load
 210   const Type *type;
 211 
 212   bool must_assert_null = false;
 213 
 214   if( bt == T_OBJECT ) {
 215     if (!field->type()->is_loaded()) {
 216       type = TypeInstPtr::BOTTOM;
 217       must_assert_null = true;
 218     } else if (field->is_constant() && field->is_static()) {


 345   // out of the constructor.
 346   // Any method can write a @Stable field; insert memory barriers after those also.
 347   if (is_field && (field->is_final() || field->is_stable())) {
 348     if (field->is_final()) {
 349         set_wrote_final(true);
 350     }
 351     if (field->is_stable()) {
 352         set_wrote_stable(true);
 353     }
 354 
 355     // Preserve allocation ptr to create precedent edge to it in membar
 356     // generated on exit from constructor.
 357     if (C->eliminate_boxing() &&
 358         adr_type->isa_oopptr() && adr_type->is_oopptr()->is_ptr_to_boxed_value() &&
 359         AllocateNode::Ideal_allocation(obj, &_gvn) != NULL) {
 360       set_alloc_with_final(obj);
 361     }
 362   }
 363 }
 364 
 365 
 366 
 367 bool Parse::push_constant(ciConstant constant, bool require_constant, bool is_autobox_cache, const Type* stable_type) {
 368   const Type* con_type = Type::make_from_constant(constant, require_constant, is_autobox_cache);
 369   switch (constant.basic_type()) {
 370   case T_ARRAY:
 371   case T_OBJECT:
 372     // cases:
 373     //   can_be_constant    = (oop not scavengable || ScavengeRootsInCode != 0)
 374     //   should_be_constant = (oop not scavengable || ScavengeRootsInCode >= 2)
 375     // An oop is not scavengable if it is in the perm gen.
 376     if (stable_type != NULL && con_type != NULL && con_type->isa_oopptr())
 377       con_type = con_type->join_speculative(stable_type);
 378     break;
 379 
 380   case T_ILLEGAL:
 381     // Invalid ciConstant returned due to OutOfMemoryError in the CI
 382     assert(C->env()->failing(), "otherwise should not see this");
 383     // These always occur because of object types; we are going to
 384     // bail out anyway, so make the stack depths match up
 385     push( zerocon(T_OBJECT) );
 386     return false;
 387   }
 388 
 389   if (con_type == NULL)
 390     // we cannot inline the oop, but we can use it later to narrow a type
 391     return false;
 392 
 393   push_node(constant.basic_type(), makecon(con_type));
 394   return true;
 395 }
 396 
 397 
 398 //=============================================================================
 399 void Parse::do_anewarray() {
 400   bool will_link;
 401   ciKlass* klass = iter().get_klass(will_link);
 402 
 403   // Uncommon Trap when class that array contains is not loaded
 404   // we need the loaded class for the rest of graph; do not
 405   // initialize the container class (see Java spec)!!!
 406   assert(will_link, "anewarray: typeflow responsibility");
 407 
 408   ciObjArrayKlass* array_klass = ciObjArrayKlass::make(klass);
 409   // Check that array_klass object is loaded
 410   if (!array_klass->is_loaded()) {
 411     // Generate uncommon_trap for unloaded array_class
 412     uncommon_trap(Deoptimization::Reason_unloaded,
 413                   Deoptimization::Action_reinterpret,
 414                   array_klass);
 415     return;
 416   }
 417 




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




















 155       return;
 156     }
 157   }





















 158   
 159   ciType* field_klass = field->type();
 160   bool is_vol = field->is_volatile();
 161 
 162   // Compute address and memory type.
 163   int offset = field->offset_in_bytes();
 164   const TypePtr* adr_type = C->alias_type(field)->adr_type();
 165   Node *adr = basic_plus_adr(obj, obj, offset);
 166   BasicType bt = field->layout_type();
 167 
 168   // Build the resultant type of the load
 169   const Type *type;
 170 
 171   bool must_assert_null = false;
 172 
 173   if( bt == T_OBJECT ) {
 174     if (!field->type()->is_loaded()) {
 175       type = TypeInstPtr::BOTTOM;
 176       must_assert_null = true;
 177     } else if (field->is_constant() && field->is_static()) {


 304   // out of the constructor.
 305   // Any method can write a @Stable field; insert memory barriers after those also.
 306   if (is_field && (field->is_final() || field->is_stable())) {
 307     if (field->is_final()) {
 308         set_wrote_final(true);
 309     }
 310     if (field->is_stable()) {
 311         set_wrote_stable(true);
 312     }
 313 
 314     // Preserve allocation ptr to create precedent edge to it in membar
 315     // generated on exit from constructor.
 316     if (C->eliminate_boxing() &&
 317         adr_type->isa_oopptr() && adr_type->is_oopptr()->is_ptr_to_boxed_value() &&
 318         AllocateNode::Ideal_allocation(obj, &_gvn) != NULL) {
 319       set_alloc_with_final(obj);
 320     }
 321   }
 322 }
 323 

































 324 //=============================================================================
 325 void Parse::do_anewarray() {
 326   bool will_link;
 327   ciKlass* klass = iter().get_klass(will_link);
 328 
 329   // Uncommon Trap when class that array contains is not loaded
 330   // we need the loaded class for the rest of graph; do not
 331   // initialize the container class (see Java spec)!!!
 332   assert(will_link, "anewarray: typeflow responsibility");
 333 
 334   ciObjArrayKlass* array_klass = ciObjArrayKlass::make(klass);
 335   // Check that array_klass object is loaded
 336   if (!array_klass->is_loaded()) {
 337     // Generate uncommon_trap for unloaded array_class
 338     uncommon_trap(Deoptimization::Reason_unloaded,
 339                   Deoptimization::Action_reinterpret,
 340                   array_klass);
 341     return;
 342   }
 343 


< prev index next >