< prev index next >

src/hotspot/share/ci/ciField.cpp

Print this page
rev 58565 : 8238358: Implementation of JEP 371: Hidden Classes
Reviewed-by: duke
Contributed-by: mandy.chung@oracle.com, lois.foltan@oracle.com, david.holmes@oracle.com, harold.seigel@oracle.com, serguei.spitsyn@oracle.com, alex.buckley@oracle.com, jamsheed.c.m@oracle.com


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




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


< prev index next >