196 // java.lang.invoke and sun.invoke packages and subpackages). 197 if (trust_final_non_static_fields(_holder)) { 198 _is_constant = true; 199 return; 200 } 201 _is_constant = false; 202 return; 203 } 204 205 // This field just may be constant. The only cases where it will 206 // not be constant are: 207 // 208 // 1. The field holds a non-perm-space oop. The field is, strictly 209 // speaking, constant but we cannot embed non-perm-space oops into 210 // generated code. For the time being we need to consider the 211 // field to be not constant. 212 // 2. The field is a *special* static&final field whose value 213 // may change. The three examples are java.lang.System.in, 214 // java.lang.System.out, and java.lang.System.err. 215 216 Handle k = _holder->get_klassOop(); 217 assert( SystemDictionary::System_klass() != NULL, "Check once per vm"); 218 if( k() == SystemDictionary::System_klass() ) { 219 // Check offsets for case 2: System.in, System.out, or System.err 220 if( _offset == java_lang_System::in_offset_in_bytes() || 221 _offset == java_lang_System::out_offset_in_bytes() || 222 _offset == java_lang_System::err_offset_in_bytes() ) { 223 _is_constant = false; 224 return; 225 } 226 } 227 228 _is_constant = true; 229 switch(type()->basic_type()) { 230 case T_BYTE: 231 _constant_value = ciConstant(type()->basic_type(), k->byte_field(_offset)); 232 break; 233 case T_CHAR: 234 _constant_value = ciConstant(type()->basic_type(), k->char_field(_offset)); 235 break; 236 case T_SHORT: 237 _constant_value = ciConstant(type()->basic_type(), k->short_field(_offset)); 238 break; 239 case T_BOOLEAN: 240 _constant_value = ciConstant(type()->basic_type(), k->bool_field(_offset)); 241 break; 242 case T_INT: 243 _constant_value = ciConstant(type()->basic_type(), k->int_field(_offset)); 244 break; 245 case T_FLOAT: 246 _constant_value = ciConstant(k->float_field(_offset)); 247 break; 248 case T_DOUBLE: 249 _constant_value = ciConstant(k->double_field(_offset)); 250 break; 251 case T_LONG: 252 _constant_value = ciConstant(k->long_field(_offset)); 253 break; 254 case T_OBJECT: 255 case T_ARRAY: 256 { 257 oop o = k->obj_field(_offset); 258 259 // A field will be "constant" if it is known always to be 260 // a non-null reference to an instance of a particular class, 261 // or to a particular array. This can happen even if the instance 262 // or array is not perm. In such a case, an "unloaded" ciArray 263 // or ciInstance is created. The compiler may be able to use 264 // information about the object's class (which is exact) or length. 265 266 if (o == NULL) { 267 _constant_value = ciConstant(type()->basic_type(), ciNullObject::make()); 268 } else { 269 _constant_value = ciConstant(type()->basic_type(), CURRENT_ENV->get_object(o)); 270 assert(_constant_value.as_object() == CURRENT_ENV->get_object(o), "check interning"); 271 } 272 } 273 } 274 } else { 275 _is_constant = false; 276 } 277 } | 196 // java.lang.invoke and sun.invoke packages and subpackages). 197 if (trust_final_non_static_fields(_holder)) { 198 _is_constant = true; 199 return; 200 } 201 _is_constant = false; 202 return; 203 } 204 205 // This field just may be constant. The only cases where it will 206 // not be constant are: 207 // 208 // 1. The field holds a non-perm-space oop. The field is, strictly 209 // speaking, constant but we cannot embed non-perm-space oops into 210 // generated code. For the time being we need to consider the 211 // field to be not constant. 212 // 2. The field is a *special* static&final field whose value 213 // may change. The three examples are java.lang.System.in, 214 // java.lang.System.out, and java.lang.System.err. 215 216 KlassHandle k = _holder->get_klassOop(); 217 assert( SystemDictionary::System_klass() != NULL, "Check once per vm"); 218 if( k() == SystemDictionary::System_klass() ) { 219 // Check offsets for case 2: System.in, System.out, or System.err 220 if( _offset == java_lang_System::in_offset_in_bytes() || 221 _offset == java_lang_System::out_offset_in_bytes() || 222 _offset == java_lang_System::err_offset_in_bytes() ) { 223 _is_constant = false; 224 return; 225 } 226 } 227 228 Handle mirror = k->java_mirror(); 229 230 _is_constant = true; 231 switch(type()->basic_type()) { 232 case T_BYTE: 233 _constant_value = ciConstant(type()->basic_type(), mirror->byte_field(_offset)); 234 break; 235 case T_CHAR: 236 _constant_value = ciConstant(type()->basic_type(), mirror->char_field(_offset)); 237 break; 238 case T_SHORT: 239 _constant_value = ciConstant(type()->basic_type(), mirror->short_field(_offset)); 240 break; 241 case T_BOOLEAN: 242 _constant_value = ciConstant(type()->basic_type(), mirror->bool_field(_offset)); 243 break; 244 case T_INT: 245 _constant_value = ciConstant(type()->basic_type(), mirror->int_field(_offset)); 246 break; 247 case T_FLOAT: 248 _constant_value = ciConstant(mirror->float_field(_offset)); 249 break; 250 case T_DOUBLE: 251 _constant_value = ciConstant(mirror->double_field(_offset)); 252 break; 253 case T_LONG: 254 _constant_value = ciConstant(mirror->long_field(_offset)); 255 break; 256 case T_OBJECT: 257 case T_ARRAY: 258 { 259 oop o = mirror->obj_field(_offset); 260 261 // A field will be "constant" if it is known always to be 262 // a non-null reference to an instance of a particular class, 263 // or to a particular array. This can happen even if the instance 264 // or array is not perm. In such a case, an "unloaded" ciArray 265 // or ciInstance is created. The compiler may be able to use 266 // information about the object's class (which is exact) or length. 267 268 if (o == NULL) { 269 _constant_value = ciConstant(type()->basic_type(), ciNullObject::make()); 270 } else { 271 _constant_value = ciConstant(type()->basic_type(), CURRENT_ENV->get_object(o)); 272 assert(_constant_value.as_object() == CURRENT_ENV->get_object(o), "check interning"); 273 } 274 } 275 } 276 } else { 277 _is_constant = false; 278 } 279 } |