Andreas Gampe | 29d38e7 | 2016-03-23 15:31:51 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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 | #ifndef ART_RUNTIME_COMPILER_FILTER_H_ |
| 18 | #define ART_RUNTIME_COMPILER_FILTER_H_ |
| 19 | |
| 20 | #include <ostream> |
| 21 | #include <string> |
| 22 | #include <vector> |
| 23 | |
| 24 | #include "base/macros.h" |
| 25 | |
| 26 | namespace art { |
| 27 | |
| 28 | class CompilerFilter FINAL { |
| 29 | public: |
| 30 | // Note: Order here matters. Later filter choices are considered "as good |
| 31 | // as" earlier filter choices. |
| 32 | enum Filter { |
Nicolas Geoffray | 49cda06 | 2017-04-21 13:08:25 +0100 | [diff] [blame^] | 33 | kAssumeVerified, // Skip verification but mark all classes as verified anyway. |
| 34 | kExtract, // Delay verication to runtime, do not compile anything. |
| 35 | kVerify, // Only verify classes. |
| 36 | kQuicken, // Verify, quicken, and compile JNI stubs. |
Andreas Gampe | 29d38e7 | 2016-03-23 15:31:51 +0000 | [diff] [blame] | 37 | kSpaceProfile, // Maximize space savings based on profile. |
| 38 | kSpace, // Maximize space savings. |
Andreas Gampe | 29d38e7 | 2016-03-23 15:31:51 +0000 | [diff] [blame] | 39 | kSpeedProfile, // Maximize runtime performance based on profile. |
| 40 | kSpeed, // Maximize runtime performance. |
| 41 | kEverythingProfile, // Compile everything capable of being compiled based on profile. |
| 42 | kEverything, // Compile everything capable of being compiled. |
| 43 | }; |
| 44 | |
Richard Uhler | f4b3487 | 2016-04-13 11:03:46 -0700 | [diff] [blame] | 45 | static const Filter kDefaultCompilerFilter = kSpeed; |
| 46 | |
Andreas Gampe | 29d38e7 | 2016-03-23 15:31:51 +0000 | [diff] [blame] | 47 | // Returns true if an oat file with this compiler filter contains |
Vladimir Marko | 8c185bf | 2016-05-23 15:32:42 +0100 | [diff] [blame] | 48 | // compiled executable code for bytecode. |
Nicolas Geoffray | 49cda06 | 2017-04-21 13:08:25 +0100 | [diff] [blame^] | 49 | static bool IsAotCompilationEnabled(Filter filter); |
Vladimir Marko | 8c185bf | 2016-05-23 15:32:42 +0100 | [diff] [blame] | 50 | |
| 51 | // Returns true if an oat file with this compiler filter contains |
Nicolas Geoffray | 60ca949 | 2016-12-20 21:15:00 +0000 | [diff] [blame] | 52 | // compiled executable code for bytecode, JNI methods, or quickened dex |
| 53 | // bytecode. |
Nicolas Geoffray | 49cda06 | 2017-04-21 13:08:25 +0100 | [diff] [blame^] | 54 | static bool IsAnyCompilationEnabled(Filter filter); |
Nicolas Geoffray | 60ca949 | 2016-12-20 21:15:00 +0000 | [diff] [blame] | 55 | |
| 56 | // Returns true if an oat file with this compiler filter contains |
Vladimir Marko | 8c185bf | 2016-05-23 15:32:42 +0100 | [diff] [blame] | 57 | // compiled executable code for JNI methods. |
| 58 | static bool IsJniCompilationEnabled(Filter filter); |
Andreas Gampe | 29d38e7 | 2016-03-23 15:31:51 +0000 | [diff] [blame] | 59 | |
Nicolas Geoffray | 49cda06 | 2017-04-21 13:08:25 +0100 | [diff] [blame^] | 60 | // Returns true if an oat file with this compiler filter contains |
| 61 | // quickened dex bytecode. |
| 62 | static bool IsQuickeningCompilationEnabled(Filter filter); |
| 63 | |
Andreas Gampe | 29d38e7 | 2016-03-23 15:31:51 +0000 | [diff] [blame] | 64 | // Returns true if this compiler filter requires running verification. |
| 65 | static bool IsVerificationEnabled(Filter filter); |
| 66 | |
| 67 | // Returns true if an oat file with this compiler filter depends on the |
| 68 | // boot image checksum. |
| 69 | static bool DependsOnImageChecksum(Filter filter); |
| 70 | |
| 71 | // Returns true if an oat file with this compiler filter depends on a |
| 72 | // profile. |
| 73 | static bool DependsOnProfile(Filter filter); |
| 74 | |
Andreas Gampe | 86a785d | 2016-03-30 17:19:48 -0700 | [diff] [blame] | 75 | // Returns a non-profile-guided version of the given filter. |
| 76 | static Filter GetNonProfileDependentFilterFrom(Filter filter); |
| 77 | |
Andreas Gampe | 29d38e7 | 2016-03-23 15:31:51 +0000 | [diff] [blame] | 78 | // Returns true if the 'current' compiler filter is considered at least as |
| 79 | // good as the 'target' compilation type. |
| 80 | // For example: kSpeed is as good as kInterpretOnly, but kInterpretOnly is |
| 81 | // not as good as kSpeed. |
| 82 | static bool IsAsGoodAs(Filter current, Filter target); |
| 83 | |
| 84 | // Return the flag name of the given filter. |
| 85 | // For example: given kVerifyAtRuntime, returns "verify-at-runtime". |
| 86 | // The name returned corresponds to the name accepted by |
| 87 | // ParseCompilerFilter. |
| 88 | static std::string NameOfFilter(Filter filter); |
| 89 | |
| 90 | // Parse the compiler filter from the given name. |
| 91 | // Returns true and sets filter to the parsed value if name refers to a |
| 92 | // valid filter. Returns false if no filter matches that name. |
| 93 | // 'filter' must be non-null. |
| 94 | static bool ParseCompilerFilter(const char* name, /*out*/Filter* filter); |
| 95 | |
| 96 | private: |
| 97 | DISALLOW_COPY_AND_ASSIGN(CompilerFilter); |
| 98 | }; |
| 99 | |
| 100 | std::ostream& operator<<(std::ostream& os, const CompilerFilter::Filter& rhs); |
| 101 | |
| 102 | } // namespace art |
| 103 | |
| 104 | #endif // ART_RUNTIME_COMPILER_FILTER_H_ |