diff options
author | 2022-02-08 12:01:07 +0000 | |
---|---|---|
committer | 2022-02-17 09:56:13 +0000 | |
commit | 5f958f61f405609646109a37449858e9836f7f36 (patch) | |
tree | de989f3f6e4a6a726c31004c28c14f944d8fabd2 /runtime/jni/java_vm_ext.cc | |
parent | ac8751516930ed941ada8c5f552dabd0eb62808c (diff) |
Avoid unnecessary read barriers in `ImageWriter`.
Also avoid visiting native roots during the same stages,
namely layout and writing (including copy-and-fixup).
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Bug: 181943478
Change-Id: I0d62d67556109dbcbd8a04fd0e8408733dacce33
Diffstat (limited to 'runtime/jni/java_vm_ext.cc')
-rw-r--r-- | runtime/jni/java_vm_ext.cc | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/runtime/jni/java_vm_ext.cc b/runtime/jni/java_vm_ext.cc index df7375b67a..f4a47ebcb4 100644 --- a/runtime/jni/java_vm_ext.cc +++ b/runtime/jni/java_vm_ext.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "java_vm_ext.h" +#include "java_vm_ext-inl.h" #include <dlfcn.h> #include <string_view> @@ -834,17 +834,6 @@ void JavaVMExt::UpdateGlobal(Thread* self, IndirectRef ref, ObjPtr<mirror::Objec globals_.Update(ref, result); } -inline bool JavaVMExt::MayAccessWeakGlobals(Thread* self) const { - return MayAccessWeakGlobalsUnlocked(self); -} - -inline bool JavaVMExt::MayAccessWeakGlobalsUnlocked(Thread* self) const { - DCHECK(self != nullptr); - return kUseReadBarrier ? - self->GetWeakRefAccessEnabled() : - allow_accessing_weak_globals_.load(std::memory_order_seq_cst); -} - ObjPtr<mirror::Object> JavaVMExt::DecodeWeakGlobal(Thread* self, IndirectRef ref) { // It is safe to access GetWeakRefAccessEnabled without the lock since CC uses checkpoints to call // SetWeakRefAccessEnabled, and the other collectors only modify allow_accessing_weak_globals_ @@ -853,7 +842,7 @@ ObjPtr<mirror::Object> JavaVMExt::DecodeWeakGlobal(Thread* self, IndirectRef ref // case, it may be racy, this is benign since DecodeWeakGlobalLocked does the correct behavior // if MayAccessWeakGlobals is false. DCHECK_EQ(IndirectReferenceTable::GetIndirectRefKind(ref), kWeakGlobal); - if (LIKELY(MayAccessWeakGlobalsUnlocked(self))) { + if (LIKELY(MayAccessWeakGlobals(self))) { return weak_globals_.SynchronizedGet(ref); } MutexLock mu(self, *Locks::jni_weak_globals_lock_); |