Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 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 | |
Andreas Gampe | 53c913b | 2014-08-12 23:19:23 -0700 | [diff] [blame] | 17 | #include "frontend.h" |
| 18 | |
Andreas Gampe | 0d8ea46 | 2014-07-17 18:04:32 -0700 | [diff] [blame] | 19 | #include <cstdint> |
| 20 | |
Andreas Gampe | 53c913b | 2014-08-12 23:19:23 -0700 | [diff] [blame] | 21 | #include "backend.h" |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 22 | #include "compiler.h" |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 23 | #include "compiler_internals.h" |
| 24 | #include "driver/compiler_driver.h" |
Dave Allison | 39c3bfb | 2014-01-28 18:33:52 -0800 | [diff] [blame] | 25 | #include "driver/compiler_options.h" |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 26 | #include "mirror/object.h" |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 27 | #include "pass_driver_me_opts.h" |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 28 | #include "runtime.h" |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 29 | #include "base/logging.h" |
buzbee | a61f495 | 2013-08-23 14:27:06 -0700 | [diff] [blame] | 30 | #include "base/timing_logger.h" |
Dave Allison | 39c3bfb | 2014-01-28 18:33:52 -0800 | [diff] [blame] | 31 | #include "driver/compiler_options.h" |
Vladimir Marko | 5c96e6b | 2013-11-14 15:34:17 +0000 | [diff] [blame] | 32 | #include "dex/quick/dex_file_to_method_inliner_map.h" |
| 33 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 34 | namespace art { |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 35 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 36 | /* Default optimizer/debug setting for the compiler. */ |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 37 | static uint32_t kCompilerOptimizerDisableFlags = 0 | // Disable specific optimizations |
Serban Constantinescu | 6399968 | 2014-07-15 17:44:21 +0100 | [diff] [blame] | 38 | // (1 << kLoadStoreElimination) | |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 39 | // (1 << kLoadHoisting) | |
| 40 | // (1 << kSuppressLoads) | |
| 41 | // (1 << kNullCheckElimination) | |
Vladimir Marko | bfea9c2 | 2014-01-17 17:49:33 +0000 | [diff] [blame] | 42 | // (1 << kClassInitCheckElimination) | |
Vladimir Marko | 95a0597 | 2014-05-30 10:01:32 +0100 | [diff] [blame] | 43 | // (1 << kGlobalValueNumbering) | |
Vladimir Marko | 415ac88 | 2014-09-30 18:09:14 +0100 | [diff] [blame^] | 44 | // (1 << kLocalValueNumbering) | |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 45 | // (1 << kPromoteRegs) | |
buzbee | 30adc73 | 2014-05-09 15:10:18 -0700 | [diff] [blame] | 46 | // (1 << kTrackLiveTemps) | |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 47 | // (1 << kSafeOptimizations) | |
| 48 | // (1 << kBBOpt) | |
| 49 | // (1 << kMatch) | |
| 50 | // (1 << kPromoteCompilerTemps) | |
buzbee | 17189ac | 2013-11-08 11:07:02 -0800 | [diff] [blame] | 51 | // (1 << kSuppressExceptionEdges) | |
Vladimir Marko | 9820b7c | 2014-01-02 16:40:37 +0000 | [diff] [blame] | 52 | // (1 << kSuppressMethodInlining) | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 53 | 0; |
| 54 | |
| 55 | static uint32_t kCompilerDebugFlags = 0 | // Enable debug/testing modes |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 56 | // (1 << kDebugDisplayMissingTargets) | |
| 57 | // (1 << kDebugVerbose) | |
| 58 | // (1 << kDebugDumpCFG) | |
| 59 | // (1 << kDebugSlowFieldPath) | |
| 60 | // (1 << kDebugSlowInvokePath) | |
| 61 | // (1 << kDebugSlowStringPath) | |
| 62 | // (1 << kDebugSlowestFieldPath) | |
| 63 | // (1 << kDebugSlowestStringPath) | |
| 64 | // (1 << kDebugExerciseResolveMethod) | |
| 65 | // (1 << kDebugVerifyDataflow) | |
| 66 | // (1 << kDebugShowMemoryUsage) | |
| 67 | // (1 << kDebugShowNops) | |
| 68 | // (1 << kDebugCountOpcodes) | |
| 69 | // (1 << kDebugDumpCheckStats) | |
| 70 | // (1 << kDebugDumpBitcodeFile) | |
| 71 | // (1 << kDebugVerifyBitcode) | |
| 72 | // (1 << kDebugShowSummaryMemoryUsage) | |
buzbee | ee17e0a | 2013-07-31 10:47:37 -0700 | [diff] [blame] | 73 | // (1 << kDebugShowFilterStats) | |
buzbee | a61f495 | 2013-08-23 14:27:06 -0700 | [diff] [blame] | 74 | // (1 << kDebugTimings) | |
buzbee | b01bf15 | 2014-05-13 15:59:07 -0700 | [diff] [blame] | 75 | // (1 << kDebugCodegenDump) | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 76 | 0; |
| 77 | |
Ian Rogers | 3d50407 | 2014-03-01 09:16:49 -0800 | [diff] [blame] | 78 | static CompiledMethod* CompileMethod(CompilerDriver& driver, |
Andreas Gampe | 53c913b | 2014-08-12 23:19:23 -0700 | [diff] [blame] | 79 | const Compiler* compiler, |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 80 | const DexFile::CodeItem* code_item, |
| 81 | uint32_t access_flags, InvokeType invoke_type, |
Ian Rogers | 8b2c0b9 | 2013-09-19 02:56:49 -0700 | [diff] [blame] | 82 | uint16_t class_def_idx, uint32_t method_idx, |
Nicolas Geoffray | f5df897 | 2014-02-14 18:37:08 +0000 | [diff] [blame] | 83 | jobject class_loader, const DexFile& dex_file, |
| 84 | void* llvm_compilation_unit) { |
Ian Rogers | 1ff3c98 | 2014-08-12 02:30:58 -0700 | [diff] [blame] | 85 | VLOG(compiler) << "Compiling " << PrettyMethod(method_idx, dex_file) << "..."; |
buzbee | 497d62e | 2014-09-17 13:23:58 -0700 | [diff] [blame] | 86 | /* |
| 87 | * Skip compilation for pathologically large methods - either by instruction count or num vregs. |
| 88 | * Dalvik uses 16-bit uints for instruction and register counts. We'll limit to a quarter |
| 89 | * of that, which also guarantees we cannot overflow our 16-bit internal SSA name space. |
| 90 | */ |
| 91 | if (code_item->insns_size_in_code_units_ >= UINT16_MAX / 4) { |
| 92 | LOG(INFO) << "Method exceeds compiler instruction limit: " |
| 93 | << code_item->insns_size_in_code_units_ |
Ian Rogers | 1ff3c98 | 2014-08-12 02:30:58 -0700 | [diff] [blame] | 94 | << " in " << PrettyMethod(method_idx, dex_file); |
buzbee | b48819d | 2013-09-14 16:15:25 -0700 | [diff] [blame] | 95 | return NULL; |
| 96 | } |
buzbee | 497d62e | 2014-09-17 13:23:58 -0700 | [diff] [blame] | 97 | if (code_item->registers_size_ >= UINT16_MAX / 4) { |
| 98 | LOG(INFO) << "Method exceeds compiler virtual register limit: " |
| 99 | << code_item->registers_size_ << " in " << PrettyMethod(method_idx, dex_file); |
| 100 | return NULL; |
| 101 | } |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 102 | |
Jeff Hao | 4a200f5 | 2014-04-01 14:58:49 -0700 | [diff] [blame] | 103 | if (!driver.GetCompilerOptions().IsCompilationEnabled()) { |
Ian Rogers | a03de6d | 2014-03-08 23:37:07 +0000 | [diff] [blame] | 104 | return nullptr; |
| 105 | } |
| 106 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 107 | ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); |
Ian Rogers | 3d50407 | 2014-03-01 09:16:49 -0800 | [diff] [blame] | 108 | CompilationUnit cu(driver.GetArenaPool()); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 109 | |
Ian Rogers | 3d50407 | 2014-03-01 09:16:49 -0800 | [diff] [blame] | 110 | cu.compiler_driver = &driver; |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 111 | cu.class_linker = class_linker; |
Ian Rogers | 3d50407 | 2014-03-01 09:16:49 -0800 | [diff] [blame] | 112 | cu.instruction_set = driver.GetInstructionSet(); |
Mathieu Chartier | 53bee42 | 2014-04-04 16:10:05 -0700 | [diff] [blame] | 113 | if (cu.instruction_set == kArm) { |
| 114 | cu.instruction_set = kThumb2; |
| 115 | } |
Andreas Gampe | af13ad9 | 2014-04-11 12:07:48 -0700 | [diff] [blame] | 116 | cu.target64 = Is64BitInstructionSet(cu.instruction_set); |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 117 | cu.compiler = compiler; |
Andreas Gampe | 00caeed | 2014-07-10 01:43:08 -0700 | [diff] [blame] | 118 | // TODO: Mips64 is not yet implemented. |
Mathieu Chartier | 53bee42 | 2014-04-04 16:10:05 -0700 | [diff] [blame] | 119 | CHECK((cu.instruction_set == kThumb2) || |
Zheng Xu | 9e06c8c | 2014-05-06 18:06:07 +0100 | [diff] [blame] | 120 | (cu.instruction_set == kArm64) || |
Mathieu Chartier | 53bee42 | 2014-04-04 16:10:05 -0700 | [diff] [blame] | 121 | (cu.instruction_set == kX86) || |
| 122 | (cu.instruction_set == kX86_64) || |
| 123 | (cu.instruction_set == kMips)); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 124 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 125 | // TODO: set this from command line |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 126 | cu.compiler_flip_match = false; |
| 127 | bool use_match = !cu.compiler_method_match.empty(); |
| 128 | bool match = use_match && (cu.compiler_flip_match ^ |
Ian Rogers | 1ff3c98 | 2014-08-12 02:30:58 -0700 | [diff] [blame] | 129 | (PrettyMethod(method_idx, dex_file).find(cu.compiler_method_match) != std::string::npos)); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 130 | if (!use_match || match) { |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 131 | cu.disable_opt = kCompilerOptimizerDisableFlags; |
| 132 | cu.enable_debug = kCompilerDebugFlags; |
| 133 | cu.verbose = VLOG_IS_ON(compiler) || |
| 134 | (cu.enable_debug & (1 << kDebugVerbose)); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 135 | } |
| 136 | |
Mingyao Yang | 42d65c5 | 2014-04-18 16:49:39 -0700 | [diff] [blame] | 137 | if (gVerboseMethods.size() != 0) { |
| 138 | cu.verbose = false; |
| 139 | for (size_t i = 0; i < gVerboseMethods.size(); ++i) { |
Ian Rogers | 1ff3c98 | 2014-08-12 02:30:58 -0700 | [diff] [blame] | 140 | if (PrettyMethod(method_idx, dex_file).find(gVerboseMethods[i]) |
Mingyao Yang | 42d65c5 | 2014-04-18 16:49:39 -0700 | [diff] [blame] | 141 | != std::string::npos) { |
| 142 | cu.verbose = true; |
| 143 | break; |
| 144 | } |
| 145 | } |
| 146 | } |
| 147 | |
buzbee | b01bf15 | 2014-05-13 15:59:07 -0700 | [diff] [blame] | 148 | if (cu.verbose) { |
| 149 | cu.enable_debug |= (1 << kDebugCodegenDump); |
| 150 | } |
| 151 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 152 | /* |
| 153 | * TODO: rework handling of optimization and debug flags. Should we split out |
| 154 | * MIR and backend flags? Need command-line setting as well. |
| 155 | */ |
| 156 | |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 157 | compiler->InitCompilationUnit(cu); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 158 | |
buzbee | a61f495 | 2013-08-23 14:27:06 -0700 | [diff] [blame] | 159 | cu.StartTimingSplit("BuildMIRGraph"); |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 160 | cu.mir_graph.reset(new MIRGraph(&cu, &cu.arena)); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 161 | |
Razvan A Lupusoru | da7a69b | 2014-01-08 15:09:50 -0800 | [diff] [blame] | 162 | /* |
| 163 | * After creation of the MIR graph, also create the code generator. |
| 164 | * The reason we do this is that optimizations on the MIR graph may need to get information |
| 165 | * that is only available if a CG exists. |
| 166 | */ |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 167 | cu.cg.reset(compiler->GetCodeGenerator(&cu, llvm_compilation_unit)); |
Razvan A Lupusoru | da7a69b | 2014-01-08 15:09:50 -0800 | [diff] [blame] | 168 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 169 | /* Gathering opcode stats? */ |
| 170 | if (kCompilerDebugFlags & (1 << kDebugCountOpcodes)) { |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 171 | cu.mir_graph->EnableOpcodeCounting(); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | /* Build the raw MIR graph */ |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 175 | cu.mir_graph->InlineMethod(code_item, access_flags, invoke_type, class_def_idx, method_idx, |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 176 | class_loader, dex_file); |
| 177 | |
Andreas Gampe | 53c913b | 2014-08-12 23:19:23 -0700 | [diff] [blame] | 178 | if (!compiler->CanCompileMethod(method_idx, dex_file, &cu)) { |
Ian Rogers | 1ff3c98 | 2014-08-12 02:30:58 -0700 | [diff] [blame] | 179 | VLOG(compiler) << cu.instruction_set << ": Cannot compile method : " |
| 180 | << PrettyMethod(method_idx, dex_file); |
Zheng Xu | 9e06c8c | 2014-05-06 18:06:07 +0100 | [diff] [blame] | 181 | return nullptr; |
| 182 | } |
| 183 | |
buzbee | 1da1e2f | 2013-11-15 13:37:01 -0800 | [diff] [blame] | 184 | cu.NewTimingSplit("MIROpt:CheckFilters"); |
Andreas Gampe | 060e6fe | 2014-06-19 11:34:06 -0700 | [diff] [blame] | 185 | std::string skip_message; |
| 186 | if (cu.mir_graph->SkipCompilation(&skip_message)) { |
| 187 | VLOG(compiler) << cu.instruction_set << ": Skipping method : " |
Ian Rogers | 1ff3c98 | 2014-08-12 02:30:58 -0700 | [diff] [blame] | 188 | << PrettyMethod(method_idx, dex_file) << " Reason = " << skip_message; |
buzbee | 33ae558 | 2014-06-12 14:56:32 -0700 | [diff] [blame] | 189 | return nullptr; |
buzbee | ee17e0a | 2013-07-31 10:47:37 -0700 | [diff] [blame] | 190 | } |
| 191 | |
Jean Christophe Beyler | 4e97c53 | 2014-01-07 10:07:18 -0800 | [diff] [blame] | 192 | /* Create the pass driver and launch it */ |
Jean Christophe Beyler | 2469e60 | 2014-05-06 20:36:55 -0700 | [diff] [blame] | 193 | PassDriverMEOpts pass_driver(&cu); |
Ian Rogers | 3d50407 | 2014-03-01 09:16:49 -0800 | [diff] [blame] | 194 | pass_driver.Launch(); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 195 | |
Calin Juravle | 38a0904 | 2014-06-23 14:40:31 +0100 | [diff] [blame] | 196 | /* For non-leaf methods check if we should skip compilation when the profiler is enabled. */ |
| 197 | if (cu.compiler_driver->ProfilePresent() |
| 198 | && !cu.mir_graph->MethodIsLeaf() |
Ian Rogers | 1ff3c98 | 2014-08-12 02:30:58 -0700 | [diff] [blame] | 199 | && cu.mir_graph->SkipCompilationByName(PrettyMethod(method_idx, dex_file))) { |
Calin Juravle | 38a0904 | 2014-06-23 14:40:31 +0100 | [diff] [blame] | 200 | return nullptr; |
| 201 | } |
| 202 | |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 203 | if (cu.enable_debug & (1 << kDebugDumpCheckStats)) { |
| 204 | cu.mir_graph->DumpCheckStats(); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 205 | } |
| 206 | |
| 207 | if (kCompilerDebugFlags & (1 << kDebugCountOpcodes)) { |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 208 | cu.mir_graph->ShowOpcodeStats(); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 209 | } |
| 210 | |
buzbee | 1da1e2f | 2013-11-15 13:37:01 -0800 | [diff] [blame] | 211 | /* Reassociate sreg names with original Dalvik vreg names. */ |
| 212 | cu.mir_graph->RemapRegLocations(); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 213 | |
Vladimir Marko | 53b6afc | 2014-03-21 14:21:20 +0000 | [diff] [blame] | 214 | /* Free Arenas from the cu.arena_stack for reuse by the cu.arena in the codegen. */ |
| 215 | if (cu.enable_debug & (1 << kDebugShowMemoryUsage)) { |
Vladimir Marko | b19955d | 2014-07-29 12:04:10 +0100 | [diff] [blame] | 216 | if (cu.arena_stack.PeakBytesAllocated() > 1 * 1024 * 1024) { |
Vladimir Marko | 53b6afc | 2014-03-21 14:21:20 +0000 | [diff] [blame] | 217 | MemStats stack_stats(cu.arena_stack.GetPeakStats()); |
Ian Rogers | 1ff3c98 | 2014-08-12 02:30:58 -0700 | [diff] [blame] | 218 | LOG(INFO) << PrettyMethod(method_idx, dex_file) << " " << Dumpable<MemStats>(stack_stats); |
Vladimir Marko | 53b6afc | 2014-03-21 14:21:20 +0000 | [diff] [blame] | 219 | } |
| 220 | } |
| 221 | cu.arena_stack.Reset(); |
| 222 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 223 | CompiledMethod* result = NULL; |
| 224 | |
buzbee | 8c7a02a | 2014-06-14 12:33:09 -0700 | [diff] [blame] | 225 | if (cu.mir_graph->PuntToInterpreter()) { |
Ian Rogers | 1ff3c98 | 2014-08-12 02:30:58 -0700 | [diff] [blame] | 226 | VLOG(compiler) << cu.instruction_set << ": Punted method to interpreter: " |
| 227 | << PrettyMethod(method_idx, dex_file); |
Andreas Gampe | 060e6fe | 2014-06-19 11:34:06 -0700 | [diff] [blame] | 228 | return nullptr; |
buzbee | 8c7a02a | 2014-06-14 12:33:09 -0700 | [diff] [blame] | 229 | } |
| 230 | |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 231 | cu.cg->Materialize(); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 232 | |
buzbee | 1da1e2f | 2013-11-15 13:37:01 -0800 | [diff] [blame] | 233 | cu.NewTimingSplit("Dedupe"); /* deduping takes up the vast majority of time in GetCompiledMethod(). */ |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 234 | result = cu.cg->GetCompiledMethod(); |
buzbee | 1da1e2f | 2013-11-15 13:37:01 -0800 | [diff] [blame] | 235 | cu.NewTimingSplit("Cleanup"); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 236 | |
| 237 | if (result) { |
Ian Rogers | 1ff3c98 | 2014-08-12 02:30:58 -0700 | [diff] [blame] | 238 | VLOG(compiler) << cu.instruction_set << ": Compiled " << PrettyMethod(method_idx, dex_file); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 239 | } else { |
Ian Rogers | 1ff3c98 | 2014-08-12 02:30:58 -0700 | [diff] [blame] | 240 | VLOG(compiler) << cu.instruction_set << ": Deferred " << PrettyMethod(method_idx, dex_file); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 241 | } |
| 242 | |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 243 | if (cu.enable_debug & (1 << kDebugShowMemoryUsage)) { |
Vladimir Marko | 53b6afc | 2014-03-21 14:21:20 +0000 | [diff] [blame] | 244 | if (cu.arena.BytesAllocated() > (1 * 1024 *1024)) { |
Vladimir Marko | 83cc7ae | 2014-02-12 18:02:05 +0000 | [diff] [blame] | 245 | MemStats mem_stats(cu.arena.GetMemStats()); |
Ian Rogers | 1ff3c98 | 2014-08-12 02:30:58 -0700 | [diff] [blame] | 246 | LOG(INFO) << PrettyMethod(method_idx, dex_file) << " " << Dumpable<MemStats>(mem_stats); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 247 | } |
| 248 | } |
| 249 | |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 250 | if (cu.enable_debug & (1 << kDebugShowSummaryMemoryUsage)) { |
| 251 | LOG(INFO) << "MEMINFO " << cu.arena.BytesAllocated() << " " << cu.mir_graph->GetNumBlocks() |
Ian Rogers | 1ff3c98 | 2014-08-12 02:30:58 -0700 | [diff] [blame] | 252 | << " " << PrettyMethod(method_idx, dex_file); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 253 | } |
| 254 | |
buzbee | a61f495 | 2013-08-23 14:27:06 -0700 | [diff] [blame] | 255 | cu.EndTiming(); |
Ian Rogers | 3d50407 | 2014-03-01 09:16:49 -0800 | [diff] [blame] | 256 | driver.GetTimingsLogger()->AddLogger(cu.timings); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 257 | return result; |
| 258 | } |
| 259 | |
Andreas Gampe | 53c913b | 2014-08-12 23:19:23 -0700 | [diff] [blame] | 260 | CompiledMethod* CompileOneMethod(CompilerDriver* driver, |
| 261 | const Compiler* compiler, |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 262 | const DexFile::CodeItem* code_item, |
| 263 | uint32_t access_flags, |
| 264 | InvokeType invoke_type, |
Ian Rogers | 8b2c0b9 | 2013-09-19 02:56:49 -0700 | [diff] [blame] | 265 | uint16_t class_def_idx, |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 266 | uint32_t method_idx, |
| 267 | jobject class_loader, |
| 268 | const DexFile& dex_file, |
Nicolas Geoffray | f5df897 | 2014-02-14 18:37:08 +0000 | [diff] [blame] | 269 | void* compilation_unit) { |
Andreas Gampe | 53c913b | 2014-08-12 23:19:23 -0700 | [diff] [blame] | 270 | return CompileMethod(*driver, compiler, code_item, access_flags, invoke_type, class_def_idx, |
Nicolas Geoffray | f5df897 | 2014-02-14 18:37:08 +0000 | [diff] [blame] | 271 | method_idx, class_loader, dex_file, compilation_unit); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 272 | } |
| 273 | |
| 274 | } // namespace art |