From 42ef8ab151a3d0cbb42cb43f6841c3708d65fca3 Mon Sep 17 00:00:00 2001 From: Andreas Gampe Date: Thu, 3 Dec 2015 17:27:32 -0800 Subject: ART: Stash a resolved method late in the verifier Invoke-interface should only be called on an interface method. We cannot move the check earlier, as there are other checks that must be done that can fail a class hard. So postpone a push to the dex cache. Clean up the test a bit. Also templatize ResolveMethod with a version always checking the invoke type, and on a cache miss check whether type target type is an interface when an interface invoke type was given. Bug: 21869691 Change-Id: I94cbb23339cbbb3cb6be9995775e4dcefacce7fd --- compiler/driver/compiler_driver-inl.h | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'compiler/driver/compiler_driver-inl.h') diff --git a/compiler/driver/compiler_driver-inl.h b/compiler/driver/compiler_driver-inl.h index 10841e6700..0eb3e439ac 100644 --- a/compiler/driver/compiler_driver-inl.h +++ b/compiler/driver/compiler_driver-inl.h @@ -264,18 +264,16 @@ inline ArtMethod* CompilerDriver::ResolveMethod( Handle class_loader, const DexCompilationUnit* mUnit, uint32_t method_idx, InvokeType invoke_type, bool check_incompatible_class_change) { DCHECK_EQ(class_loader.Get(), soa.Decode(mUnit->GetClassLoader())); - ArtMethod* resolved_method = mUnit->GetClassLinker()->ResolveMethod( - *dex_cache->GetDexFile(), method_idx, dex_cache, class_loader, nullptr, invoke_type); - DCHECK_EQ(resolved_method == nullptr, soa.Self()->IsExceptionPending()); + ArtMethod* resolved_method = + check_incompatible_class_change + ? mUnit->GetClassLinker()->ResolveMethod( + *dex_cache->GetDexFile(), method_idx, dex_cache, class_loader, nullptr, invoke_type) + : mUnit->GetClassLinker()->ResolveMethod( + *dex_cache->GetDexFile(), method_idx, dex_cache, class_loader, nullptr, invoke_type); if (UNLIKELY(resolved_method == nullptr)) { + DCHECK(soa.Self()->IsExceptionPending()); // Clean up any exception left by type resolution. soa.Self()->ClearException(); - return nullptr; - } - if (check_incompatible_class_change && - UNLIKELY(resolved_method->CheckIncompatibleClassChange(invoke_type))) { - // Silently return null on incompatible class change. - return nullptr; } return resolved_method; } @@ -361,7 +359,7 @@ inline int CompilerDriver::IsFastInvoke( ArtMethod* called_method; ClassLinker* class_linker = mUnit->GetClassLinker(); if (LIKELY(devirt_target->dex_file == mUnit->GetDexFile())) { - called_method = class_linker->ResolveMethod( + called_method = class_linker->ResolveMethod( *devirt_target->dex_file, devirt_target->dex_method_index, dex_cache, class_loader, nullptr, kVirtual); } else { @@ -369,7 +367,7 @@ inline int CompilerDriver::IsFastInvoke( auto target_dex_cache(hs.NewHandle(class_linker->RegisterDexFile( *devirt_target->dex_file, class_linker->GetOrCreateAllocatorForClassLoader(class_loader.Get())))); - called_method = class_linker->ResolveMethod( + called_method = class_linker->ResolveMethod( *devirt_target->dex_file, devirt_target->dex_method_index, target_dex_cache, class_loader, nullptr, kVirtual); } -- cgit v1.2.3