summaryrefslogtreecommitdiff
path: root/compiler/driver/compiler_driver-inl.h
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/driver/compiler_driver-inl.h')
-rw-r--r--compiler/driver/compiler_driver-inl.h140
1 files changed, 0 insertions, 140 deletions
diff --git a/compiler/driver/compiler_driver-inl.h b/compiler/driver/compiler_driver-inl.h
index 3a260f5a80..4b913f4255 100644
--- a/compiler/driver/compiler_driver-inl.h
+++ b/compiler/driver/compiler_driver-inl.h
@@ -293,146 +293,6 @@ inline uint16_t CompilerDriver::GetResolvedMethodVTableIndex(
}
}
-inline int CompilerDriver::IsFastInvoke(
- ScopedObjectAccess& soa, Handle<mirror::DexCache> dex_cache,
- Handle<mirror::ClassLoader> class_loader, const DexCompilationUnit* mUnit,
- mirror::Class* referrer_class, ArtMethod* resolved_method, InvokeType* invoke_type,
- MethodReference* target_method, const MethodReference* devirt_target,
- uintptr_t* direct_code, uintptr_t* direct_method) {
- // Don't try to fast-path if we don't understand the caller's class.
- // Referrer_class is the class that this invoke is contained in.
- if (UNLIKELY(referrer_class == nullptr)) {
- return 0;
- }
- StackHandleScope<2> hs(soa.Self());
- // Methods_class is the class refered to by the class_idx field of the methodId the method_idx is
- // pointing to.
- // For example in
- // .class LABC;
- // .super LDEF;
- // .method hi()V
- // ...
- // invoke-super {p0}, LDEF;->hi()V
- // ...
- // .end method
- // the referrer_class is 'ABC' and the methods_class is DEF. Note that the methods class is 'DEF'
- // even if 'DEF' inherits the method from it's superclass.
- Handle<mirror::Class> methods_class(hs.NewHandle(mUnit->GetClassLinker()->ResolveType(
- *target_method->dex_file,
- target_method->dex_file->GetMethodId(target_method->dex_method_index).class_idx_,
- dex_cache,
- class_loader)));
- DCHECK(methods_class.Get() != nullptr);
- mirror::Class* methods_declaring_class = resolved_method->GetDeclaringClass();
- if (UNLIKELY(!referrer_class->CanAccessResolvedMethod(methods_declaring_class, resolved_method,
- dex_cache.Get(),
- target_method->dex_method_index))) {
- return 0;
- }
- // Sharpen a virtual call into a direct call when the target is known not to have been
- // overridden (ie is final).
- const bool same_dex_file = target_method->dex_file == mUnit->GetDexFile();
- bool can_sharpen_virtual_based_on_type = same_dex_file &&
- (*invoke_type == kVirtual) && (resolved_method->IsFinal() ||
- methods_declaring_class->IsFinal());
- // For invoke-super, ensure the vtable index will be correct to dispatch in the vtable of
- // the super class.
- const PointerSize pointer_size = InstructionSetPointerSize(GetInstructionSet());
- // TODO We should be able to sharpen if we are going into the boot image as well.
- bool can_sharpen_super_based_on_type = same_dex_file &&
- (*invoke_type == kSuper) &&
- !methods_class->IsInterface() &&
- (referrer_class != methods_declaring_class) &&
- referrer_class->IsSubClass(methods_declaring_class) &&
- resolved_method->GetMethodIndex() < methods_declaring_class->GetVTableLength() &&
- (methods_declaring_class->GetVTableEntry(
- resolved_method->GetMethodIndex(), pointer_size) == resolved_method) &&
- resolved_method->IsInvokable();
- // TODO We should be able to sharpen if we are going into the boot image as well.
- bool can_sharpen_interface_super_based_on_type = same_dex_file &&
- (*invoke_type == kSuper) &&
- methods_class->IsInterface() &&
- methods_class->IsAssignableFrom(referrer_class) &&
- resolved_method->IsInvokable();
-
- if (can_sharpen_virtual_based_on_type ||
- can_sharpen_super_based_on_type ||
- can_sharpen_interface_super_based_on_type) {
- // Sharpen a virtual call into a direct call. The method_idx is into referrer's
- // dex cache, check that this resolved method is where we expect it.
- CHECK_EQ(target_method->dex_file, mUnit->GetDexFile());
- DCHECK_EQ(dex_cache.Get(), mUnit->GetClassLinker()->FindDexCache(
- soa.Self(), *mUnit->GetDexFile(), false));
- CHECK_EQ(referrer_class->GetDexCache()->GetResolvedMethod(
- target_method->dex_method_index, pointer_size),
- resolved_method) << PrettyMethod(resolved_method);
- int stats_flags = kFlagMethodResolved;
- GetCodeAndMethodForDirectCall(/*out*/invoke_type,
- kDirect, // Sharp type
- false, // The dex cache is guaranteed to be available
- referrer_class, resolved_method,
- /*out*/&stats_flags,
- target_method,
- /*out*/direct_code,
- /*out*/direct_method);
- DCHECK_NE(*invoke_type, kSuper) << PrettyMethod(resolved_method);
- if (*invoke_type == kDirect) {
- stats_flags |= kFlagsMethodResolvedVirtualMadeDirect;
- }
- return stats_flags;
- }
-
- if ((*invoke_type == kVirtual || *invoke_type == kInterface) && devirt_target != nullptr) {
- // Post-verification callback recorded a more precise invoke target based on its type info.
- ArtMethod* called_method;
- ClassLinker* class_linker = mUnit->GetClassLinker();
- if (LIKELY(devirt_target->dex_file == mUnit->GetDexFile())) {
- called_method = class_linker->ResolveMethod<ClassLinker::kNoICCECheckForCache>(
- *devirt_target->dex_file, devirt_target->dex_method_index, dex_cache, class_loader,
- nullptr, kVirtual);
- } else {
- auto target_dex_cache(hs.NewHandle(class_linker->RegisterDexFile(*devirt_target->dex_file,
- class_loader.Get())));
- called_method = class_linker->ResolveMethod<ClassLinker::kNoICCECheckForCache>(
- *devirt_target->dex_file, devirt_target->dex_method_index, target_dex_cache,
- class_loader, nullptr, kVirtual);
- }
- CHECK(called_method != nullptr);
- CHECK(called_method->IsInvokable());
- int stats_flags = kFlagMethodResolved;
- GetCodeAndMethodForDirectCall(/*out*/invoke_type,
- kDirect, // Sharp type
- true, // The dex cache may not be available
- referrer_class, called_method,
- /*out*/&stats_flags,
- target_method,
- /*out*/direct_code,
- /*out*/direct_method);
- DCHECK_NE(*invoke_type, kSuper);
- if (*invoke_type == kDirect) {
- stats_flags |= kFlagsMethodResolvedPreciseTypeDevirtualization;
- }
- return stats_flags;
- }
-
- if (UNLIKELY(*invoke_type == kSuper)) {
- // Unsharpened super calls are suspicious so go slow-path.
- return 0;
- }
-
- // Sharpening failed so generate a regular resolved method dispatch.
- int stats_flags = kFlagMethodResolved;
- GetCodeAndMethodForDirectCall(/*out*/invoke_type,
- *invoke_type, // Sharp type
- false, // The dex cache is guaranteed to be available
- referrer_class, resolved_method,
- /*out*/&stats_flags,
- target_method,
- /*out*/direct_code,
- /*out*/direct_method);
- return stats_flags;
-}
-
inline bool CompilerDriver::IsMethodsClassInitialized(mirror::Class* referrer_class,
ArtMethod* resolved_method) {
if (!resolved_method->IsStatic()) {