From 790412959a6413a585f45fc5f77fe7106311a00c Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Thu, 26 Mar 2015 10:05:54 +0000 Subject: Use the original invoke type when inlining. When resolving a method through the compiler driver, the code makes sure the call in the DEX bytecode matches the kind of method found, to check for IncompatibleClassChangeError. Because when we sharpen an invoke virtual, we transform the invoke kind to direct, we must not use the new kind, but the one in DEX. Change-Id: Iaf77b27b529c659ea48ffb19f46427552c9e3654 --- compiler/optimizing/builder.cc | 2 +- compiler/optimizing/inliner.cc | 4 +++- compiler/optimizing/nodes.h | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) (limited to 'compiler') diff --git a/compiler/optimizing/builder.cc b/compiler/optimizing/builder.cc index 8786ed419c..f81935a7c6 100644 --- a/compiler/optimizing/builder.cc +++ b/compiler/optimizing/builder.cc @@ -620,7 +620,7 @@ bool HGraphBuilder::BuildInvoke(const Instruction& instruction, DCHECK(!is_recursive || (target_method.dex_file == dex_compilation_unit_->GetDexFile())); invoke = new (arena_) HInvokeStaticOrDirect( arena_, number_of_arguments, return_type, dex_pc, target_method.dex_method_index, - is_recursive, optimized_invoke_type); + is_recursive, invoke_type, optimized_invoke_type); } size_t start_index = 0; diff --git a/compiler/optimizing/inliner.cc b/compiler/optimizing/inliner.cc index 256e85b6ce..4b990f1ddd 100644 --- a/compiler/optimizing/inliner.cc +++ b/compiler/optimizing/inliner.cc @@ -50,7 +50,9 @@ void HInliner::Run() { HInstruction* next = instruction->GetNext(); HInvokeStaticOrDirect* call = instruction->AsInvokeStaticOrDirect(); if (call != nullptr) { - if (!TryInline(call, call->GetDexMethodIndex(), call->GetInvokeType())) { + // We use the original invoke type to ensure the resolution of the called method + // works properly. + if (!TryInline(call, call->GetDexMethodIndex(), call->GetOriginalInvokeType())) { if (kIsDebugBuild) { std::string callee_name = PrettyMethod(call->GetDexMethodIndex(), *outer_compilation_unit_.GetDexFile()); diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h index 08b16d99b6..9c751fb9c5 100644 --- a/compiler/optimizing/nodes.h +++ b/compiler/optimizing/nodes.h @@ -2131,8 +2131,10 @@ class HInvokeStaticOrDirect : public HInvoke { uint32_t dex_pc, uint32_t dex_method_index, bool is_recursive, + InvokeType original_invoke_type, InvokeType invoke_type) : HInvoke(arena, number_of_arguments, return_type, dex_pc, dex_method_index), + original_invoke_type_(original_invoke_type), invoke_type_(invoke_type), is_recursive_(is_recursive) {} @@ -2142,6 +2144,7 @@ class HInvokeStaticOrDirect : public HInvoke { return false; } + InvokeType GetOriginalInvokeType() const { return original_invoke_type_; } InvokeType GetInvokeType() const { return invoke_type_; } bool IsRecursive() const { return is_recursive_; } bool NeedsDexCache() const OVERRIDE { return !IsRecursive(); } @@ -2149,6 +2152,7 @@ class HInvokeStaticOrDirect : public HInvoke { DECLARE_INSTRUCTION(InvokeStaticOrDirect); private: + const InvokeType original_invoke_type_; const InvokeType invoke_type_; const bool is_recursive_; -- cgit v1.2.3-59-g8ed1b