From 673ed3d8aedc5462a47ded827c99f35d46525457 Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Fri, 28 Aug 2015 14:56:43 -0700 Subject: Revert "Revert "Change dex caches to be weak roots"" This reverts commit 81a9087f0df0518c39405b7d18ba5858a6d8b77b. Boot.oat creation time goes from 4.7s to 4.9s on host due to extra locking. Will try to improve this in another CL. Bug: 23602225 Bug: 22720414 Change-Id: I7e25b75cfb63faa196c7b0f60e46cce50bf12021 --- runtime/java_vm_ext.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'runtime/java_vm_ext.cc') diff --git a/runtime/java_vm_ext.cc b/runtime/java_vm_ext.cc index 9d41018c1b..ef7a924c63 100644 --- a/runtime/java_vm_ext.cc +++ b/runtime/java_vm_ext.cc @@ -373,7 +373,7 @@ JavaVMExt::JavaVMExt(Runtime* runtime, const RuntimeArgumentMap& runtime_options globals_(gGlobalsInitial, gGlobalsMax, kGlobal), libraries_(new Libraries), unchecked_functions_(&gJniInvokeInterface), - weak_globals_lock_("JNI weak global reference table lock"), + weak_globals_lock_("JNI weak global reference table lock", kJniWeakGlobalsLock), weak_globals_(kWeakGlobalsInitial, kWeakGlobalsMax, kWeakGlobal), allow_new_weak_globals_(true), weak_globals_add_condition_("weak globals add condition", weak_globals_lock_) { @@ -578,6 +578,13 @@ void JavaVMExt::UpdateGlobal(Thread* self, IndirectRef ref, mirror::Object* resu mirror::Object* JavaVMExt::DecodeWeakGlobal(Thread* self, IndirectRef ref) { MutexLock mu(self, weak_globals_lock_); + return DecodeWeakGlobalLocked(self, ref); +} + +mirror::Object* JavaVMExt::DecodeWeakGlobalLocked(Thread* self, IndirectRef ref) { + if (kDebugLocking) { + weak_globals_lock_.AssertHeld(self); + } while (UNLIKELY((!kUseReadBarrier && !allow_new_weak_globals_) || (kUseReadBarrier && !self->GetWeakRefAccessEnabled()))) { weak_globals_add_condition_.WaitHoldingLocks(self); -- cgit v1.2.3-59-g8ed1b