Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include "inliner.h" |
| 18 | |
Mathieu Chartier | 3d21bdf | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 19 | #include "art_method-inl.h" |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 20 | #include "builder.h" |
| 21 | #include "class_linker.h" |
| 22 | #include "constant_folding.h" |
| 23 | #include "dead_code_elimination.h" |
| 24 | #include "driver/compiler_driver-inl.h" |
| 25 | #include "driver/dex_compilation_unit.h" |
| 26 | #include "instruction_simplifier.h" |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 27 | #include "mirror/class_loader.h" |
| 28 | #include "mirror/dex_cache.h" |
| 29 | #include "nodes.h" |
Nicolas Geoffray | 259136f | 2014-12-17 23:21:58 +0000 | [diff] [blame] | 30 | #include "register_allocator.h" |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 31 | #include "ssa_phi_elimination.h" |
| 32 | #include "scoped_thread_state_change.h" |
| 33 | #include "thread.h" |
Calin Juravle | f1c6d9e | 2015-04-13 18:42:21 +0100 | [diff] [blame] | 34 | #include "dex/verified_method.h" |
| 35 | #include "dex/verification_results.h" |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 36 | |
| 37 | namespace art { |
| 38 | |
| 39 | static constexpr int kMaxInlineCodeUnits = 100; |
Nicolas Geoffray | ef87c5d | 2015-01-30 12:41:14 +0000 | [diff] [blame] | 40 | static constexpr int kDepthLimit = 5; |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 41 | |
| 42 | void HInliner::Run() { |
Nicolas Geoffray | e50b8d2 | 2015-03-13 08:57:42 +0000 | [diff] [blame] | 43 | if (graph_->IsDebuggable()) { |
| 44 | // For simplicity, we currently never inline when the graph is debuggable. This avoids |
| 45 | // doing some logic in the runtime to discover if a method could have been inlined. |
| 46 | return; |
| 47 | } |
Nicolas Geoffray | ef87c5d | 2015-01-30 12:41:14 +0000 | [diff] [blame] | 48 | const GrowableArray<HBasicBlock*>& blocks = graph_->GetReversePostOrder(); |
| 49 | for (size_t i = 0; i < blocks.Size(); ++i) { |
| 50 | HBasicBlock* block = blocks.Get(i); |
| 51 | for (HInstruction* instruction = block->GetFirstInstruction(); instruction != nullptr;) { |
| 52 | HInstruction* next = instruction->GetNext(); |
| 53 | HInvokeStaticOrDirect* call = instruction->AsInvokeStaticOrDirect(); |
Razvan A Lupusoru | 3e90a96 | 2015-03-27 13:44:44 -0700 | [diff] [blame] | 54 | // As long as the call is not intrinsified, it is worth trying to inline. |
| 55 | if (call != nullptr && call->GetIntrinsic() == Intrinsics::kNone) { |
Nicolas Geoffray | 7904129 | 2015-03-26 10:05:54 +0000 | [diff] [blame] | 56 | // We use the original invoke type to ensure the resolution of the called method |
| 57 | // works properly. |
Nicolas Geoffray | 8859311 | 2015-06-22 14:15:07 +0000 | [diff] [blame] | 58 | if (!TryInline(call, call->GetDexMethodIndex())) { |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 59 | if (kIsDebugBuild) { |
| 60 | std::string callee_name = |
Nicolas Geoffray | ef87c5d | 2015-01-30 12:41:14 +0000 | [diff] [blame] | 61 | PrettyMethod(call->GetDexMethodIndex(), *outer_compilation_unit_.GetDexFile()); |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 62 | bool should_inline = callee_name.find("$inline$") != std::string::npos; |
| 63 | CHECK(!should_inline) << "Could not inline " << callee_name; |
| 64 | } |
| 65 | } |
| 66 | } |
Nicolas Geoffray | ef87c5d | 2015-01-30 12:41:14 +0000 | [diff] [blame] | 67 | instruction = next; |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 68 | } |
| 69 | } |
| 70 | } |
| 71 | |
Nicolas Geoffray | 8859311 | 2015-06-22 14:15:07 +0000 | [diff] [blame] | 72 | bool HInliner::TryInline(HInvoke* invoke_instruction, uint32_t method_index) const { |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 73 | ScopedObjectAccess soa(Thread::Current()); |
Nicolas Geoffray | 9437b78 | 2015-03-25 10:08:51 +0000 | [diff] [blame] | 74 | const DexFile& caller_dex_file = *caller_compilation_unit_.GetDexFile(); |
| 75 | VLOG(compiler) << "Try inlining " << PrettyMethod(method_index, caller_dex_file); |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 76 | |
Nicolas Geoffray | 8859311 | 2015-06-22 14:15:07 +0000 | [diff] [blame] | 77 | ClassLinker* class_linker = caller_compilation_unit_.GetClassLinker(); |
| 78 | // We can query the dex cache directly. The verifier has populated it already. |
| 79 | ArtMethod* resolved_method = class_linker->FindDexCache(caller_dex_file)->GetResolvedMethod( |
| 80 | method_index, class_linker->GetImagePointerSize()); |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 81 | |
Mathieu Chartier | 3d21bdf | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 82 | if (resolved_method == nullptr) { |
Nicolas Geoffray | 8859311 | 2015-06-22 14:15:07 +0000 | [diff] [blame] | 83 | // Method cannot be resolved if it is in another dex file we do not have access to. |
Nicolas Geoffray | 9437b78 | 2015-03-25 10:08:51 +0000 | [diff] [blame] | 84 | VLOG(compiler) << "Method cannot be resolved " << PrettyMethod(method_index, caller_dex_file); |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 85 | return false; |
| 86 | } |
| 87 | |
Nicolas Geoffray | 9437b78 | 2015-03-25 10:08:51 +0000 | [diff] [blame] | 88 | bool can_use_dex_cache = true; |
| 89 | const DexFile& outer_dex_file = *outer_compilation_unit_.GetDexFile(); |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 90 | if (resolved_method->GetDexFile()->GetLocation().compare(outer_dex_file.GetLocation()) != 0) { |
Nicolas Geoffray | 9437b78 | 2015-03-25 10:08:51 +0000 | [diff] [blame] | 91 | can_use_dex_cache = false; |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | const DexFile::CodeItem* code_item = resolved_method->GetCodeItem(); |
| 95 | |
| 96 | if (code_item == nullptr) { |
Nicolas Geoffray | 9437b78 | 2015-03-25 10:08:51 +0000 | [diff] [blame] | 97 | VLOG(compiler) << "Method " << PrettyMethod(method_index, caller_dex_file) |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 98 | << " is not inlined because it is native"; |
| 99 | return false; |
| 100 | } |
| 101 | |
| 102 | if (code_item->insns_size_in_code_units_ > kMaxInlineCodeUnits) { |
Nicolas Geoffray | 9437b78 | 2015-03-25 10:08:51 +0000 | [diff] [blame] | 103 | VLOG(compiler) << "Method " << PrettyMethod(method_index, caller_dex_file) |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 104 | << " is too big to inline"; |
| 105 | return false; |
| 106 | } |
| 107 | |
| 108 | if (code_item->tries_size_ != 0) { |
Nicolas Geoffray | 9437b78 | 2015-03-25 10:08:51 +0000 | [diff] [blame] | 109 | VLOG(compiler) << "Method " << PrettyMethod(method_index, caller_dex_file) |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 110 | << " is not inlined because of try block"; |
| 111 | return false; |
| 112 | } |
| 113 | |
Calin Juravle | f1c6d9e | 2015-04-13 18:42:21 +0100 | [diff] [blame] | 114 | uint16_t class_def_idx = resolved_method->GetDeclaringClass()->GetDexClassDefIndex(); |
| 115 | if (!compiler_driver_->IsMethodVerifiedWithoutFailures( |
| 116 | resolved_method->GetDexMethodIndex(), class_def_idx, *resolved_method->GetDexFile())) { |
Nicolas Geoffray | 9437b78 | 2015-03-25 10:08:51 +0000 | [diff] [blame] | 117 | VLOG(compiler) << "Method " << PrettyMethod(method_index, caller_dex_file) |
Calin Juravle | f1c6d9e | 2015-04-13 18:42:21 +0100 | [diff] [blame] | 118 | << " couldn't be verified, so it cannot be inlined"; |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 119 | return false; |
| 120 | } |
| 121 | |
Nicolas Geoffray | c0365b1 | 2015-03-18 18:31:52 +0000 | [diff] [blame] | 122 | if (resolved_method->ShouldNotInline()) { |
Nicolas Geoffray | 9437b78 | 2015-03-25 10:08:51 +0000 | [diff] [blame] | 123 | VLOG(compiler) << "Method " << PrettyMethod(method_index, caller_dex_file) |
Nicolas Geoffray | c0365b1 | 2015-03-18 18:31:52 +0000 | [diff] [blame] | 124 | << " was already flagged as non inlineable"; |
| 125 | return false; |
| 126 | } |
| 127 | |
Roland Levillain | 4c0eb42 | 2015-04-24 16:43:49 +0100 | [diff] [blame] | 128 | if (invoke_instruction->IsInvokeStaticOrDirect() && |
| 129 | invoke_instruction->AsInvokeStaticOrDirect()->IsStaticWithImplicitClinitCheck()) { |
| 130 | // Case of a static method that cannot be inlined because it implicitly |
| 131 | // requires an initialization check of its declaring class. |
| 132 | VLOG(compiler) << "Method " << PrettyMethod(method_index, caller_dex_file) |
| 133 | << " is not inlined because it is static and requires a clinit" |
| 134 | << " check that cannot be emitted due to Dex cache limitations"; |
| 135 | return false; |
| 136 | } |
| 137 | |
Nicolas Geoffray | 9437b78 | 2015-03-25 10:08:51 +0000 | [diff] [blame] | 138 | if (!TryBuildAndInline(resolved_method, invoke_instruction, method_index, can_use_dex_cache)) { |
Nicolas Geoffray | c0365b1 | 2015-03-18 18:31:52 +0000 | [diff] [blame] | 139 | return false; |
| 140 | } |
| 141 | |
Nicolas Geoffray | 9437b78 | 2015-03-25 10:08:51 +0000 | [diff] [blame] | 142 | VLOG(compiler) << "Successfully inlined " << PrettyMethod(method_index, caller_dex_file); |
Nicolas Geoffray | c0365b1 | 2015-03-18 18:31:52 +0000 | [diff] [blame] | 143 | MaybeRecordStat(kInlinedInvoke); |
| 144 | return true; |
| 145 | } |
| 146 | |
Mathieu Chartier | 3d21bdf | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 147 | bool HInliner::TryBuildAndInline(ArtMethod* resolved_method, |
Nicolas Geoffray | c0365b1 | 2015-03-18 18:31:52 +0000 | [diff] [blame] | 148 | HInvoke* invoke_instruction, |
Nicolas Geoffray | 9437b78 | 2015-03-25 10:08:51 +0000 | [diff] [blame] | 149 | uint32_t method_index, |
| 150 | bool can_use_dex_cache) const { |
Nicolas Geoffray | c0365b1 | 2015-03-18 18:31:52 +0000 | [diff] [blame] | 151 | ScopedObjectAccess soa(Thread::Current()); |
| 152 | const DexFile::CodeItem* code_item = resolved_method->GetCodeItem(); |
Nicolas Geoffray | 9437b78 | 2015-03-25 10:08:51 +0000 | [diff] [blame] | 153 | const DexFile& caller_dex_file = *caller_compilation_unit_.GetDexFile(); |
Nicolas Geoffray | c0365b1 | 2015-03-18 18:31:52 +0000 | [diff] [blame] | 154 | |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 155 | DexCompilationUnit dex_compilation_unit( |
| 156 | nullptr, |
Nicolas Geoffray | 9437b78 | 2015-03-25 10:08:51 +0000 | [diff] [blame] | 157 | caller_compilation_unit_.GetClassLoader(), |
| 158 | caller_compilation_unit_.GetClassLinker(), |
| 159 | *resolved_method->GetDexFile(), |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 160 | code_item, |
| 161 | resolved_method->GetDeclaringClass()->GetDexClassDefIndex(), |
Nicolas Geoffray | 9437b78 | 2015-03-25 10:08:51 +0000 | [diff] [blame] | 162 | resolved_method->GetDexMethodIndex(), |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 163 | resolved_method->GetAccessFlags(), |
| 164 | nullptr); |
| 165 | |
Nicolas Geoffray | e0fe7ae | 2015-03-09 10:02:49 +0000 | [diff] [blame] | 166 | HGraph* callee_graph = new (graph_->GetArena()) HGraph( |
Nicolas Geoffray | 0a23d74 | 2015-05-07 11:57:35 +0100 | [diff] [blame] | 167 | graph_->GetArena(), |
| 168 | caller_dex_file, |
| 169 | method_index, |
Mathieu Chartier | 3d21bdf | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 170 | compiler_driver_->GetInstructionSet(), |
Nicolas Geoffray | 0a23d74 | 2015-05-07 11:57:35 +0100 | [diff] [blame] | 171 | graph_->IsDebuggable(), |
| 172 | graph_->GetCurrentInstructionId()); |
David Brazdil | 5e8b137 | 2015-01-23 14:39:08 +0000 | [diff] [blame] | 173 | |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 174 | OptimizingCompilerStats inline_stats; |
David Brazdil | 5e8b137 | 2015-01-23 14:39:08 +0000 | [diff] [blame] | 175 | HGraphBuilder builder(callee_graph, |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 176 | &dex_compilation_unit, |
| 177 | &outer_compilation_unit_, |
Nicolas Geoffray | 9437b78 | 2015-03-25 10:08:51 +0000 | [diff] [blame] | 178 | resolved_method->GetDexFile(), |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 179 | compiler_driver_, |
| 180 | &inline_stats); |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 181 | |
David Brazdil | 5e8b137 | 2015-01-23 14:39:08 +0000 | [diff] [blame] | 182 | if (!builder.BuildGraph(*code_item)) { |
Nicolas Geoffray | 9437b78 | 2015-03-25 10:08:51 +0000 | [diff] [blame] | 183 | VLOG(compiler) << "Method " << PrettyMethod(method_index, caller_dex_file) |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 184 | << " could not be built, so cannot be inlined"; |
Nicolas Geoffray | 2653149 | 2015-05-27 12:53:36 +0100 | [diff] [blame] | 185 | // There could be multiple reasons why the graph could not be built, including |
| 186 | // unaccessible methods/fields due to using a different dex cache. We do not mark |
| 187 | // the method as non-inlineable so that other callers can still try to inline it. |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 188 | return false; |
| 189 | } |
| 190 | |
Nicolas Geoffray | 259136f | 2014-12-17 23:21:58 +0000 | [diff] [blame] | 191 | if (!RegisterAllocator::CanAllocateRegistersFor(*callee_graph, |
| 192 | compiler_driver_->GetInstructionSet())) { |
Nicolas Geoffray | 9437b78 | 2015-03-25 10:08:51 +0000 | [diff] [blame] | 193 | VLOG(compiler) << "Method " << PrettyMethod(method_index, caller_dex_file) |
Nicolas Geoffray | 259136f | 2014-12-17 23:21:58 +0000 | [diff] [blame] | 194 | << " cannot be inlined because of the register allocator"; |
Nicolas Geoffray | 4fa04a6 | 2015-05-26 14:35:06 +0100 | [diff] [blame] | 195 | resolved_method->SetShouldNotInline(); |
Nicolas Geoffray | 259136f | 2014-12-17 23:21:58 +0000 | [diff] [blame] | 196 | return false; |
| 197 | } |
| 198 | |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 199 | if (!callee_graph->TryBuildingSsa()) { |
Nicolas Geoffray | 9437b78 | 2015-03-25 10:08:51 +0000 | [diff] [blame] | 200 | VLOG(compiler) << "Method " << PrettyMethod(method_index, caller_dex_file) |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 201 | << " could not be transformed to SSA"; |
Nicolas Geoffray | 4fa04a6 | 2015-05-26 14:35:06 +0100 | [diff] [blame] | 202 | resolved_method->SetShouldNotInline(); |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 203 | return false; |
| 204 | } |
| 205 | |
Nicolas Geoffray | ef87c5d | 2015-01-30 12:41:14 +0000 | [diff] [blame] | 206 | // Run simple optimizations on the graph. |
Calin Juravle | 7a9c885 | 2015-04-21 14:07:50 +0100 | [diff] [blame] | 207 | HDeadCodeElimination dce(callee_graph, stats_); |
Nicolas Geoffray | ef87c5d | 2015-01-30 12:41:14 +0000 | [diff] [blame] | 208 | HConstantFolding fold(callee_graph); |
Calin Juravle | acf735c | 2015-02-12 15:25:22 +0000 | [diff] [blame] | 209 | InstructionSimplifier simplify(callee_graph, stats_); |
Nicolas Geoffray | ef87c5d | 2015-01-30 12:41:14 +0000 | [diff] [blame] | 210 | |
| 211 | HOptimization* optimizations[] = { |
Nicolas Geoffray | ef87c5d | 2015-01-30 12:41:14 +0000 | [diff] [blame] | 212 | &dce, |
| 213 | &fold, |
| 214 | &simplify, |
| 215 | }; |
| 216 | |
| 217 | for (size_t i = 0; i < arraysize(optimizations); ++i) { |
| 218 | HOptimization* optimization = optimizations[i]; |
| 219 | optimization->Run(); |
| 220 | } |
| 221 | |
| 222 | if (depth_ + 1 < kDepthLimit) { |
Nicolas Geoffray | 9437b78 | 2015-03-25 10:08:51 +0000 | [diff] [blame] | 223 | HInliner inliner(callee_graph, |
| 224 | outer_compilation_unit_, |
| 225 | dex_compilation_unit, |
| 226 | compiler_driver_, |
| 227 | stats_, |
| 228 | depth_ + 1); |
Nicolas Geoffray | ef87c5d | 2015-01-30 12:41:14 +0000 | [diff] [blame] | 229 | inliner.Run(); |
| 230 | } |
| 231 | |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 232 | HReversePostOrderIterator it(*callee_graph); |
Nicolas Geoffray | ef87c5d | 2015-01-30 12:41:14 +0000 | [diff] [blame] | 233 | it.Advance(); // Past the entry block, it does not contain instructions that prevent inlining. |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 234 | for (; !it.Done(); it.Advance()) { |
| 235 | HBasicBlock* block = it.Current(); |
| 236 | if (block->IsLoopHeader()) { |
Nicolas Geoffray | 9437b78 | 2015-03-25 10:08:51 +0000 | [diff] [blame] | 237 | VLOG(compiler) << "Method " << PrettyMethod(method_index, caller_dex_file) |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 238 | << " could not be inlined because it contains a loop"; |
Nicolas Geoffray | 4fa04a6 | 2015-05-26 14:35:06 +0100 | [diff] [blame] | 239 | resolved_method->SetShouldNotInline(); |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 240 | return false; |
| 241 | } |
| 242 | |
| 243 | for (HInstructionIterator instr_it(block->GetInstructions()); |
| 244 | !instr_it.Done(); |
| 245 | instr_it.Advance()) { |
| 246 | HInstruction* current = instr_it.Current(); |
Nicolas Geoffray | 276d9da | 2015-02-02 18:24:11 +0000 | [diff] [blame] | 247 | if (current->IsSuspendCheck()) { |
| 248 | continue; |
| 249 | } |
| 250 | |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 251 | if (current->CanThrow()) { |
Nicolas Geoffray | 9437b78 | 2015-03-25 10:08:51 +0000 | [diff] [blame] | 252 | VLOG(compiler) << "Method " << PrettyMethod(method_index, caller_dex_file) |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 253 | << " could not be inlined because " << current->DebugName() |
| 254 | << " can throw"; |
| 255 | return false; |
| 256 | } |
| 257 | |
| 258 | if (current->NeedsEnvironment()) { |
Nicolas Geoffray | 9437b78 | 2015-03-25 10:08:51 +0000 | [diff] [blame] | 259 | VLOG(compiler) << "Method " << PrettyMethod(method_index, caller_dex_file) |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 260 | << " could not be inlined because " << current->DebugName() |
| 261 | << " needs an environment"; |
| 262 | return false; |
| 263 | } |
Nicolas Geoffray | 9437b78 | 2015-03-25 10:08:51 +0000 | [diff] [blame] | 264 | |
| 265 | if (!can_use_dex_cache && current->NeedsDexCache()) { |
| 266 | VLOG(compiler) << "Method " << PrettyMethod(method_index, caller_dex_file) |
| 267 | << " could not be inlined because " << current->DebugName() |
| 268 | << " it is in a different dex file and requires access to the dex cache"; |
Nicolas Geoffray | 4fa04a6 | 2015-05-26 14:35:06 +0100 | [diff] [blame] | 269 | // Do not flag the method as not-inlineable. A caller within the same |
| 270 | // dex file could still successfully inline it. |
Nicolas Geoffray | 9437b78 | 2015-03-25 10:08:51 +0000 | [diff] [blame] | 271 | return false; |
| 272 | } |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 273 | } |
| 274 | } |
| 275 | |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 276 | callee_graph->InlineInto(graph_, invoke_instruction); |
Nicolas Geoffray | 7c5367b | 2014-12-17 10:13:46 +0000 | [diff] [blame] | 277 | |
Mark Mendell | 1152c92 | 2015-04-24 17:06:35 -0400 | [diff] [blame] | 278 | if (callee_graph->HasBoundsChecks()) { |
| 279 | graph_->SetHasBoundsChecks(true); |
Mingyao Yang | e4335eb | 2015-03-02 15:14:13 -0800 | [diff] [blame] | 280 | } |
| 281 | |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 282 | return true; |
| 283 | } |
| 284 | |
| 285 | } // namespace art |