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 | |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 17 | #include "compiler.h" |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 18 | #include "compiler_internals.h" |
| 19 | #include "driver/compiler_driver.h" |
Dave Allison | 39c3bfb | 2014-01-28 18:33:52 -0800 | [diff] [blame] | 20 | #include "driver/compiler_options.h" |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 21 | #include "dataflow_iterator-inl.h" |
| 22 | #include "leb128.h" |
| 23 | #include "mirror/object.h" |
Jean Christophe Beyler | 4e97c53 | 2014-01-07 10:07:18 -0800 | [diff] [blame] | 24 | #include "pass_driver.h" |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 25 | #include "runtime.h" |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 26 | #include "base/logging.h" |
buzbee | a61f495 | 2013-08-23 14:27:06 -0700 | [diff] [blame] | 27 | #include "base/timing_logger.h" |
Dave Allison | 39c3bfb | 2014-01-28 18:33:52 -0800 | [diff] [blame] | 28 | #include "driver/compiler_options.h" |
Vladimir Marko | 5c96e6b | 2013-11-14 15:34:17 +0000 | [diff] [blame] | 29 | #include "dex/quick/dex_file_to_method_inliner_map.h" |
| 30 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 31 | namespace art { |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 32 | |
Ian Rogers | 72d3262 | 2014-05-06 16:20:11 -0700 | [diff] [blame] | 33 | extern "C" void ArtInitQuickCompilerContext(art::CompilerDriver* driver) { |
| 34 | CHECK(driver->GetCompilerContext() == nullptr); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 35 | } |
| 36 | |
Ian Rogers | 72d3262 | 2014-05-06 16:20:11 -0700 | [diff] [blame] | 37 | extern "C" void ArtUnInitQuickCompilerContext(art::CompilerDriver* driver) { |
| 38 | CHECK(driver->GetCompilerContext() == nullptr); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | /* Default optimizer/debug setting for the compiler. */ |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 42 | static uint32_t kCompilerOptimizerDisableFlags = 0 | // Disable specific optimizations |
buzbee | 091cc40 | 2014-03-31 10:14:40 -0700 | [diff] [blame] | 43 | (1 << kLoadStoreElimination) | // TODO: this pass has been broken for awhile - fix or delete. |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 44 | // (1 << kLoadHoisting) | |
| 45 | // (1 << kSuppressLoads) | |
| 46 | // (1 << kNullCheckElimination) | |
Vladimir Marko | bfea9c2 | 2014-01-17 17:49:33 +0000 | [diff] [blame] | 47 | // (1 << kClassInitCheckElimination) | |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 48 | // (1 << kPromoteRegs) | |
buzbee | 091cc40 | 2014-03-31 10:14:40 -0700 | [diff] [blame] | 49 | (1 << kTrackLiveTemps) | // FIXME: disable until liveness issue fixed. |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 50 | // (1 << kSafeOptimizations) | |
| 51 | // (1 << kBBOpt) | |
| 52 | // (1 << kMatch) | |
| 53 | // (1 << kPromoteCompilerTemps) | |
buzbee | 17189ac | 2013-11-08 11:07:02 -0800 | [diff] [blame] | 54 | // (1 << kSuppressExceptionEdges) | |
Vladimir Marko | 9820b7c | 2014-01-02 16:40:37 +0000 | [diff] [blame] | 55 | // (1 << kSuppressMethodInlining) | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 56 | 0; |
| 57 | |
| 58 | static uint32_t kCompilerDebugFlags = 0 | // Enable debug/testing modes |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 59 | // (1 << kDebugDisplayMissingTargets) | |
| 60 | // (1 << kDebugVerbose) | |
| 61 | // (1 << kDebugDumpCFG) | |
| 62 | // (1 << kDebugSlowFieldPath) | |
| 63 | // (1 << kDebugSlowInvokePath) | |
| 64 | // (1 << kDebugSlowStringPath) | |
| 65 | // (1 << kDebugSlowestFieldPath) | |
| 66 | // (1 << kDebugSlowestStringPath) | |
| 67 | // (1 << kDebugExerciseResolveMethod) | |
| 68 | // (1 << kDebugVerifyDataflow) | |
| 69 | // (1 << kDebugShowMemoryUsage) | |
| 70 | // (1 << kDebugShowNops) | |
| 71 | // (1 << kDebugCountOpcodes) | |
| 72 | // (1 << kDebugDumpCheckStats) | |
| 73 | // (1 << kDebugDumpBitcodeFile) | |
| 74 | // (1 << kDebugVerifyBitcode) | |
| 75 | // (1 << kDebugShowSummaryMemoryUsage) | |
buzbee | ee17e0a | 2013-07-31 10:47:37 -0700 | [diff] [blame] | 76 | // (1 << kDebugShowFilterStats) | |
buzbee | a61f495 | 2013-08-23 14:27:06 -0700 | [diff] [blame] | 77 | // (1 << kDebugTimings) | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 78 | 0; |
| 79 | |
Vladimir Marko | 25724ef | 2013-11-12 15:09:20 +0000 | [diff] [blame] | 80 | CompilationUnit::CompilationUnit(ArenaPool* pool) |
| 81 | : compiler_driver(NULL), |
| 82 | class_linker(NULL), |
| 83 | dex_file(NULL), |
| 84 | class_loader(NULL), |
| 85 | class_def_idx(0), |
| 86 | method_idx(0), |
| 87 | code_item(NULL), |
| 88 | access_flags(0), |
| 89 | invoke_type(kDirect), |
| 90 | shorty(NULL), |
| 91 | disable_opt(0), |
| 92 | enable_debug(0), |
| 93 | verbose(false), |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 94 | compiler(NULL), |
Vladimir Marko | 25724ef | 2013-11-12 15:09:20 +0000 | [diff] [blame] | 95 | instruction_set(kNone), |
| 96 | num_dalvik_registers(0), |
| 97 | insns(NULL), |
| 98 | num_ins(0), |
| 99 | num_outs(0), |
| 100 | num_regs(0), |
Vladimir Marko | 25724ef | 2013-11-12 15:09:20 +0000 | [diff] [blame] | 101 | compiler_flip_match(false), |
| 102 | arena(pool), |
Vladimir Marko | 83cc7ae | 2014-02-12 18:02:05 +0000 | [diff] [blame] | 103 | arena_stack(pool), |
Vladimir Marko | 25724ef | 2013-11-12 15:09:20 +0000 | [diff] [blame] | 104 | mir_graph(NULL), |
| 105 | cg(NULL), |
| 106 | timings("QuickCompiler", true, false) { |
| 107 | } |
| 108 | |
| 109 | CompilationUnit::~CompilationUnit() { |
| 110 | } |
| 111 | |
buzbee | a61f495 | 2013-08-23 14:27:06 -0700 | [diff] [blame] | 112 | void CompilationUnit::StartTimingSplit(const char* label) { |
Nicolas Geoffray | ea3fa0b | 2014-02-10 11:59:41 +0000 | [diff] [blame] | 113 | if (compiler_driver->GetDumpPasses()) { |
buzbee | a61f495 | 2013-08-23 14:27:06 -0700 | [diff] [blame] | 114 | timings.StartSplit(label); |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | void CompilationUnit::NewTimingSplit(const char* label) { |
Nicolas Geoffray | ea3fa0b | 2014-02-10 11:59:41 +0000 | [diff] [blame] | 119 | if (compiler_driver->GetDumpPasses()) { |
buzbee | a61f495 | 2013-08-23 14:27:06 -0700 | [diff] [blame] | 120 | timings.NewSplit(label); |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | void CompilationUnit::EndTiming() { |
Nicolas Geoffray | ea3fa0b | 2014-02-10 11:59:41 +0000 | [diff] [blame] | 125 | if (compiler_driver->GetDumpPasses()) { |
buzbee | a61f495 | 2013-08-23 14:27:06 -0700 | [diff] [blame] | 126 | timings.EndSplit(); |
Nicolas Geoffray | ea3fa0b | 2014-02-10 11:59:41 +0000 | [diff] [blame] | 127 | if (enable_debug & (1 << kDebugTimings)) { |
| 128 | LOG(INFO) << "TIMINGS " << PrettyMethod(method_idx, *dex_file); |
| 129 | LOG(INFO) << Dumpable<TimingLogger>(timings); |
| 130 | } |
buzbee | a61f495 | 2013-08-23 14:27:06 -0700 | [diff] [blame] | 131 | } |
| 132 | } |
| 133 | |
Zheng Xu | 9e06c8c | 2014-05-06 18:06:07 +0100 | [diff] [blame] | 134 | // TODO: Remove this when we are able to compile everything. |
| 135 | int arm64_support_list[] = { |
| 136 | Instruction::NOP, |
| 137 | // Instruction::MOVE, |
| 138 | // Instruction::MOVE_FROM16, |
| 139 | // Instruction::MOVE_16, |
| 140 | // Instruction::MOVE_WIDE, |
| 141 | // Instruction::MOVE_WIDE_FROM16, |
| 142 | // Instruction::MOVE_WIDE_16, |
| 143 | // Instruction::MOVE_OBJECT, |
| 144 | // Instruction::MOVE_OBJECT_FROM16, |
| 145 | // Instruction::MOVE_OBJECT_16, |
| 146 | // Instruction::MOVE_RESULT, |
| 147 | // Instruction::MOVE_RESULT_WIDE, |
| 148 | // Instruction::MOVE_RESULT_OBJECT, |
| 149 | // Instruction::MOVE_EXCEPTION, |
| 150 | // Instruction::RETURN_VOID, |
| 151 | // Instruction::RETURN, |
| 152 | // Instruction::RETURN_WIDE, |
| 153 | // Instruction::RETURN_OBJECT, |
| 154 | // Instruction::CONST_4, |
| 155 | // Instruction::CONST_16, |
| 156 | // Instruction::CONST, |
| 157 | // Instruction::CONST_HIGH16, |
| 158 | // Instruction::CONST_WIDE_16, |
| 159 | // Instruction::CONST_WIDE_32, |
| 160 | // Instruction::CONST_WIDE, |
| 161 | // Instruction::CONST_WIDE_HIGH16, |
| 162 | // Instruction::CONST_STRING, |
| 163 | // Instruction::CONST_STRING_JUMBO, |
| 164 | // Instruction::CONST_CLASS, |
| 165 | // Instruction::MONITOR_ENTER, |
| 166 | // Instruction::MONITOR_EXIT, |
| 167 | // Instruction::CHECK_CAST, |
| 168 | // Instruction::INSTANCE_OF, |
| 169 | // Instruction::ARRAY_LENGTH, |
| 170 | // Instruction::NEW_INSTANCE, |
| 171 | // Instruction::NEW_ARRAY, |
| 172 | // Instruction::FILLED_NEW_ARRAY, |
| 173 | // Instruction::FILLED_NEW_ARRAY_RANGE, |
| 174 | // Instruction::FILL_ARRAY_DATA, |
| 175 | // Instruction::THROW, |
| 176 | // Instruction::GOTO, |
| 177 | // Instruction::GOTO_16, |
| 178 | // Instruction::GOTO_32, |
| 179 | // Instruction::PACKED_SWITCH, |
| 180 | // Instruction::SPARSE_SWITCH, |
| 181 | // Instruction::CMPL_FLOAT, |
| 182 | // Instruction::CMPG_FLOAT, |
| 183 | // Instruction::CMPL_DOUBLE, |
| 184 | // Instruction::CMPG_DOUBLE, |
| 185 | // Instruction::CMP_LONG, |
| 186 | // Instruction::IF_EQ, |
| 187 | // Instruction::IF_NE, |
| 188 | // Instruction::IF_LT, |
| 189 | // Instruction::IF_GE, |
| 190 | // Instruction::IF_GT, |
| 191 | // Instruction::IF_LE, |
| 192 | // Instruction::IF_EQZ, |
| 193 | // Instruction::IF_NEZ, |
| 194 | // Instruction::IF_LTZ, |
| 195 | // Instruction::IF_GEZ, |
| 196 | // Instruction::IF_GTZ, |
| 197 | // Instruction::IF_LEZ, |
| 198 | // Instruction::UNUSED_3E, |
| 199 | // Instruction::UNUSED_3F, |
| 200 | // Instruction::UNUSED_40, |
| 201 | // Instruction::UNUSED_41, |
| 202 | // Instruction::UNUSED_42, |
| 203 | // Instruction::UNUSED_43, |
| 204 | // Instruction::AGET, |
| 205 | // Instruction::AGET_WIDE, |
| 206 | // Instruction::AGET_OBJECT, |
| 207 | // Instruction::AGET_BOOLEAN, |
| 208 | // Instruction::AGET_BYTE, |
| 209 | // Instruction::AGET_CHAR, |
| 210 | // Instruction::AGET_SHORT, |
| 211 | // Instruction::APUT, |
| 212 | // Instruction::APUT_WIDE, |
| 213 | // Instruction::APUT_OBJECT, |
| 214 | // Instruction::APUT_BOOLEAN, |
| 215 | // Instruction::APUT_BYTE, |
| 216 | // Instruction::APUT_CHAR, |
| 217 | // Instruction::APUT_SHORT, |
| 218 | // Instruction::IGET, |
| 219 | // Instruction::IGET_WIDE, |
| 220 | // Instruction::IGET_OBJECT, |
| 221 | // Instruction::IGET_BOOLEAN, |
| 222 | // Instruction::IGET_BYTE, |
| 223 | // Instruction::IGET_CHAR, |
| 224 | // Instruction::IGET_SHORT, |
| 225 | // Instruction::IPUT, |
| 226 | // Instruction::IPUT_WIDE, |
| 227 | // Instruction::IPUT_OBJECT, |
| 228 | // Instruction::IPUT_BOOLEAN, |
| 229 | // Instruction::IPUT_BYTE, |
| 230 | // Instruction::IPUT_CHAR, |
| 231 | // Instruction::IPUT_SHORT, |
| 232 | // Instruction::SGET, |
| 233 | // Instruction::SGET_WIDE, |
| 234 | // Instruction::SGET_OBJECT, |
| 235 | // Instruction::SGET_BOOLEAN, |
| 236 | // Instruction::SGET_BYTE, |
| 237 | // Instruction::SGET_CHAR, |
| 238 | // Instruction::SGET_SHORT, |
| 239 | // Instruction::SPUT, |
| 240 | // Instruction::SPUT_WIDE, |
| 241 | // Instruction::SPUT_OBJECT, |
| 242 | // Instruction::SPUT_BOOLEAN, |
| 243 | // Instruction::SPUT_BYTE, |
| 244 | // Instruction::SPUT_CHAR, |
| 245 | // Instruction::SPUT_SHORT, |
| 246 | Instruction::INVOKE_VIRTUAL, |
| 247 | Instruction::INVOKE_SUPER, |
| 248 | Instruction::INVOKE_DIRECT, |
| 249 | Instruction::INVOKE_STATIC, |
| 250 | Instruction::INVOKE_INTERFACE, |
| 251 | // Instruction::RETURN_VOID_BARRIER, |
| 252 | // Instruction::INVOKE_VIRTUAL_RANGE, |
| 253 | // Instruction::INVOKE_SUPER_RANGE, |
| 254 | // Instruction::INVOKE_DIRECT_RANGE, |
| 255 | // Instruction::INVOKE_STATIC_RANGE, |
| 256 | // Instruction::INVOKE_INTERFACE_RANGE, |
| 257 | // Instruction::UNUSED_79, |
| 258 | // Instruction::UNUSED_7A, |
| 259 | // Instruction::NEG_INT, |
| 260 | // Instruction::NOT_INT, |
| 261 | // Instruction::NEG_LONG, |
| 262 | // Instruction::NOT_LONG, |
| 263 | // Instruction::NEG_FLOAT, |
| 264 | // Instruction::NEG_DOUBLE, |
| 265 | // Instruction::INT_TO_LONG, |
| 266 | // Instruction::INT_TO_FLOAT, |
| 267 | // Instruction::INT_TO_DOUBLE, |
| 268 | // Instruction::LONG_TO_INT, |
| 269 | // Instruction::LONG_TO_FLOAT, |
| 270 | // Instruction::LONG_TO_DOUBLE, |
| 271 | // Instruction::FLOAT_TO_INT, |
| 272 | // Instruction::FLOAT_TO_LONG, |
| 273 | // Instruction::FLOAT_TO_DOUBLE, |
| 274 | // Instruction::DOUBLE_TO_INT, |
| 275 | // Instruction::DOUBLE_TO_LONG, |
| 276 | // Instruction::DOUBLE_TO_FLOAT, |
| 277 | // Instruction::INT_TO_BYTE, |
| 278 | // Instruction::INT_TO_CHAR, |
| 279 | // Instruction::INT_TO_SHORT, |
| 280 | // Instruction::ADD_INT, |
| 281 | // Instruction::SUB_INT, |
| 282 | // Instruction::MUL_INT, |
| 283 | // Instruction::DIV_INT, |
| 284 | // Instruction::REM_INT, |
| 285 | // Instruction::AND_INT, |
| 286 | // Instruction::OR_INT, |
| 287 | // Instruction::XOR_INT, |
| 288 | // Instruction::SHL_INT, |
| 289 | // Instruction::SHR_INT, |
| 290 | // Instruction::USHR_INT, |
| 291 | // Instruction::ADD_LONG, |
| 292 | // Instruction::SUB_LONG, |
| 293 | // Instruction::MUL_LONG, |
| 294 | // Instruction::DIV_LONG, |
| 295 | // Instruction::REM_LONG, |
| 296 | // Instruction::AND_LONG, |
| 297 | // Instruction::OR_LONG, |
| 298 | // Instruction::XOR_LONG, |
| 299 | // Instruction::SHL_LONG, |
| 300 | // Instruction::SHR_LONG, |
| 301 | // Instruction::USHR_LONG, |
| 302 | // Instruction::ADD_FLOAT, |
| 303 | // Instruction::SUB_FLOAT, |
| 304 | // Instruction::MUL_FLOAT, |
| 305 | // Instruction::DIV_FLOAT, |
| 306 | // Instruction::REM_FLOAT, |
| 307 | // Instruction::ADD_DOUBLE, |
| 308 | // Instruction::SUB_DOUBLE, |
| 309 | // Instruction::MUL_DOUBLE, |
| 310 | // Instruction::DIV_DOUBLE, |
| 311 | // Instruction::REM_DOUBLE, |
| 312 | // Instruction::ADD_INT_2ADDR, |
| 313 | // Instruction::SUB_INT_2ADDR, |
| 314 | // Instruction::MUL_INT_2ADDR, |
| 315 | // Instruction::DIV_INT_2ADDR, |
| 316 | // Instruction::REM_INT_2ADDR, |
| 317 | // Instruction::AND_INT_2ADDR, |
| 318 | // Instruction::OR_INT_2ADDR, |
| 319 | // Instruction::XOR_INT_2ADDR, |
| 320 | // Instruction::SHL_INT_2ADDR, |
| 321 | // Instruction::SHR_INT_2ADDR, |
| 322 | // Instruction::USHR_INT_2ADDR, |
| 323 | // Instruction::ADD_LONG_2ADDR, |
| 324 | // Instruction::SUB_LONG_2ADDR, |
| 325 | // Instruction::MUL_LONG_2ADDR, |
| 326 | // Instruction::DIV_LONG_2ADDR, |
| 327 | // Instruction::REM_LONG_2ADDR, |
| 328 | // Instruction::AND_LONG_2ADDR, |
| 329 | // Instruction::OR_LONG_2ADDR, |
| 330 | // Instruction::XOR_LONG_2ADDR, |
| 331 | // Instruction::SHL_LONG_2ADDR, |
| 332 | // Instruction::SHR_LONG_2ADDR, |
| 333 | // Instruction::USHR_LONG_2ADDR, |
| 334 | // Instruction::ADD_FLOAT_2ADDR, |
| 335 | // Instruction::SUB_FLOAT_2ADDR, |
| 336 | // Instruction::MUL_FLOAT_2ADDR, |
| 337 | // Instruction::DIV_FLOAT_2ADDR, |
| 338 | // Instruction::REM_FLOAT_2ADDR, |
| 339 | // Instruction::ADD_DOUBLE_2ADDR, |
| 340 | // Instruction::SUB_DOUBLE_2ADDR, |
| 341 | // Instruction::MUL_DOUBLE_2ADDR, |
| 342 | // Instruction::DIV_DOUBLE_2ADDR, |
| 343 | // Instruction::REM_DOUBLE_2ADDR, |
| 344 | // Instruction::ADD_INT_LIT16, |
| 345 | // Instruction::RSUB_INT, |
| 346 | // Instruction::MUL_INT_LIT16, |
| 347 | // Instruction::DIV_INT_LIT16, |
| 348 | // Instruction::REM_INT_LIT16, |
| 349 | // Instruction::AND_INT_LIT16, |
| 350 | // Instruction::OR_INT_LIT16, |
| 351 | // Instruction::XOR_INT_LIT16, |
| 352 | // Instruction::ADD_INT_LIT8, |
| 353 | // Instruction::RSUB_INT_LIT8, |
| 354 | // Instruction::MUL_INT_LIT8, |
| 355 | // Instruction::DIV_INT_LIT8, |
| 356 | // Instruction::REM_INT_LIT8, |
| 357 | // Instruction::AND_INT_LIT8, |
| 358 | // Instruction::OR_INT_LIT8, |
| 359 | // Instruction::XOR_INT_LIT8, |
| 360 | // Instruction::SHL_INT_LIT8, |
| 361 | // Instruction::SHR_INT_LIT8, |
| 362 | // Instruction::USHR_INT_LIT8, |
| 363 | // Instruction::IGET_QUICK, |
| 364 | // Instruction::IGET_WIDE_QUICK, |
| 365 | // Instruction::IGET_OBJECT_QUICK, |
| 366 | // Instruction::IPUT_QUICK, |
| 367 | // Instruction::IPUT_WIDE_QUICK, |
| 368 | // Instruction::IPUT_OBJECT_QUICK, |
| 369 | // Instruction::INVOKE_VIRTUAL_QUICK, |
| 370 | // Instruction::INVOKE_VIRTUAL_RANGE_QUICK, |
| 371 | // Instruction::UNUSED_EB, |
| 372 | // Instruction::UNUSED_EC, |
| 373 | // Instruction::UNUSED_ED, |
| 374 | // Instruction::UNUSED_EE, |
| 375 | // Instruction::UNUSED_EF, |
| 376 | // Instruction::UNUSED_F0, |
| 377 | // Instruction::UNUSED_F1, |
| 378 | // Instruction::UNUSED_F2, |
| 379 | // Instruction::UNUSED_F3, |
| 380 | // Instruction::UNUSED_F4, |
| 381 | // Instruction::UNUSED_F5, |
| 382 | // Instruction::UNUSED_F6, |
| 383 | // Instruction::UNUSED_F7, |
| 384 | // Instruction::UNUSED_F8, |
| 385 | // Instruction::UNUSED_F9, |
| 386 | // Instruction::UNUSED_FA, |
| 387 | // Instruction::UNUSED_FB, |
| 388 | // Instruction::UNUSED_FC, |
| 389 | // Instruction::UNUSED_FD, |
| 390 | // Instruction::UNUSED_FE, |
| 391 | // Instruction::UNUSED_FF, |
| 392 | |
| 393 | // ----- ExtendedMIROpcode ----- |
| 394 | // kMirOpPhi, |
| 395 | // kMirOpCopy, |
| 396 | // kMirOpFusedCmplFloat, |
| 397 | // kMirOpFusedCmpgFloat, |
| 398 | // kMirOpFusedCmplDouble, |
| 399 | // kMirOpFusedCmpgDouble, |
| 400 | // kMirOpFusedCmpLong, |
| 401 | // kMirOpNop, |
| 402 | // kMirOpNullCheck, |
| 403 | // kMirOpRangeCheck, |
| 404 | // kMirOpDivZeroCheck, |
| 405 | // kMirOpCheck, |
| 406 | // kMirOpCheckPart2, |
| 407 | // kMirOpSelect, |
| 408 | // kMirOpLast, |
| 409 | }; |
| 410 | |
| 411 | // TODO: Remove this when we are able to compile everything. |
| 412 | static bool CanCompileShorty(const char* shorty) { |
| 413 | uint32_t shorty_size = strlen(shorty); |
| 414 | CHECK_GE(shorty_size, 1u); |
| 415 | // Set a limitation on maximum number of parameters. |
| 416 | // Note : there is an implied "method*" parameter, and probably "this" as well. |
| 417 | // 1 is for the return type. Currently, we only accept 2 parameters at the most. |
| 418 | if (shorty_size > (1 + 2)) { |
| 419 | return false; |
| 420 | } |
| 421 | // Z : boolean |
| 422 | // B : byte |
| 423 | // S : short |
| 424 | // C : char |
| 425 | // I : int |
| 426 | // L : long |
| 427 | // F : float |
| 428 | // D : double |
| 429 | // L : reference(object, array) |
| 430 | // V : void |
| 431 | // Current calling conversion only support 32bit softfp |
| 432 | // which has problems with long, float, double |
| 433 | constexpr char supported_types[] = "ZBSCILV"; |
| 434 | for (uint32_t i = 0; i < shorty_size; i++) { |
| 435 | if (strchr(supported_types, shorty[i]) == nullptr) { |
| 436 | return false; |
| 437 | } |
| 438 | } |
| 439 | return true; |
| 440 | }; |
| 441 | |
| 442 | // TODO: Remove this when we are able to compile everything. |
| 443 | // Skip the method that we do not support currently. |
| 444 | static bool CanCompileMethod(uint32_t method_idx, const DexFile& dex_file, |
| 445 | CompilationUnit& cu) { |
| 446 | // There is some limitation with current ARM 64 backend. |
| 447 | if (cu.instruction_set == kArm64) { |
| 448 | // Check if we can compile the prototype. |
| 449 | const char* shorty = dex_file.GetMethodShorty(dex_file.GetMethodId(method_idx)); |
| 450 | if (!CanCompileShorty(shorty)) { |
| 451 | VLOG(compiler) << "Unsupported shorty : " << shorty; |
| 452 | return false; |
| 453 | } |
| 454 | |
| 455 | for (int idx = 0; idx < cu.mir_graph->GetNumBlocks(); idx++) { |
| 456 | BasicBlock *bb = cu.mir_graph->GetBasicBlock(idx); |
| 457 | if (bb == NULL) continue; |
| 458 | if (bb->block_type == kDead) continue; |
| 459 | for (MIR* mir = bb->first_mir_insn; mir != nullptr; mir = mir->next) { |
| 460 | int opcode = mir->dalvikInsn.opcode; |
| 461 | // Check if we support the byte code. |
| 462 | if (std::find(arm64_support_list, arm64_support_list + arraysize(arm64_support_list), |
| 463 | opcode) == arm64_support_list + arraysize(arm64_support_list)) { |
| 464 | if (opcode < kMirOpFirst) { |
| 465 | VLOG(compiler) << "Unsupported dalvik byte code : " |
| 466 | << mir->dalvikInsn.opcode; |
| 467 | } else { |
| 468 | VLOG(compiler) << "Unsupported extended MIR opcode : " |
| 469 | << MIRGraph::extended_mir_op_names_[opcode - kMirOpFirst]; |
| 470 | } |
| 471 | return false; |
| 472 | } |
| 473 | // Check if it invokes a prototype that we cannot support. |
| 474 | if (Instruction::INVOKE_VIRTUAL == opcode || |
| 475 | Instruction::INVOKE_SUPER == opcode || |
| 476 | Instruction::INVOKE_DIRECT == opcode || |
| 477 | Instruction::INVOKE_STATIC == opcode || |
| 478 | Instruction::INVOKE_INTERFACE == opcode) { |
| 479 | uint32_t invoke_method_idx = mir->dalvikInsn.vB; |
| 480 | const char* invoke_method_shorty = dex_file.GetMethodShorty( |
| 481 | dex_file.GetMethodId(invoke_method_idx)); |
| 482 | if (!CanCompileShorty(invoke_method_shorty)) { |
| 483 | VLOG(compiler) << "Unsupported to invoke '" |
| 484 | << PrettyMethod(invoke_method_idx, dex_file) |
| 485 | << "' with shorty : " << invoke_method_shorty; |
| 486 | return false; |
| 487 | } |
| 488 | } |
| 489 | } |
| 490 | } |
| 491 | |
| 492 | LOG(INFO) << "Using experimental instruction set A64 for " |
| 493 | << PrettyMethod(method_idx, dex_file); |
| 494 | } |
| 495 | return true; |
| 496 | } |
| 497 | |
Ian Rogers | 3d50407 | 2014-03-01 09:16:49 -0800 | [diff] [blame] | 498 | static CompiledMethod* CompileMethod(CompilerDriver& driver, |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 499 | Compiler* compiler, |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 500 | const DexFile::CodeItem* code_item, |
| 501 | uint32_t access_flags, InvokeType invoke_type, |
Ian Rogers | 8b2c0b9 | 2013-09-19 02:56:49 -0700 | [diff] [blame] | 502 | uint16_t class_def_idx, uint32_t method_idx, |
Nicolas Geoffray | f5df897 | 2014-02-14 18:37:08 +0000 | [diff] [blame] | 503 | jobject class_loader, const DexFile& dex_file, |
| 504 | void* llvm_compilation_unit) { |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 505 | VLOG(compiler) << "Compiling " << PrettyMethod(method_idx, dex_file) << "..."; |
buzbee | b48819d | 2013-09-14 16:15:25 -0700 | [diff] [blame] | 506 | if (code_item->insns_size_in_code_units_ >= 0x10000) { |
| 507 | LOG(INFO) << "Method size exceeds compiler limits: " << code_item->insns_size_in_code_units_ |
| 508 | << " in " << PrettyMethod(method_idx, dex_file); |
| 509 | return NULL; |
| 510 | } |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 511 | |
Jeff Hao | 4a200f5 | 2014-04-01 14:58:49 -0700 | [diff] [blame] | 512 | if (!driver.GetCompilerOptions().IsCompilationEnabled()) { |
Ian Rogers | a03de6d | 2014-03-08 23:37:07 +0000 | [diff] [blame] | 513 | return nullptr; |
| 514 | } |
| 515 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 516 | ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); |
Ian Rogers | 3d50407 | 2014-03-01 09:16:49 -0800 | [diff] [blame] | 517 | CompilationUnit cu(driver.GetArenaPool()); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 518 | |
Ian Rogers | 3d50407 | 2014-03-01 09:16:49 -0800 | [diff] [blame] | 519 | cu.compiler_driver = &driver; |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 520 | cu.class_linker = class_linker; |
Ian Rogers | 3d50407 | 2014-03-01 09:16:49 -0800 | [diff] [blame] | 521 | cu.instruction_set = driver.GetInstructionSet(); |
Mathieu Chartier | 53bee42 | 2014-04-04 16:10:05 -0700 | [diff] [blame] | 522 | if (cu.instruction_set == kArm) { |
| 523 | cu.instruction_set = kThumb2; |
| 524 | } |
Andreas Gampe | af13ad9 | 2014-04-11 12:07:48 -0700 | [diff] [blame] | 525 | cu.target64 = Is64BitInstructionSet(cu.instruction_set); |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 526 | cu.compiler = compiler; |
Stuart Monteith | b95a534 | 2014-03-12 13:32:32 +0000 | [diff] [blame] | 527 | // TODO: x86_64 & arm64 are not yet implemented. |
Mathieu Chartier | 53bee42 | 2014-04-04 16:10:05 -0700 | [diff] [blame] | 528 | CHECK((cu.instruction_set == kThumb2) || |
Zheng Xu | 9e06c8c | 2014-05-06 18:06:07 +0100 | [diff] [blame] | 529 | (cu.instruction_set == kArm64) || |
Mathieu Chartier | 53bee42 | 2014-04-04 16:10:05 -0700 | [diff] [blame] | 530 | (cu.instruction_set == kX86) || |
| 531 | (cu.instruction_set == kX86_64) || |
| 532 | (cu.instruction_set == kMips)); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 533 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 534 | /* Adjust this value accordingly once inlining is performed */ |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 535 | cu.num_dalvik_registers = code_item->registers_size_; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 536 | // TODO: set this from command line |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 537 | cu.compiler_flip_match = false; |
| 538 | bool use_match = !cu.compiler_method_match.empty(); |
| 539 | bool match = use_match && (cu.compiler_flip_match ^ |
| 540 | (PrettyMethod(method_idx, dex_file).find(cu.compiler_method_match) != |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 541 | std::string::npos)); |
| 542 | if (!use_match || match) { |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 543 | cu.disable_opt = kCompilerOptimizerDisableFlags; |
| 544 | cu.enable_debug = kCompilerDebugFlags; |
| 545 | cu.verbose = VLOG_IS_ON(compiler) || |
| 546 | (cu.enable_debug & (1 << kDebugVerbose)); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 547 | } |
| 548 | |
Mingyao Yang | 42d65c5 | 2014-04-18 16:49:39 -0700 | [diff] [blame] | 549 | if (gVerboseMethods.size() != 0) { |
| 550 | cu.verbose = false; |
| 551 | for (size_t i = 0; i < gVerboseMethods.size(); ++i) { |
| 552 | if (PrettyMethod(method_idx, dex_file).find(gVerboseMethods[i]) |
| 553 | != std::string::npos) { |
| 554 | cu.verbose = true; |
| 555 | break; |
| 556 | } |
| 557 | } |
| 558 | } |
| 559 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 560 | /* |
| 561 | * TODO: rework handling of optimization and debug flags. Should we split out |
| 562 | * MIR and backend flags? Need command-line setting as well. |
| 563 | */ |
| 564 | |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 565 | compiler->InitCompilationUnit(cu); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 566 | |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 567 | if (cu.instruction_set == kMips) { |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 568 | // Disable some optimizations for mips for now |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 569 | cu.disable_opt |= ( |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 570 | (1 << kLoadStoreElimination) | |
| 571 | (1 << kLoadHoisting) | |
| 572 | (1 << kSuppressLoads) | |
| 573 | (1 << kNullCheckElimination) | |
| 574 | (1 << kPromoteRegs) | |
| 575 | (1 << kTrackLiveTemps) | |
| 576 | (1 << kSafeOptimizations) | |
| 577 | (1 << kBBOpt) | |
| 578 | (1 << kMatch) | |
| 579 | (1 << kPromoteCompilerTemps)); |
| 580 | } |
| 581 | |
Zheng Xu | 9e06c8c | 2014-05-06 18:06:07 +0100 | [diff] [blame] | 582 | if (cu.instruction_set == kArm64) { |
| 583 | // TODO(Arm64): enable optimizations once backend is mature enough. |
| 584 | cu.disable_opt = ~(uint32_t)0; |
| 585 | } |
| 586 | |
buzbee | a61f495 | 2013-08-23 14:27:06 -0700 | [diff] [blame] | 587 | cu.StartTimingSplit("BuildMIRGraph"); |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 588 | cu.mir_graph.reset(new MIRGraph(&cu, &cu.arena)); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 589 | |
Razvan A Lupusoru | da7a69b | 2014-01-08 15:09:50 -0800 | [diff] [blame] | 590 | /* |
| 591 | * After creation of the MIR graph, also create the code generator. |
| 592 | * The reason we do this is that optimizations on the MIR graph may need to get information |
| 593 | * that is only available if a CG exists. |
| 594 | */ |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 595 | cu.cg.reset(compiler->GetCodeGenerator(&cu, llvm_compilation_unit)); |
Razvan A Lupusoru | da7a69b | 2014-01-08 15:09:50 -0800 | [diff] [blame] | 596 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 597 | /* Gathering opcode stats? */ |
| 598 | if (kCompilerDebugFlags & (1 << kDebugCountOpcodes)) { |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 599 | cu.mir_graph->EnableOpcodeCounting(); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 600 | } |
| 601 | |
Dave Allison | 39c3bfb | 2014-01-28 18:33:52 -0800 | [diff] [blame] | 602 | // Check early if we should skip this compilation if using the profiled filter. |
| 603 | if (cu.compiler_driver->ProfilePresent()) { |
| 604 | std::string methodname = PrettyMethod(method_idx, dex_file); |
| 605 | if (cu.mir_graph->SkipCompilation(methodname)) { |
| 606 | return NULL; |
| 607 | } |
| 608 | } |
| 609 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 610 | /* Build the raw MIR graph */ |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 611 | 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] | 612 | class_loader, dex_file); |
| 613 | |
Zheng Xu | 9e06c8c | 2014-05-06 18:06:07 +0100 | [diff] [blame] | 614 | // TODO(Arm64): Remove this when we are able to compile everything. |
| 615 | if (!CanCompileMethod(method_idx, dex_file, cu)) { |
| 616 | VLOG(compiler) << "Cannot compile method : " << PrettyMethod(method_idx, dex_file); |
| 617 | return nullptr; |
| 618 | } |
| 619 | |
buzbee | 1da1e2f | 2013-11-15 13:37:01 -0800 | [diff] [blame] | 620 | cu.NewTimingSplit("MIROpt:CheckFilters"); |
Jeff Hao | 4a200f5 | 2014-04-01 14:58:49 -0700 | [diff] [blame] | 621 | if (cu.mir_graph->SkipCompilation()) { |
| 622 | return NULL; |
buzbee | ee17e0a | 2013-07-31 10:47:37 -0700 | [diff] [blame] | 623 | } |
| 624 | |
Jean Christophe Beyler | 4e97c53 | 2014-01-07 10:07:18 -0800 | [diff] [blame] | 625 | /* Create the pass driver and launch it */ |
Ian Rogers | 3d50407 | 2014-03-01 09:16:49 -0800 | [diff] [blame] | 626 | PassDriver pass_driver(&cu); |
| 627 | pass_driver.Launch(); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 628 | |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 629 | if (cu.enable_debug & (1 << kDebugDumpCheckStats)) { |
| 630 | cu.mir_graph->DumpCheckStats(); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 631 | } |
| 632 | |
| 633 | if (kCompilerDebugFlags & (1 << kDebugCountOpcodes)) { |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 634 | cu.mir_graph->ShowOpcodeStats(); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 635 | } |
| 636 | |
buzbee | 1da1e2f | 2013-11-15 13:37:01 -0800 | [diff] [blame] | 637 | /* Reassociate sreg names with original Dalvik vreg names. */ |
| 638 | cu.mir_graph->RemapRegLocations(); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 639 | |
Vladimir Marko | 53b6afc | 2014-03-21 14:21:20 +0000 | [diff] [blame] | 640 | /* Free Arenas from the cu.arena_stack for reuse by the cu.arena in the codegen. */ |
| 641 | if (cu.enable_debug & (1 << kDebugShowMemoryUsage)) { |
| 642 | if (cu.arena_stack.PeakBytesAllocated() > 256 * 1024) { |
| 643 | MemStats stack_stats(cu.arena_stack.GetPeakStats()); |
| 644 | LOG(INFO) << PrettyMethod(method_idx, dex_file) << " " << Dumpable<MemStats>(stack_stats); |
| 645 | } |
| 646 | } |
| 647 | cu.arena_stack.Reset(); |
| 648 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 649 | CompiledMethod* result = NULL; |
| 650 | |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 651 | cu.cg->Materialize(); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 652 | |
buzbee | 1da1e2f | 2013-11-15 13:37:01 -0800 | [diff] [blame] | 653 | 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] | 654 | result = cu.cg->GetCompiledMethod(); |
buzbee | 1da1e2f | 2013-11-15 13:37:01 -0800 | [diff] [blame] | 655 | cu.NewTimingSplit("Cleanup"); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 656 | |
| 657 | if (result) { |
| 658 | VLOG(compiler) << "Compiled " << PrettyMethod(method_idx, dex_file); |
| 659 | } else { |
| 660 | VLOG(compiler) << "Deferred " << PrettyMethod(method_idx, dex_file); |
| 661 | } |
| 662 | |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 663 | if (cu.enable_debug & (1 << kDebugShowMemoryUsage)) { |
Vladimir Marko | 53b6afc | 2014-03-21 14:21:20 +0000 | [diff] [blame] | 664 | if (cu.arena.BytesAllocated() > (1 * 1024 *1024)) { |
Vladimir Marko | 83cc7ae | 2014-02-12 18:02:05 +0000 | [diff] [blame] | 665 | MemStats mem_stats(cu.arena.GetMemStats()); |
Vladimir Marko | 53b6afc | 2014-03-21 14:21:20 +0000 | [diff] [blame] | 666 | LOG(INFO) << PrettyMethod(method_idx, dex_file) << " " << Dumpable<MemStats>(mem_stats); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 667 | } |
| 668 | } |
| 669 | |
Mathieu Chartier | f6c4b3b | 2013-08-24 16:11:37 -0700 | [diff] [blame] | 670 | if (cu.enable_debug & (1 << kDebugShowSummaryMemoryUsage)) { |
| 671 | LOG(INFO) << "MEMINFO " << cu.arena.BytesAllocated() << " " << cu.mir_graph->GetNumBlocks() |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 672 | << " " << PrettyMethod(method_idx, dex_file); |
| 673 | } |
| 674 | |
buzbee | a61f495 | 2013-08-23 14:27:06 -0700 | [diff] [blame] | 675 | cu.EndTiming(); |
Ian Rogers | 3d50407 | 2014-03-01 09:16:49 -0800 | [diff] [blame] | 676 | driver.GetTimingsLogger()->AddLogger(cu.timings); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 677 | return result; |
| 678 | } |
| 679 | |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 680 | CompiledMethod* CompileOneMethod(CompilerDriver& driver, |
| 681 | Compiler* compiler, |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 682 | const DexFile::CodeItem* code_item, |
| 683 | uint32_t access_flags, |
| 684 | InvokeType invoke_type, |
Ian Rogers | 8b2c0b9 | 2013-09-19 02:56:49 -0700 | [diff] [blame] | 685 | uint16_t class_def_idx, |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 686 | uint32_t method_idx, |
| 687 | jobject class_loader, |
| 688 | const DexFile& dex_file, |
Nicolas Geoffray | f5df897 | 2014-02-14 18:37:08 +0000 | [diff] [blame] | 689 | void* compilation_unit) { |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 690 | 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] | 691 | method_idx, class_loader, dex_file, compilation_unit); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 692 | } |
| 693 | |
| 694 | } // namespace art |
| 695 | |
| 696 | extern "C" art::CompiledMethod* |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 697 | ArtQuickCompileMethod(art::CompilerDriver& driver, |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 698 | const art::DexFile::CodeItem* code_item, |
| 699 | uint32_t access_flags, art::InvokeType invoke_type, |
Ian Rogers | 8b2c0b9 | 2013-09-19 02:56:49 -0700 | [diff] [blame] | 700 | uint16_t class_def_idx, uint32_t method_idx, jobject class_loader, |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 701 | const art::DexFile& dex_file) { |
| 702 | // TODO: check method fingerprint here to determine appropriate backend type. Until then, use build default |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 703 | art::Compiler* compiler = driver.GetCompiler(); |
| 704 | return art::CompileOneMethod(driver, compiler, code_item, access_flags, invoke_type, |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 705 | class_def_idx, method_idx, class_loader, dex_file, |
| 706 | NULL /* use thread llvm_info */); |
| 707 | } |