From: Nicolas Geoffray Date: Sat, 13 Feb 2016 12:38:36 +0000 (+0000) Subject: Don't call IsNative if the declaring class can be null. X-Git-Tag: android-x86-7.1-r1~408^2~7^2~27^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=dec3a12c45e160097e6938be3778a6175113c42f;p=android-x86%2Fart.git Don't call IsNative if the declaring class can be null. There's a check down below the IsNative call that makes sure the declaring class is not null. Change-Id: I744bf01105eadeea9893ae626970c4b6b2f64a8b --- diff --git a/runtime/art_method-inl.h b/runtime/art_method-inl.h index cc45c385b..ebe89bbbd 100644 --- a/runtime/art_method-inl.h +++ b/runtime/art_method-inl.h @@ -449,24 +449,25 @@ template void ArtMethod::VisitRoots(RootVisitorType& visitor, size_t pointer_size) { ArtMethod* interface_method = nullptr; mirror::Class* klass = declaring_class_.Read(); - if (UNLIKELY(klass != nullptr && klass->IsProxyClass())) { - // For normal methods, dex cache shortcuts will be visited through the declaring class. - // However, for proxies we need to keep the interface method alive, so we visit its roots. - interface_method = mirror::DexCache::GetElementPtrSize( - GetDexCacheResolvedMethods(pointer_size), - GetDexMethodIndex(), - pointer_size); - DCHECK(interface_method != nullptr); - DCHECK_EQ(interface_method, - Runtime::Current()->GetClassLinker()->FindMethodForProxy(klass, this)); - interface_method->VisitRoots(visitor, pointer_size); - } - - visitor.VisitRootIfNonNull(declaring_class_.AddressWithoutBarrier()); - if (!IsNative()) { - ProfilingInfo* profiling_info = GetProfilingInfo(pointer_size); - if (profiling_info != nullptr) { - profiling_info->VisitRoots(visitor); + if (LIKELY(klass != nullptr)) { + if (UNLIKELY(klass->IsProxyClass())) { + // For normal methods, dex cache shortcuts will be visited through the declaring class. + // However, for proxies we need to keep the interface method alive, so we visit its roots. + interface_method = mirror::DexCache::GetElementPtrSize( + GetDexCacheResolvedMethods(pointer_size), + GetDexMethodIndex(), + pointer_size); + DCHECK(interface_method != nullptr); + DCHECK_EQ(interface_method, + Runtime::Current()->GetClassLinker()->FindMethodForProxy(klass, this)); + interface_method->VisitRoots(visitor, pointer_size); + } + visitor.VisitRoot(declaring_class_.AddressWithoutBarrier()); + if (!IsNative()) { + ProfilingInfo* profiling_info = GetProfilingInfo(pointer_size); + if (profiling_info != nullptr) { + profiling_info->VisitRoots(visitor); + } } } }