summaryrefslogtreecommitdiff
path: root/runtime/java_vm_ext.h
diff options
context:
space:
mode:
author Mathieu Chartier <mathieuc@google.com> 2015-09-01 11:14:34 -0700
committer Mathieu Chartier <mathieuc@google.com> 2015-09-01 19:46:40 -0700
commit30b5e27083913bb711fca0ca89a941797fcf3d5d (patch)
treec0b5229955f580d8ef928433c5e7bc372c70c3aa /runtime/java_vm_ext.h
parentb52cfcb3868d08102b4c971974a7b1443861a90c (diff)
Enable lockless decoding of weak globals
Will help speed up decoding weak DexCache roots. Change-Id: I9a68beb4106cbd383111a30e249c9b0149064e78
Diffstat (limited to 'runtime/java_vm_ext.h')
-rw-r--r--runtime/java_vm_ext.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/runtime/java_vm_ext.h b/runtime/java_vm_ext.h
index e80266fd5d..d68a85f230 100644
--- a/runtime/java_vm_ext.h
+++ b/runtime/java_vm_ext.h
@@ -126,7 +126,7 @@ class JavaVMExt : public JavaVM {
void SweepJniWeakGlobals(IsMarkedVisitor* visitor)
SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!weak_globals_lock_);
- mirror::Object* DecodeGlobal(Thread* self, IndirectRef ref)
+ mirror::Object* DecodeGlobal(IndirectRef ref)
SHARED_REQUIRES(Locks::mutator_lock_);
void UpdateGlobal(Thread* self, IndirectRef ref, mirror::Object* result)
@@ -155,6 +155,12 @@ class JavaVMExt : public JavaVM {
REQUIRES(!globals_lock_);
private:
+ // Return true if self can currently access weak globals.
+ bool MayAccessWeakGlobalsUnlocked(Thread* self) const SHARED_REQUIRES(Locks::mutator_lock_);
+ bool MayAccessWeakGlobals(Thread* self) const
+ SHARED_REQUIRES(Locks::mutator_lock_)
+ REQUIRES(weak_globals_lock_);
+
Runtime* const runtime_;
// Used for testing. By default, we'll LOG(FATAL) the reason.
@@ -184,8 +190,10 @@ class JavaVMExt : public JavaVM {
// Since weak_globals_ contain weak roots, be careful not to
// directly access the object references in it. Use Get() with the
// read barrier enabled.
- IndirectReferenceTable weak_globals_ GUARDED_BY(weak_globals_lock_);
- bool allow_new_weak_globals_ GUARDED_BY(weak_globals_lock_);
+ // Not guarded by weak_globals_lock since we may use SynchronizedGet in DecodeWeakGlobal.
+ IndirectReferenceTable weak_globals_;
+ // Not guarded by weak_globals_lock since we may use SynchronizedGet in DecodeWeakGlobal.
+ Atomic<bool> allow_accessing_weak_globals_;
ConditionVariable weak_globals_add_condition_ GUARDED_BY(weak_globals_lock_);
DISALLOW_COPY_AND_ASSIGN(JavaVMExt);