< prev index next >

src/hotspot/share/ci/ciField.cpp

Print this page




 205   } else {
 206     _type = ciType::make(field_type);
 207   }
 208 
 209   initialize_from(fd);
 210 
 211   // Either (a) it is marked shared, or else (b) we are done bootstrapping.
 212   assert(is_shared() || ciObjectFactory::is_initialized(),
 213          "bootstrap classes must not create & cache unshared fields");
 214 }
 215 
 216 static bool trust_final_non_static_fields(ciInstanceKlass* holder) {
 217   if (holder == NULL)
 218     return false;
 219   if (holder->name() == ciSymbol::java_lang_System())
 220     // Never trust strangely unstable finals:  System.out, etc.
 221     return false;
 222   // Even if general trusting is disabled, trust system-built closures in these packages.
 223   if (holder->is_in_package("java/lang/invoke") || holder->is_in_package("sun/invoke"))
 224     return true;
 225   // Trust VM unsafe anonymous classes. They are private API (jdk.internal.misc.Unsafe)
 226   // and can't be serialized, so there is no hacking of finals going on with them.
 227   if (holder->is_unsafe_anonymous())

 228     return true;
 229   // Trust final fields in all boxed classes
 230   if (holder->is_box_klass())
 231     return true;
 232   // Trust final fields in String
 233   if (holder->name() == ciSymbol::java_lang_String())
 234     return true;
 235   // Trust Atomic*FieldUpdaters: they are very important for performance, and make up one
 236   // more reason not to use Unsafe, if their final fields are trusted. See more in JDK-8140483.
 237   if (holder->name() == ciSymbol::java_util_concurrent_atomic_AtomicIntegerFieldUpdater_Impl() ||
 238       holder->name() == ciSymbol::java_util_concurrent_atomic_AtomicLongFieldUpdater_CASUpdater() ||
 239       holder->name() == ciSymbol::java_util_concurrent_atomic_AtomicLongFieldUpdater_LockedUpdater() ||
 240       holder->name() == ciSymbol::java_util_concurrent_atomic_AtomicReferenceFieldUpdater_Impl()) {
 241     return true;
 242   }
 243   return TrustFinalNonStaticFields;
 244 }
 245 
 246 void ciField::initialize_from(fieldDescriptor* fd) {
 247   // Get the flags, offset, and canonical holder of the field.




 205   } else {
 206     _type = ciType::make(field_type);
 207   }
 208 
 209   initialize_from(fd);
 210 
 211   // Either (a) it is marked shared, or else (b) we are done bootstrapping.
 212   assert(is_shared() || ciObjectFactory::is_initialized(),
 213          "bootstrap classes must not create & cache unshared fields");
 214 }
 215 
 216 static bool trust_final_non_static_fields(ciInstanceKlass* holder) {
 217   if (holder == NULL)
 218     return false;
 219   if (holder->name() == ciSymbol::java_lang_System())
 220     // Never trust strangely unstable finals:  System.out, etc.
 221     return false;
 222   // Even if general trusting is disabled, trust system-built closures in these packages.
 223   if (holder->is_in_package("java/lang/invoke") || holder->is_in_package("sun/invoke"))
 224     return true;
 225   // Trust VM nonfindable and unsafe anonymous classes. They are created via Lookup.defineClass or
 226   // the private API (jdk.internal.misc.Unsafe) and can't be serialized, so there is no hacking
 227   // of finals going on with them.
 228   if (holder->is_nonfindable() || holder->is_unsafe_anonymous())
 229     return true;
 230   // Trust final fields in all boxed classes
 231   if (holder->is_box_klass())
 232     return true;
 233   // Trust final fields in String
 234   if (holder->name() == ciSymbol::java_lang_String())
 235     return true;
 236   // Trust Atomic*FieldUpdaters: they are very important for performance, and make up one
 237   // more reason not to use Unsafe, if their final fields are trusted. See more in JDK-8140483.
 238   if (holder->name() == ciSymbol::java_util_concurrent_atomic_AtomicIntegerFieldUpdater_Impl() ||
 239       holder->name() == ciSymbol::java_util_concurrent_atomic_AtomicLongFieldUpdater_CASUpdater() ||
 240       holder->name() == ciSymbol::java_util_concurrent_atomic_AtomicLongFieldUpdater_LockedUpdater() ||
 241       holder->name() == ciSymbol::java_util_concurrent_atomic_AtomicReferenceFieldUpdater_Impl()) {
 242     return true;
 243   }
 244   return TrustFinalNonStaticFields;
 245 }
 246 
 247 void ciField::initialize_from(fieldDescriptor* fd) {
 248   // Get the flags, offset, and canonical holder of the field.


< prev index next >