hotspot/src/share/vm/opto/parse3.cpp
changeset 3908 24b55ad4c228
parent 3261 c7d5aae8d3f7
child 4470 1e6edcab3109
equal deleted inserted replaced
3906:6767b0c66883 3908:24b55ad4c228
   265     set_wrote_final(true);
   265     set_wrote_final(true);
   266   }
   266   }
   267 }
   267 }
   268 
   268 
   269 
   269 
   270 bool Parse::push_constant(ciConstant constant) {
   270 bool Parse::push_constant(ciConstant constant, bool require_constant) {
   271   switch (constant.basic_type()) {
   271   switch (constant.basic_type()) {
   272   case T_BOOLEAN:  push( intcon(constant.as_boolean()) ); break;
   272   case T_BOOLEAN:  push( intcon(constant.as_boolean()) ); break;
   273   case T_INT:      push( intcon(constant.as_int())     ); break;
   273   case T_INT:      push( intcon(constant.as_int())     ); break;
   274   case T_CHAR:     push( intcon(constant.as_char())    ); break;
   274   case T_CHAR:     push( intcon(constant.as_char())    ); break;
   275   case T_BYTE:     push( intcon(constant.as_byte())    ); break;
   275   case T_BYTE:     push( intcon(constant.as_byte())    ); break;
   277   case T_FLOAT:    push( makecon(TypeF::make(constant.as_float())) );  break;
   277   case T_FLOAT:    push( makecon(TypeF::make(constant.as_float())) );  break;
   278   case T_DOUBLE:   push_pair( makecon(TypeD::make(constant.as_double())) );  break;
   278   case T_DOUBLE:   push_pair( makecon(TypeD::make(constant.as_double())) );  break;
   279   case T_LONG:     push_pair( longcon(constant.as_long()) ); break;
   279   case T_LONG:     push_pair( longcon(constant.as_long()) ); break;
   280   case T_ARRAY:
   280   case T_ARRAY:
   281   case T_OBJECT: {
   281   case T_OBJECT: {
   282     // the oop is in perm space if the ciObject "has_encoding"
   282     // cases:
       
   283     //   can_be_constant    = (oop not scavengable || ScavengeRootsInCode != 0)
       
   284     //   should_be_constant = (oop not scavengable || ScavengeRootsInCode >= 2)
       
   285     // An oop is not scavengable if it is in the perm gen.
   283     ciObject* oop_constant = constant.as_object();
   286     ciObject* oop_constant = constant.as_object();
   284     if (oop_constant->is_null_object()) {
   287     if (oop_constant->is_null_object()) {
   285       push( zerocon(T_OBJECT) );
   288       push( zerocon(T_OBJECT) );
   286       break;
   289       break;
   287     } else if (oop_constant->has_encoding()) {
   290     } else if (require_constant || oop_constant->should_be_constant()) {
   288       push( makecon(TypeOopPtr::make_from_constant(oop_constant)) );
   291       push( makecon(TypeOopPtr::make_from_constant(oop_constant, require_constant)) );
   289       break;
   292       break;
   290     } else {
   293     } else {
   291       // we cannot inline the oop, but we can use it later to narrow a type
   294       // we cannot inline the oop, but we can use it later to narrow a type
   292       return false;
   295       return false;
   293     }
   296     }