diff options
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/optimizing/instruction_builder.cc | 8 | ||||
-rw-r--r-- | compiler/optimizing/instruction_simplifier.cc | 7 | ||||
-rw-r--r-- | compiler/optimizing/sharpening.cc | 15 | ||||
-rw-r--r-- | compiler/optimizing/sharpening.h | 5 |
4 files changed, 27 insertions, 8 deletions
diff --git a/compiler/optimizing/instruction_builder.cc b/compiler/optimizing/instruction_builder.cc index 3b1086e88e..068d3a964b 100644 --- a/compiler/optimizing/instruction_builder.cc +++ b/compiler/optimizing/instruction_builder.cc @@ -1111,6 +1111,7 @@ bool HInstructionBuilder::BuildInvoke(const Instruction& instruction, HInvokeStaticOrDirect::DispatchInfo dispatch_info = HSharpening::SharpenLoadMethod(resolved_method, has_method_id, + /* for_interface_call= */ false, code_generator_); if (dispatch_info.code_ptr_location == CodePtrLocation::kCallCriticalNative) { graph_->SetHasDirectCriticalNativeCall(true); @@ -1147,8 +1148,11 @@ bool HInstructionBuilder::BuildInvoke(const Instruction& instruction, ScopedObjectAccess soa(Thread::Current()); DCHECK(resolved_method->GetDeclaringClass()->IsInterface()); } - MethodLoadKind load_kind = - HSharpening::SharpenLoadMethod(resolved_method, /* has_method_id= */ true, code_generator_) + MethodLoadKind load_kind = HSharpening::SharpenLoadMethod( + resolved_method, + /* has_method_id= */ true, + /* for_interface_call= */ true, + code_generator_) .method_load_kind; invoke = new (allocator_) HInvokeInterface(allocator_, number_of_arguments, diff --git a/compiler/optimizing/instruction_simplifier.cc b/compiler/optimizing/instruction_simplifier.cc index 96f82f61ca..8886f14726 100644 --- a/compiler/optimizing/instruction_simplifier.cc +++ b/compiler/optimizing/instruction_simplifier.cc @@ -2310,8 +2310,11 @@ void InstructionSimplifierVisitor::SimplifySystemArrayCopy(HInvoke* instruction) // the invoke, as we would need to look it up in the current dex file, and it // is unlikely that it exists. The most usual situation for such typed // arraycopy methods is a direct pointer to the boot image. - invoke->SetDispatchInfo( - HSharpening::SharpenLoadMethod(method, /* has_method_id= */ true, codegen_)); + invoke->SetDispatchInfo(HSharpening::SharpenLoadMethod( + method, + /* has_method_id= */ true, + /* for_interface_call= */ false, + codegen_)); } } } diff --git a/compiler/optimizing/sharpening.cc b/compiler/optimizing/sharpening.cc index 3ffb24b852..1fd76f7029 100644 --- a/compiler/optimizing/sharpening.cc +++ b/compiler/optimizing/sharpening.cc @@ -58,7 +58,10 @@ static bool BootImageAOTCanEmbedMethod(ArtMethod* method, const CompilerOptions& } HInvokeStaticOrDirect::DispatchInfo HSharpening::SharpenLoadMethod( - ArtMethod* callee, bool has_method_id, CodeGenerator* codegen) { + ArtMethod* callee, + bool has_method_id, + bool for_interface_call, + CodeGenerator* codegen) { if (kIsDebugBuild) { ScopedObjectAccess soa(Thread::Current()); // Required for GetDeclaringClass below. DCHECK(callee != nullptr); @@ -83,8 +86,14 @@ HInvokeStaticOrDirect::DispatchInfo HSharpening::SharpenLoadMethod( // We don't optimize for debuggable as it would prevent us from obsoleting the method in some // situations. const CompilerOptions& compiler_options = codegen->GetCompilerOptions(); - if (callee == codegen->GetGraph()->GetArtMethod() && !codegen->GetGraph()->IsDebuggable()) { - // Recursive call. + if (callee == codegen->GetGraph()->GetArtMethod() && + !codegen->GetGraph()->IsDebuggable() && + // The runtime expects the canonical interface method being passed as + // hidden argument when doing an invokeinterface. Because default methods + // can be called through invokevirtual, we may get a copied method if we + // load 'recursively'. + (!for_interface_call || !callee->IsDefault())) { + // Recursive load. method_load_kind = MethodLoadKind::kRecursive; code_ptr_location = CodePtrLocation::kCallSelf; } else if (compiler_options.IsBootImage() || compiler_options.IsBootImageExtension()) { diff --git a/compiler/optimizing/sharpening.h b/compiler/optimizing/sharpening.h index f71d9b5056..975366918c 100644 --- a/compiler/optimizing/sharpening.h +++ b/compiler/optimizing/sharpening.h @@ -31,7 +31,10 @@ class HSharpening { public: // Used by the builder and InstructionSimplifier. static HInvokeStaticOrDirect::DispatchInfo SharpenLoadMethod( - ArtMethod* callee, bool has_method_id, CodeGenerator* codegen); + ArtMethod* callee, + bool has_method_id, + bool for_interface_call, + CodeGenerator* codegen); // Used by the builder and the inliner. static HLoadClass::LoadKind ComputeLoadClassKind(HLoadClass* load_class, |