summaryrefslogtreecommitdiff
path: root/compiler/optimizing/sharpening.cc
diff options
context:
space:
mode:
author Nicolas Geoffray <ngeoffray@google.com> 2021-01-19 10:35:54 +0000
committer Nicolas Geoffray <ngeoffray@google.com> 2021-01-21 14:07:57 +0000
commitd5a8695394f8f6e8f9a66752441623dc31b97660 (patch)
tree591ac4892304365282a57262c91e1945ac94c6a9 /compiler/optimizing/sharpening.cc
parent2fb37411e42455a00fdad90f0e612c3214e5bd1a (diff)
Reland "Improve invokeinterface for nterp."
This reverts commit f1d06474baa2f7c00761db39099b89ddab71bbe4. Bug: 177554973 Bug: 112676029 Test: test.py Test: 815-invokeinterface-default Test: enable text-to-speech on device, no crash Reason for revert: Fixed issue with recursive default methods Change-Id: I2fb9336adb6c4fc920f39aa19bfe7f0a92ce059a
Diffstat (limited to 'compiler/optimizing/sharpening.cc')
-rw-r--r--compiler/optimizing/sharpening.cc15
1 files changed, 12 insertions, 3 deletions
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()) {