8140483: Atomic*FieldUpdaters final fields should be trusted
authorshade
Thu, 29 Oct 2015 14:08:19 +0300
changeset 33483 5b7dd5bd7c5c
parent 33480 e4cef6796874
child 33484 19436533aef1
8140483: Atomic*FieldUpdaters final fields should be trusted Summary: Add exceptions for A*FU subclasses that do the actual work. Reviewed-by: jrose, vlivanov
hotspot/src/share/vm/ci/ciField.cpp
hotspot/src/share/vm/classfile/vmSymbols.hpp
--- a/hotspot/src/share/vm/ci/ciField.cpp	Thu Oct 29 09:24:00 2015 +0100
+++ b/hotspot/src/share/vm/ci/ciField.cpp	Thu Oct 29 14:08:19 2015 +0300
@@ -190,6 +190,14 @@
   // so there is no hacking of finals going on with them.
   if (holder->is_anonymous())
     return true;
+  // Trust Atomic*FieldUpdaters: they are very important for performance, and make up one
+  // more reason not to use Unsafe, if their final fields are trusted. See more in JDK-8140483.
+  if (holder->name() == ciSymbol::java_util_concurrent_atomic_AtomicIntegerFieldUpdater_Impl() ||
+      holder->name() == ciSymbol::java_util_concurrent_atomic_AtomicLongFieldUpdater_CASUpdater() ||
+      holder->name() == ciSymbol::java_util_concurrent_atomic_AtomicLongFieldUpdater_LockedUpdater() ||
+      holder->name() == ciSymbol::java_util_concurrent_atomic_AtomicReferenceFieldUpdater_Impl()) {
+    return true;
+  }
   return TrustFinalNonStaticFields;
 }
 
--- a/hotspot/src/share/vm/classfile/vmSymbols.hpp	Thu Oct 29 09:24:00 2015 +0100
+++ b/hotspot/src/share/vm/classfile/vmSymbols.hpp	Thu Oct 29 14:08:19 2015 +0300
@@ -202,7 +202,11 @@
   template(java_lang_StackTraceElement,               "java/lang/StackTraceElement")              \
                                                                                                   \
   /* Concurrency support */                                                                       \
-  template(java_util_concurrent_locks_AbstractOwnableSynchronizer,   "java/util/concurrent/locks/AbstractOwnableSynchronizer") \
+  template(java_util_concurrent_locks_AbstractOwnableSynchronizer,           "java/util/concurrent/locks/AbstractOwnableSynchronizer") \
+  template(java_util_concurrent_atomic_AtomicIntegerFieldUpdater_Impl,       "java/util/concurrent/atomic/AtomicIntegerFieldUpdater$AtomicIntegerFieldUpdaterImpl") \
+  template(java_util_concurrent_atomic_AtomicLongFieldUpdater_CASUpdater,    "java/util/concurrent/atomic/AtomicLongFieldUpdater$CASUpdater") \
+  template(java_util_concurrent_atomic_AtomicLongFieldUpdater_LockedUpdater, "java/util/concurrent/atomic/AtomicLongFieldUpdater$LockedUpdater") \
+  template(java_util_concurrent_atomic_AtomicReferenceFieldUpdater_Impl,     "java/util/concurrent/atomic/AtomicReferenceFieldUpdater$AtomicReferenceFieldUpdaterImpl") \
   template(sun_misc_Contended_signature,              "Lsun/misc/Contended;")                     \
                                                                                                   \
   /* class symbols needed by intrinsics */                                                        \