From 8029e7d0b5271823672c9189fee8ccd80bdc11b0 Mon Sep 17 00:00:00 2001 From: shade Date: Thu, 29 Oct 2015 14:08:19 +0300 Subject: [PATCH] 8140483: Atomic*FieldUpdaters final fields should be trusted Summary: Add exceptions for A*FU subclasses that do the actual work. Reviewed-by: jrose, vlivanov --- src/share/vm/ci/ciField.cpp | 8 ++++++++ src/share/vm/classfile/vmSymbols.hpp | 6 +++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/share/vm/ci/ciField.cpp b/src/share/vm/ci/ciField.cpp index 58c191710..7dd09a98e 100644 --- a/src/share/vm/ci/ciField.cpp +++ b/src/share/vm/ci/ciField.cpp @@ -187,6 +187,14 @@ static bool trust_final_non_static_fields(ciInstanceKlass* holder) { // Even if general trusting is disabled, trust system-built closures in these packages. if (holder->is_in_package("java/lang/invoke") || holder->is_in_package("sun/invoke")) 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; } diff --git a/src/share/vm/classfile/vmSymbols.hpp b/src/share/vm/classfile/vmSymbols.hpp index 0a84cb074..222d2b067 100644 --- a/src/share/vm/classfile/vmSymbols.hpp +++ b/src/share/vm/classfile/vmSymbols.hpp @@ -203,7 +203,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 */ \ -- GitLab