From 09c5ca40635faee00f40f6ca0581dd475efd545e Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Thu, 31 May 2018 15:15:31 +0100 Subject: Clean up class resolution and lookup. Simplify the code and avoid read barriers when appropriate. Relax class status check in ArtField::GetDeclaringClass() because we can see ClassStatus::kIdx from the from-space class object for kReadBarrierOption=kWithoutReadBarrier. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I83886a64fe5a99a1c3c30eab3b35dae449e6b4bc --- runtime/class_linker.h | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'runtime/class_linker.h') diff --git a/runtime/class_linker.h b/runtime/class_linker.h index b38f01d835..32016fa12a 100644 --- a/runtime/class_linker.h +++ b/runtime/class_linker.h @@ -67,6 +67,8 @@ using MethodDexCachePair = NativeDexCachePair; using MethodDexCacheType = std::atomic; } // namespace mirror +class ArtField; +class ArtMethod; class ClassHierarchyAnalysis; enum class ClassRoot : uint32_t; class ClassTable; @@ -219,10 +221,9 @@ class ClassLinker { ObjPtr ResolveType(dex::TypeIndex type_idx, ObjPtr referrer) REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Locks::dex_lock_, !Roles::uninterruptible_); - - // Resolve a type with the given index from the DexFile associated with the given `referrer`, - // storing the result in the DexCache. The `referrer` is used to identify the target DexCache - // and ClassLoader to use for resolution. + ObjPtr ResolveType(dex::TypeIndex type_idx, ArtField* referrer) + REQUIRES_SHARED(Locks::mutator_lock_) + REQUIRES(!Locks::dex_lock_, !Roles::uninterruptible_); ObjPtr ResolveType(dex::TypeIndex type_idx, ArtMethod* referrer) REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Locks::dex_lock_, !Roles::uninterruptible_); @@ -242,10 +243,8 @@ class ClassLinker { ObjPtr LookupResolvedType(dex::TypeIndex type_idx, ObjPtr referrer) REQUIRES_SHARED(Locks::mutator_lock_); - - // Look up a resolved type with the given index from the DexFile associated with the given - // `referrer`, storing the result in the DexCache. The `referrer` is used to identify the - // target DexCache and ClassLoader to use for lookup. + ObjPtr LookupResolvedType(dex::TypeIndex type_idx, ArtField* referrer) + REQUIRES_SHARED(Locks::mutator_lock_); ObjPtr LookupResolvedType(dex::TypeIndex type_idx, ArtMethod* referrer) REQUIRES_SHARED(Locks::mutator_lock_); @@ -877,12 +876,19 @@ class ClassLinker { REQUIRES(!Locks::dex_lock_); // Implementation of LookupResolvedType() called when the type was not found in the dex cache. + ObjPtr DoLookupResolvedType(dex::TypeIndex type_idx, + ObjPtr referrer) + REQUIRES_SHARED(Locks::mutator_lock_); ObjPtr DoLookupResolvedType(dex::TypeIndex type_idx, ObjPtr dex_cache, ObjPtr class_loader) REQUIRES_SHARED(Locks::mutator_lock_); // Implementation of ResolveType() called when the type was not found in the dex cache. + ObjPtr DoResolveType(dex::TypeIndex type_idx, + ObjPtr referrer) + REQUIRES_SHARED(Locks::mutator_lock_) + REQUIRES(!Locks::dex_lock_, !Roles::uninterruptible_); ObjPtr DoResolveType(dex::TypeIndex type_idx, Handle dex_cache, Handle class_loader) -- cgit v1.2.3-59-g8ed1b