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

src/share/vm/opto/parse3.cpp

Print this page




 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 (push_constant(field->constant_value()))
 154         return;
 155     }
 156     else {
 157       // final non-static field
 158       // Treat final non-static fields of trusted classes (classes in
 159       // java.lang.invoke and sun.invoke packages and subpackages) as
 160       // compile time constants.
 161       if (obj->is_Con()) {
 162         const TypeOopPtr* oop_ptr = obj->bottom_type()->isa_oopptr();
 163         ciObject* constant_oop = oop_ptr->const_oop();
 164         ciConstant constant = field->constant_value_of(constant_oop);
 165         if (push_constant(constant, true))
 166           return;
 167       }
 168     }
 169   }
 170 
 171   ciType* field_klass = field->type();
 172   bool is_vol = field->is_volatile();


 287     // volatile alias indices. Skip this if the membar is redundant.
 288     if (adr_idx != Compile::AliasIdxBot) {
 289       insert_mem_bar_volatile(Op_MemBarVolatile, Compile::AliasIdxBot, store);
 290     }
 291 
 292     // Finally, place alias-index-specific membars for each volatile index
 293     // that isn't the adr_idx membar. Typically there's only 1 or 2.
 294     for( int i = Compile::AliasIdxRaw; i < C->num_alias_types(); i++ ) {
 295       if (i != adr_idx && C->alias_type(i)->is_volatile()) {
 296         insert_mem_bar_volatile(Op_MemBarVolatile, i, store);
 297       }
 298     }
 299   }
 300 
 301   // If the field is final, the rules of Java say we are in <init> or <clinit>.
 302   // Note the presence of writes to final non-static fields, so that we
 303   // can insert a memory barrier later on to keep the writes from floating
 304   // out of the constructor.
 305   if (is_field && field->is_final()) {
 306     set_wrote_final(true);







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




 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_autobox()) {
 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();


 304     // volatile alias indices. Skip this if the membar is redundant.
 305     if (adr_idx != Compile::AliasIdxBot) {
 306       insert_mem_bar_volatile(Op_MemBarVolatile, Compile::AliasIdxBot, store);
 307     }
 308 
 309     // Finally, place alias-index-specific membars for each volatile index
 310     // that isn't the adr_idx membar. Typically there's only 1 or 2.
 311     for( int i = Compile::AliasIdxRaw; i < C->num_alias_types(); i++ ) {
 312       if (i != adr_idx && C->alias_type(i)->is_volatile()) {
 313         insert_mem_bar_volatile(Op_MemBarVolatile, i, store);
 314       }
 315     }
 316   }
 317 
 318   // If the field is final, the rules of Java say we are in <init> or <clinit>.
 319   // Note the presence of writes to final non-static fields, so that we
 320   // can insert a memory barrier later on to keep the writes from floating
 321   // out of the constructor.
 322   if (is_field && field->is_final()) {
 323     set_wrote_final(true);
 324     // Preserve allocation ptr to create precedent edge to it in membar
 325     // generated on exit from constructor.
 326     if (C->eliminate_autobox() &&
 327         adr_type->isa_oopptr() && adr_type->is_oopptr()->is_ptr_to_boxed_value() &&
 328         AllocateNode::Ideal_allocation(obj, &_gvn) != NULL) {
 329       set_alloc_with_final(obj);
 330     }
 331   }
 332 }
 333 
 334 
 335 bool Parse::push_constant(ciConstant constant, bool require_constant, bool is_autobox_cache) {
 336   switch (constant.basic_type()) {
 337   case T_BOOLEAN:  push( intcon(constant.as_boolean()) ); break;
 338   case T_INT:      push( intcon(constant.as_int())     ); break;
 339   case T_CHAR:     push( intcon(constant.as_char())    ); break;
 340   case T_BYTE:     push( intcon(constant.as_byte())    ); break;
 341   case T_SHORT:    push( intcon(constant.as_short())   ); break;
 342   case T_FLOAT:    push( makecon(TypeF::make(constant.as_float())) );  break;
 343   case T_DOUBLE:   push_pair( makecon(TypeD::make(constant.as_double())) );  break;
 344   case T_LONG:     push_pair( longcon(constant.as_long()) ); break;
 345   case T_ARRAY:
 346   case T_OBJECT: {
 347     // cases:
 348     //   can_be_constant    = (oop not scavengable || ScavengeRootsInCode != 0)
 349     //   should_be_constant = (oop not scavengable || ScavengeRootsInCode >= 2)
 350     // An oop is not scavengable if it is in the perm gen.
 351     ciObject* oop_constant = constant.as_object();
 352     if (oop_constant->is_null_object()) {
 353       push( zerocon(T_OBJECT) );
 354       break;
 355     } else if (require_constant || oop_constant->should_be_constant()) {
 356       push( makecon(TypeOopPtr::make_from_constant(oop_constant, require_constant, is_autobox_cache)) );
 357       break;
 358     } else {
 359       // we cannot inline the oop, but we can use it later to narrow a type
 360       return false;
 361     }
 362   }
 363   case T_ILLEGAL: {
 364     // Invalid ciConstant returned due to OutOfMemoryError in the CI
 365     assert(C->env()->failing(), "otherwise should not see this");
 366     // These always occur because of object types; we are going to
 367     // bail out anyway, so make the stack depths match up
 368     push( zerocon(T_OBJECT) );
 369     return false;
 370   }
 371   default:
 372     ShouldNotReachHere();
 373     return false;
 374   }
 375 
 376   // success


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