From 942fd3130254d8276cbfe8e6201825e9c49e9b2c Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Mon, 16 Jan 2017 20:52:19 +0000 Subject: Reduce using ArtMethod's dex_cache_resolved_types_. Avoid using the ArtMethod's dex cache type array shortcut in runtime, preparing for its removal. We do not completely remove the shortcut yet because it is still used by array allocation entrypoints. Fix ArgArray::BuildArgArrayFromObjectArray in reflection.cc to not ask for the parameter type to be resolved. It should have been previously resolved when retrieving the Method. Also partially revert https://android-review.googlesource.com/310717 because it relied on the removed AIOOBE check in the removed ArtMethod::GetDexCacheResolvedType(). The removed check was simply defensive but it could not be triggered without some memory corruption. Test: m test-art-host Bug: 30627598 Change-Id: Ic45a5ff8c66b79429e440cbc08d67bf22a083682 --- runtime/entrypoints/entrypoint_utils.cc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'runtime/entrypoints/entrypoint_utils.cc') diff --git a/runtime/entrypoints/entrypoint_utils.cc b/runtime/entrypoints/entrypoint_utils.cc index b17e1a8ab1..fa94ef822b 100644 --- a/runtime/entrypoints/entrypoint_utils.cc +++ b/runtime/entrypoints/entrypoint_utils.cc @@ -48,10 +48,9 @@ static inline mirror::Class* CheckFilledNewArrayAlloc(dex::TypeIndex type_idx, ThrowNegativeArraySizeException(component_count); return nullptr; // Failure } - ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); - PointerSize pointer_size = class_linker->GetImagePointerSize(); - mirror::Class* klass = referrer->GetDexCacheResolvedType(type_idx, pointer_size); + mirror::Class* klass = referrer->GetDexCache()->GetResolvedType(type_idx); if (UNLIKELY(klass == nullptr)) { // Not in dex cache so try to resolve + ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); klass = class_linker->ResolveType(type_idx, referrer); if (klass == nullptr) { // Error DCHECK(self->IsExceptionPending()); @@ -129,7 +128,7 @@ void CheckReferenceResult(Handle o, Thread* self) { } // Make sure that the result is an instance of the type this method was expected to return. ArtMethod* method = self->GetCurrentMethod(nullptr); - mirror::Class* return_type = method->GetReturnType(true /* resolve */, kRuntimePointerSize); + mirror::Class* return_type = method->GetReturnType(true /* resolve */); if (!o->InstanceOf(return_type)) { Runtime::Current()->GetJavaVM()->JniAbortF(nullptr, @@ -192,8 +191,7 @@ JValue InvokeProxyInvocationHandler(ScopedObjectAccessAlreadyRunnable& soa, cons ArtMethod* interface_method = soa.Decode(interface_method_jobj)->GetArtMethod(); // This can cause thread suspension. - PointerSize pointer_size = Runtime::Current()->GetClassLinker()->GetImagePointerSize(); - mirror::Class* result_type = interface_method->GetReturnType(true /* resolve */, pointer_size); + mirror::Class* result_type = interface_method->GetReturnType(true /* resolve */); ObjPtr result_ref = soa.Decode(result); JValue result_unboxed; if (!UnboxPrimitiveForResult(result_ref.Ptr(), result_type, &result_unboxed)) { -- cgit v1.2.3-59-g8ed1b