diff options
author | Hiroshi Yamauchi <yamauchi@google.com> | 2014-05-29 12:16:04 -0700 |
---|---|---|
committer | Hiroshi Yamauchi <yamauchi@google.com> | 2014-05-29 12:37:49 -0700 |
commit | 196851b634a5bfdd8ab3fb59a320e550b21b0f4d (patch) | |
tree | f9fca2858b6213163d358c2eb2b2f88aa88a027b /runtime/thread.cc | |
parent | ea0b6e284cab12eed88eebf6aa19e6292af57389 (diff) | |
download | art-196851b634a5bfdd8ab3fb59a320e550b21b0f4d.zip art-196851b634a5bfdd8ab3fb59a320e550b21b0f4d.tar.gz art-196851b634a5bfdd8ab3fb59a320e550b21b0f4d.tar.bz2 |
Add read barriers for the weak roots in the JNI weak globals.
Bug: 12687968
Change-Id: Ic265a0e162e8cc9edc4ab7fa34f8afd5ce968d08
Diffstat (limited to 'runtime/thread.cc')
-rw-r--r-- | runtime/thread.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/runtime/thread.cc b/runtime/thread.cc index 55bec1e..1355aa1 100644 --- a/runtime/thread.cc +++ b/runtime/thread.cc @@ -1253,7 +1253,8 @@ mirror::Object* Thread::DecodeJObject(jobject obj) const { // The "kinds" below are sorted by the frequency we expect to encounter them. if (kind == kLocal) { IndirectReferenceTable& locals = tlsPtr_.jni_env->locals; - result = locals.Get(ref); + // Local references do not need a read barrier. + result = locals.Get<kWithoutReadBarrier>(ref); } else if (kind == kHandleScopeOrInvalid) { // TODO: make stack indirect reference table lookup more efficient. // Check if this is a local reference in the handle scope. @@ -1266,7 +1267,9 @@ mirror::Object* Thread::DecodeJObject(jobject obj) const { } } else if (kind == kGlobal) { JavaVMExt* const vm = Runtime::Current()->GetJavaVM(); - result = vm->globals.SynchronizedGet(const_cast<Thread*>(this), &vm->globals_lock, ref); + // Strong global references do not need a read barrier. + result = vm->globals.SynchronizedGet<kWithoutReadBarrier>( + const_cast<Thread*>(this), &vm->globals_lock, ref); } else { DCHECK_EQ(kind, kWeakGlobal); result = Runtime::Current()->GetJavaVM()->DecodeWeakGlobal(const_cast<Thread*>(this), ref); |