diff options
author | Mathieu Chartier <mathieuc@google.com> | 2015-06-26 20:57:03 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-06-26 20:57:04 +0000 |
commit | ffd43f62c23d2cbf84ab549dc37ca1dda2ac438d (patch) | |
tree | 850b3b36474c866715c956fb7bda2c0f0c04ffe3 /runtime | |
parent | b91205e40fe692061edde19ecb87d51414a7fcee (diff) | |
parent | e290896bfccb170f589407c0d10945c8ae0c5807 (diff) | |
download | art-ffd43f62c23d2cbf84ab549dc37ca1dda2ac438d.zip art-ffd43f62c23d2cbf84ab549dc37ca1dda2ac438d.tar.gz art-ffd43f62c23d2cbf84ab549dc37ca1dda2ac438d.tar.bz2 |
Merge "Require mutator lock for DeleteLocalRef" into mnc-dev
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/jni_internal.cc | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/runtime/jni_internal.cc b/runtime/jni_internal.cc index 6ab4455..0a01f78 100644 --- a/runtime/jni_internal.cc +++ b/runtime/jni_internal.cc @@ -554,15 +554,16 @@ class JNI { return soa.AddLocalReference<jobject>(decoded_obj); } - static void DeleteLocalRef(JNIEnv* env, jobject obj) - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { + static void DeleteLocalRef(JNIEnv* env, jobject obj) { if (obj == nullptr) { return; } - IndirectReferenceTable& locals = reinterpret_cast<JNIEnvExt*>(env)->locals; - - uint32_t cookie = reinterpret_cast<JNIEnvExt*>(env)->local_ref_cookie; - if (!locals.Remove(cookie, obj)) { + // SOA is only necessary to have exclusion between GC root marking and removing. + // We don't want to have the GC attempt to mark a null root if we just removed + // it. b/22119403 + ScopedObjectAccess soa(env); + auto* ext_env = down_cast<JNIEnvExt*>(env); + if (!ext_env->locals.Remove(ext_env->local_ref_cookie, obj)) { // Attempting to delete a local reference that is not in the // topmost local reference frame is a no-op. DeleteLocalRef returns // void and doesn't throw any exceptions, but we should probably |