From b9b7d91f5ceb0b738e1774992fd6fe205c6091e9 Mon Sep 17 00:00:00 2001 From: Orion Hodson Date: Wed, 24 Feb 2021 09:24:47 +0000 Subject: Revert "Lazily allocate DexCache arrays." This reverts commit 1214319d27e7fb4c4ff00b39799df6f15288098a. Reason for revert: Post-submit fails Bug: b/181097963 Test: TH Change-Id: I9fd21140f1703d0020458b786f48bd39889a9948 --- runtime/class_linker-inl.h | 58 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 46 insertions(+), 12 deletions(-) (limited to 'runtime/class_linker-inl.h') diff --git a/runtime/class_linker-inl.h b/runtime/class_linker-inl.h index f45ccb5929..69f5a77a25 100644 --- a/runtime/class_linker-inl.h +++ b/runtime/class_linker-inl.h @@ -70,7 +70,10 @@ inline ObjPtr ClassLinker::ResolveString(dex::StringIndex string ArtField* referrer) { Thread::PoisonObjectPointersIfDebug(); DCHECK(!Thread::Current()->IsExceptionPending()); - ObjPtr resolved = referrer->GetDexCache()->GetResolvedString(string_idx); + // We do not need the read barrier for getting the DexCache for the initial resolved type + // lookup as both from-space and to-space copies point to the same native resolved types array. + ObjPtr resolved = + referrer->GetDexCache()->GetResolvedString(string_idx); if (resolved == nullptr) { resolved = DoResolveString(string_idx, referrer->GetDexCache()); } @@ -81,7 +84,10 @@ inline ObjPtr ClassLinker::ResolveString(dex::StringIndex string ArtMethod* referrer) { Thread::PoisonObjectPointersIfDebug(); DCHECK(!Thread::Current()->IsExceptionPending()); - ObjPtr resolved = referrer->GetDexCache()->GetResolvedString(string_idx); + // We do not need the read barrier for getting the DexCache for the initial resolved type + // lookup as both from-space and to-space copies point to the same native resolved types array. + ObjPtr resolved = + referrer->GetDexCache()->GetResolvedString(string_idx); if (resolved == nullptr) { resolved = DoResolveString(string_idx, referrer->GetDexCache()); } @@ -116,8 +122,10 @@ inline ObjPtr ClassLinker::ResolveType(dex::TypeIndex type_idx, Thread::Current()->PoisonObjectPointers(); } DCHECK(!Thread::Current()->IsExceptionPending()); + // We do not need the read barrier for getting the DexCache for the initial resolved type + // lookup as both from-space and to-space copies point to the same native resolved types array. ObjPtr resolved_type = - referrer->GetDexCache()->GetResolvedType(type_idx); + referrer->GetDexCache()->GetResolvedType(type_idx); if (resolved_type == nullptr) { resolved_type = DoResolveType(type_idx, referrer); } @@ -128,7 +136,10 @@ inline ObjPtr ClassLinker::ResolveType(dex::TypeIndex type_idx, ArtField* referrer) { Thread::PoisonObjectPointersIfDebug(); DCHECK(!Thread::Current()->IsExceptionPending()); - ObjPtr resolved_type = referrer->GetDexCache()->GetResolvedType(type_idx); + // We do not need the read barrier for getting the DexCache for the initial resolved type + // lookup as both from-space and to-space copies point to the same native resolved types array. + ObjPtr resolved_type = + referrer->GetDexCache()->GetResolvedType(type_idx); if (UNLIKELY(resolved_type == nullptr)) { resolved_type = DoResolveType(type_idx, referrer); } @@ -139,7 +150,10 @@ inline ObjPtr ClassLinker::ResolveType(dex::TypeIndex type_idx, ArtMethod* referrer) { Thread::PoisonObjectPointersIfDebug(); DCHECK(!Thread::Current()->IsExceptionPending()); - ObjPtr resolved_type = referrer->GetDexCache()->GetResolvedType(type_idx); + // We do not need the read barrier for getting the DexCache for the initial resolved type + // lookup as both from-space and to-space copies point to the same native resolved types array. + ObjPtr resolved_type = + referrer->GetDexCache()->GetResolvedType(type_idx); if (UNLIKELY(resolved_type == nullptr)) { resolved_type = DoResolveType(type_idx, referrer); } @@ -160,8 +174,10 @@ inline ObjPtr ClassLinker::ResolveType(dex::TypeIndex type_idx, inline ObjPtr ClassLinker::LookupResolvedType(dex::TypeIndex type_idx, ObjPtr referrer) { + // We do not need the read barrier for getting the DexCache for the initial resolved type + // lookup as both from-space and to-space copies point to the same native resolved types array. ObjPtr type = - referrer->GetDexCache()->GetResolvedType(type_idx); + referrer->GetDexCache()->GetResolvedType(type_idx); if (type == nullptr) { type = DoLookupResolvedType(type_idx, referrer); } @@ -170,7 +186,10 @@ inline ObjPtr ClassLinker::LookupResolvedType(dex::TypeIndex type inline ObjPtr ClassLinker::LookupResolvedType(dex::TypeIndex type_idx, ArtField* referrer) { - ObjPtr type = referrer->GetDexCache()->GetResolvedType(type_idx); + // We do not need the read barrier for getting the DexCache for the initial resolved type + // lookup as both from-space and to-space copies point to the same native resolved types array. + ObjPtr type = + referrer->GetDexCache()->GetResolvedType(type_idx); if (type == nullptr) { type = DoLookupResolvedType(type_idx, referrer->GetDeclaringClass()); } @@ -179,7 +198,10 @@ inline ObjPtr ClassLinker::LookupResolvedType(dex::TypeIndex type inline ObjPtr ClassLinker::LookupResolvedType(dex::TypeIndex type_idx, ArtMethod* referrer) { - ObjPtr type = referrer->GetDexCache()->GetResolvedType(type_idx); + // We do not need the read barrier for getting the DexCache for the initial resolved type + // lookup as both from-space and to-space copies point to the same native resolved types array. + ObjPtr type = + referrer->GetDexCache()->GetResolvedType(type_idx); if (type == nullptr) { type = DoLookupResolvedType(type_idx, referrer->GetDeclaringClass()); } @@ -285,7 +307,10 @@ inline ArtMethod* ClassLinker::GetResolvedMethod(uint32_t method_idx, ArtMethod* // lookup in the context of the original method from where it steals the code. // However, we delay the GetInterfaceMethodIfProxy() until needed. DCHECK(!referrer->IsProxyMethod() || referrer->IsConstructor()); - ArtMethod* resolved_method = referrer->GetDexCache()->GetResolvedMethod(method_idx); + // We do not need the read barrier for getting the DexCache for the initial resolved method + // lookup as both from-space and to-space copies point to the same native resolved methods array. + ArtMethod* resolved_method = referrer->GetDexCache()->GetResolvedMethod( + method_idx); if (resolved_method == nullptr) { return nullptr; } @@ -325,7 +350,10 @@ inline ArtMethod* ClassLinker::ResolveMethod(Thread* self, // However, we delay the GetInterfaceMethodIfProxy() until needed. DCHECK(!referrer->IsProxyMethod() || referrer->IsConstructor()); Thread::PoisonObjectPointersIfDebug(); - ArtMethod* resolved_method = referrer->GetDexCache()->GetResolvedMethod(method_idx); + // We do not need the read barrier for getting the DexCache for the initial resolved method + // lookup as both from-space and to-space copies point to the same native resolved methods array. + ArtMethod* resolved_method = referrer->GetDexCache()->GetResolvedMethod( + method_idx); DCHECK(resolved_method == nullptr || !resolved_method->IsRuntimeMethod()); if (UNLIKELY(resolved_method == nullptr)) { referrer = referrer->GetInterfaceMethodIfProxy(image_pointer_size_); @@ -390,7 +418,10 @@ inline ArtMethod* ClassLinker::ResolveMethod(Thread* self, inline ArtField* ClassLinker::LookupResolvedField(uint32_t field_idx, ArtMethod* referrer, bool is_static) { - ArtField* field = referrer->GetDexCache()->GetResolvedField(field_idx); + // We do not need the read barrier for getting the DexCache for the initial resolved field + // lookup as both from-space and to-space copies point to the same native resolved fields array. + ArtField* field = referrer->GetDexCache()->GetResolvedField( + field_idx); if (field == nullptr) { ObjPtr class_loader = referrer->GetDeclaringClass()->GetClassLoader(); field = LookupResolvedField(field_idx, referrer->GetDexCache(), class_loader, is_static); @@ -402,7 +433,10 @@ inline ArtField* ClassLinker::ResolveField(uint32_t field_idx, ArtMethod* referrer, bool is_static) { Thread::PoisonObjectPointersIfDebug(); - ArtField* resolved_field = referrer->GetDexCache()->GetResolvedField(field_idx); + // We do not need the read barrier for getting the DexCache for the initial resolved field + // lookup as both from-space and to-space copies point to the same native resolved fields array. + ArtField* resolved_field = referrer->GetDexCache()->GetResolvedField( + field_idx); if (UNLIKELY(resolved_field == nullptr)) { StackHandleScope<2> hs(Thread::Current()); ObjPtr referring_class = referrer->GetDeclaringClass(); -- cgit v1.2.3-59-g8ed1b