Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +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 "compiler.h" |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 18 | |
Andreas Gampe | 53c913b | 2014-08-12 23:19:23 -0700 | [diff] [blame] | 19 | #include "base/logging.h" |
Andreas Gampe | 53c913b | 2014-08-12 23:19:23 -0700 | [diff] [blame] | 20 | #include "driver/compiler_driver.h" |
Andreas Gampe | 53c913b | 2014-08-12 23:19:23 -0700 | [diff] [blame] | 21 | #include "optimizing/optimizing_compiler.h" |
Vladimir Marko | 80afd02 | 2015-05-19 18:08:00 +0100 | [diff] [blame] | 22 | #include "utils.h" |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 23 | |
| 24 | namespace art { |
| 25 | |
Ian Rogers | 72d3262 | 2014-05-06 16:20:11 -0700 | [diff] [blame] | 26 | Compiler* Compiler::Create(CompilerDriver* driver, Compiler::Kind kind) { |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 27 | switch (kind) { |
| 28 | case kQuick: |
Nicolas Geoffray | 3c94f09 | 2016-03-21 17:10:24 +0000 | [diff] [blame] | 29 | // TODO: Remove Quick in options. |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 30 | case kOptimizing: |
Andreas Gampe | 53c913b | 2014-08-12 23:19:23 -0700 | [diff] [blame] | 31 | return CreateOptimizingCompiler(driver); |
| 32 | |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 33 | default: |
| 34 | LOG(FATAL) << "UNREACHABLE"; |
Ian Rogers | 2c4257b | 2014-10-24 14:20:06 -0700 | [diff] [blame] | 35 | UNREACHABLE(); |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 36 | } |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 37 | } |
| 38 | |
Nicolas Geoffray | b5f62b3 | 2014-10-30 10:58:41 +0000 | [diff] [blame] | 39 | bool Compiler::IsPathologicalCase(const DexFile::CodeItem& code_item, |
| 40 | uint32_t method_idx, |
| 41 | const DexFile& dex_file) { |
| 42 | /* |
| 43 | * Skip compilation for pathologically large methods - either by instruction count or num vregs. |
| 44 | * Dalvik uses 16-bit uints for instruction and register counts. We'll limit to a quarter |
| 45 | * of that, which also guarantees we cannot overflow our 16-bit internal Quick SSA name space. |
| 46 | */ |
| 47 | if (code_item.insns_size_in_code_units_ >= UINT16_MAX / 4) { |
| 48 | LOG(INFO) << "Method exceeds compiler instruction limit: " |
| 49 | << code_item.insns_size_in_code_units_ |
David Sehr | 709b070 | 2016-10-13 09:12:37 -0700 | [diff] [blame] | 50 | << " in " << dex_file.PrettyMethod(method_idx); |
Nicolas Geoffray | b5f62b3 | 2014-10-30 10:58:41 +0000 | [diff] [blame] | 51 | return true; |
| 52 | } |
| 53 | if (code_item.registers_size_ >= UINT16_MAX / 4) { |
| 54 | LOG(INFO) << "Method exceeds compiler virtual register limit: " |
David Sehr | 709b070 | 2016-10-13 09:12:37 -0700 | [diff] [blame] | 55 | << code_item.registers_size_ << " in " << dex_file.PrettyMethod(method_idx); |
Nicolas Geoffray | b5f62b3 | 2014-10-30 10:58:41 +0000 | [diff] [blame] | 56 | return true; |
| 57 | } |
| 58 | return false; |
| 59 | } |
| 60 | |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 61 | } // namespace art |