summaryrefslogtreecommitdiff
path: root/runtime/java_vm_ext.h
diff options
context:
space:
mode:
author Mathieu Chartier <mathieuc@google.com> 2015-09-02 03:03:01 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2015-09-02 03:03:01 +0000
commit91a359fc20f82adbe46154ca17db3cb14cd747a1 (patch)
tree4bd24888ed58827dabe40d849639100205d83e2a /runtime/java_vm_ext.h
parent4d169121fa7c09be2e4d314c1699c3639973ac49 (diff)
parent30b5e27083913bb711fca0ca89a941797fcf3d5d (diff)
Merge "Enable lockless decoding of weak globals"
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);