From 6a816cf624ba56bf2872916d7b65b18fd9a411ef Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Tue, 24 Mar 2015 16:17:56 +0000 Subject: Revert "Inline across dex files." bug: 19904089 bug: 19903495 This reverts commit 7e4c3508e4f5512650b63c41f7872a749e99aee9. Change-Id: I15df746b5f1882cce78eedde6c05c0d3b69bfa4a --- compiler/optimizing/builder.cc | 12 +++++------- compiler/optimizing/inliner.cc | 26 ++++++++++---------------- compiler/optimizing/inliner.h | 3 +-- compiler/optimizing/nodes.h | 6 ------ 4 files changed, 16 insertions(+), 31 deletions(-) (limited to 'compiler') diff --git a/compiler/optimizing/builder.cc b/compiler/optimizing/builder.cc index cbb41b1..ec7fd62 100644 --- a/compiler/optimizing/builder.cc +++ b/compiler/optimizing/builder.cc @@ -616,8 +616,8 @@ bool HGraphBuilder::BuildInvoke(const Instruction& instruction, DCHECK((optimized_invoke_type == invoke_type) || (optimized_invoke_type != kDirect) || compiler_driver_->GetCompilerOptions().GetCompilePic()); bool is_recursive = - (target_method.dex_method_index == dex_compilation_unit_->GetDexMethodIndex()); - DCHECK(!is_recursive || (target_method.dex_file == dex_compilation_unit_->GetDexFile())); + (target_method.dex_method_index == outer_compilation_unit_->GetDexMethodIndex()); + DCHECK(!is_recursive || (target_method.dex_file == outer_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); @@ -711,7 +711,7 @@ bool HGraphBuilder::BuildStaticFieldAccess(const Instruction& instruction, uint16_t field_index = instruction.VRegB_21c(); ScopedObjectAccess soa(Thread::Current()); - StackHandleScope<5> hs(soa.Self()); + StackHandleScope<4> hs(soa.Self()); Handle dex_cache(hs.NewHandle( dex_compilation_unit_->GetClassLinker()->FindDexCache(*dex_compilation_unit_->GetDexFile()))); Handle class_loader(hs.NewHandle( @@ -724,10 +724,8 @@ bool HGraphBuilder::BuildStaticFieldAccess(const Instruction& instruction, return false; } - Handle outer_dex_cache(hs.NewHandle( - outer_compilation_unit_->GetClassLinker()->FindDexCache(*outer_compilation_unit_->GetDexFile()))); Handle referrer_class(hs.NewHandle(compiler_driver_->ResolveCompilingMethodsClass( - soa, outer_dex_cache, class_loader, outer_compilation_unit_))); + soa, dex_cache, class_loader, outer_compilation_unit_))); // The index at which the field's class is stored in the DexCache's type array. uint32_t storage_index; @@ -740,7 +738,7 @@ bool HGraphBuilder::BuildStaticFieldAccess(const Instruction& instruction, // TODO: find out why this check is needed. bool is_in_dex_cache = compiler_driver_->CanAssumeTypeIsPresentInDexCache( - *dex_compilation_unit_->GetDexFile(), storage_index); + *outer_compilation_unit_->GetDexFile(), storage_index); bool is_initialized = resolved_field->GetDeclaringClass()->IsInitialized() && is_in_dex_cache; bool is_referrer_class = (referrer_class.Get() == resolved_field->GetDeclaringClass()); diff --git a/compiler/optimizing/inliner.cc b/compiler/optimizing/inliner.cc index 82d6357..968fe3e 100644 --- a/compiler/optimizing/inliner.cc +++ b/compiler/optimizing/inliner.cc @@ -85,9 +85,11 @@ bool HInliner::TryInline(HInvoke* invoke_instruction, return false; } - bool can_use_dex_cache = true; if (resolved_method->GetDexFile()->GetLocation().compare(outer_dex_file.GetLocation()) != 0) { - can_use_dex_cache = false; + VLOG(compiler) << "Did not inline " + << PrettyMethod(method_index, outer_dex_file) + << " because it is in a different dex file"; + return false; } const DexFile::CodeItem* code_item = resolved_method->GetCodeItem(); @@ -122,7 +124,7 @@ bool HInliner::TryInline(HInvoke* invoke_instruction, return false; } - if (!TryBuildAndInline(resolved_method, invoke_instruction, method_index, can_use_dex_cache)) { + if (!TryBuildAndInline(resolved_method, invoke_instruction, method_index)) { resolved_method->SetShouldNotInline(); return false; } @@ -134,8 +136,7 @@ bool HInliner::TryInline(HInvoke* invoke_instruction, bool HInliner::TryBuildAndInline(Handle resolved_method, HInvoke* invoke_instruction, - uint32_t method_index, - bool can_use_dex_cache) const { + uint32_t method_index) const { ScopedObjectAccess soa(Thread::Current()); const DexFile::CodeItem* code_item = resolved_method->GetCodeItem(); const DexFile& outer_dex_file = *outer_compilation_unit_.GetDexFile(); @@ -144,10 +145,10 @@ bool HInliner::TryBuildAndInline(Handle resolved_method, nullptr, outer_compilation_unit_.GetClassLoader(), outer_compilation_unit_.GetClassLinker(), - *resolved_method->GetDexFile(), + outer_dex_file, code_item, resolved_method->GetDeclaringClass()->GetDexClassDefIndex(), - resolved_method->GetDexMethodIndex(), + method_index, resolved_method->GetAccessFlags(), nullptr); @@ -158,7 +159,7 @@ bool HInliner::TryBuildAndInline(Handle resolved_method, HGraphBuilder builder(callee_graph, &dex_compilation_unit, &outer_compilation_unit_, - resolved_method->GetDexFile(), + &outer_dex_file, compiler_driver_, &inline_stats); @@ -199,7 +200,7 @@ bool HInliner::TryBuildAndInline(Handle resolved_method, if (depth_ + 1 < kDepthLimit) { HInliner inliner( - callee_graph, dex_compilation_unit, compiler_driver_, stats_, depth_ + 1); + callee_graph, outer_compilation_unit_, compiler_driver_, stats_, depth_ + 1); inliner.Run(); } @@ -234,13 +235,6 @@ bool HInliner::TryBuildAndInline(Handle resolved_method, << " needs an environment"; return false; } - - if (!can_use_dex_cache && current->NeedsDexCache()) { - VLOG(compiler) << "Method " << PrettyMethod(method_index, outer_dex_file) - << " could not be inlined because " << current->DebugName() - << " it is in a different dex file and requires access to the dex cache"; - return false; - } } } diff --git a/compiler/optimizing/inliner.h b/compiler/optimizing/inliner.h index 4b7e2ff..1251977 100644 --- a/compiler/optimizing/inliner.h +++ b/compiler/optimizing/inliner.h @@ -48,8 +48,7 @@ class HInliner : public HOptimization { bool TryInline(HInvoke* invoke_instruction, uint32_t method_index, InvokeType invoke_type) const; bool TryBuildAndInline(Handle resolved_method, HInvoke* invoke_instruction, - uint32_t method_index, - bool can_use_dex_cache) const; + uint32_t method_index) const; const DexCompilationUnit& outer_compilation_unit_; CompilerDriver* const compiler_driver_; diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h index 07ff8ba..a35fa1d 100644 --- a/compiler/optimizing/nodes.h +++ b/compiler/optimizing/nodes.h @@ -1200,8 +1200,6 @@ class HInstruction : public ArenaObject { return NeedsEnvironment() || IsLoadClass() || IsLoadString(); } - virtual bool NeedsDexCache() const { return false; } - protected: virtual const HUserRecord InputRecordAt(size_t i) const = 0; virtual void SetRawInputRecordAt(size_t index, const HUserRecord& input) = 0; @@ -2092,7 +2090,6 @@ class HInvokeStaticOrDirect : public HInvoke { InvokeType GetInvokeType() const { return invoke_type_; } bool IsRecursive() const { return is_recursive_; } - bool NeedsDexCache() const OVERRIDE { return !IsRecursive(); } DECLARE_INSTRUCTION(InvokeStaticOrDirect); @@ -2975,8 +2972,6 @@ class HLoadClass : public HExpression<0> { return loaded_class_rti_.IsExact(); } - bool NeedsDexCache() const OVERRIDE { return !is_referrers_class_; } - DECLARE_INSTRUCTION(LoadClass); private: @@ -3012,7 +3007,6 @@ class HLoadString : public HExpression<0> { // TODO: Can we deopt or debug when we resolve a string? bool NeedsEnvironment() const OVERRIDE { return false; } - bool NeedsDexCache() const OVERRIDE { return true; } DECLARE_INSTRUCTION(LoadString); -- cgit v1.1