Calin Juravle | 36eb313 | 2017-01-13 16:32:38 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 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 <string> |
Vladimir Marko | e512556 | 2019-02-06 17:38:26 +0000 | [diff] [blame] | 18 | #include <string_view> |
Calin Juravle | 36eb313 | 2017-01-13 16:32:38 -0800 | [diff] [blame] | 19 | |
| 20 | #include "android-base/stringprintf.h" |
| 21 | #include "android-base/strings.h" |
David Sehr | 891a50e | 2017-10-27 17:01:07 -0700 | [diff] [blame] | 22 | #include "base/file_utils.h" |
Vladimir Marko | e512556 | 2019-02-06 17:38:26 +0000 | [diff] [blame] | 23 | #include "base/logging.h" // For InitLogging. |
| 24 | #include "base/mutex.h" |
| 25 | #include "base/os.h" |
| 26 | #include "base/string_view_cpp20.h" |
| 27 | #include "base/utils.h" |
Calin Juravle | 36eb313 | 2017-01-13 16:32:38 -0800 | [diff] [blame] | 28 | #include "compiler_filter.h" |
Calin Juravle | 20c4644 | 2017-09-12 00:54:26 -0700 | [diff] [blame] | 29 | #include "class_loader_context.h" |
David Sehr | 9e734c7 | 2018-01-04 17:56:19 -0800 | [diff] [blame] | 30 | #include "dex/dex_file.h" |
Calin Juravle | 36eb313 | 2017-01-13 16:32:38 -0800 | [diff] [blame] | 31 | #include "noop_compiler_callbacks.h" |
| 32 | #include "oat_file_assistant.h" |
Calin Juravle | 36eb313 | 2017-01-13 16:32:38 -0800 | [diff] [blame] | 33 | #include "runtime.h" |
| 34 | #include "thread-inl.h" |
Calin Juravle | 36eb313 | 2017-01-13 16:32:38 -0800 | [diff] [blame] | 35 | |
| 36 | namespace art { |
| 37 | |
| 38 | // See OatFileAssistant docs for the meaning of the valid return codes. |
| 39 | enum ReturnCodes { |
| 40 | kNoDexOptNeeded = 0, |
| 41 | kDex2OatFromScratch = 1, |
| 42 | kDex2OatForBootImageOat = 2, |
| 43 | kDex2OatForFilterOat = 3, |
Vladimir Marko | e066932 | 2018-09-03 15:44:54 +0100 | [diff] [blame] | 44 | kDex2OatForBootImageOdex = 4, |
| 45 | kDex2OatForFilterOdex = 5, |
Calin Juravle | 36eb313 | 2017-01-13 16:32:38 -0800 | [diff] [blame] | 46 | |
| 47 | kErrorInvalidArguments = 101, |
| 48 | kErrorCannotCreateRuntime = 102, |
| 49 | kErrorUnknownDexOptNeeded = 103 |
| 50 | }; |
| 51 | |
| 52 | static int original_argc; |
| 53 | static char** original_argv; |
| 54 | |
| 55 | static std::string CommandLine() { |
| 56 | std::vector<std::string> command; |
Andreas Gampe | 2a487eb | 2018-11-19 11:41:22 -0800 | [diff] [blame] | 57 | command.reserve(original_argc); |
Calin Juravle | 36eb313 | 2017-01-13 16:32:38 -0800 | [diff] [blame] | 58 | for (int i = 0; i < original_argc; ++i) { |
| 59 | command.push_back(original_argv[i]); |
| 60 | } |
| 61 | return android::base::Join(command, ' '); |
| 62 | } |
| 63 | |
| 64 | static void UsageErrorV(const char* fmt, va_list ap) { |
| 65 | std::string error; |
| 66 | android::base::StringAppendV(&error, fmt, ap); |
| 67 | LOG(ERROR) << error; |
| 68 | } |
| 69 | |
| 70 | static void UsageError(const char* fmt, ...) { |
| 71 | va_list ap; |
| 72 | va_start(ap, fmt); |
| 73 | UsageErrorV(fmt, ap); |
| 74 | va_end(ap); |
| 75 | } |
| 76 | |
| 77 | NO_RETURN static void Usage(const char *fmt, ...) { |
| 78 | va_list ap; |
| 79 | va_start(ap, fmt); |
| 80 | UsageErrorV(fmt, ap); |
| 81 | va_end(ap); |
| 82 | |
| 83 | UsageError("Command: %s", CommandLine().c_str()); |
| 84 | UsageError(" Performs a dexopt analysis on the given dex file and returns whether or not"); |
| 85 | UsageError(" the dex file needs to be dexopted."); |
| 86 | UsageError("Usage: dexoptanalyzer [options]..."); |
| 87 | UsageError(""); |
| 88 | UsageError(" --dex-file=<filename>: the dex file which should be analyzed."); |
| 89 | UsageError(""); |
| 90 | UsageError(" --isa=<string>: the instruction set for which the analysis should be performed."); |
| 91 | UsageError(""); |
| 92 | UsageError(" --compiler-filter=<string>: the target compiler filter to be used as reference"); |
| 93 | UsageError(" when deciding if the dex file needs to be optimized."); |
| 94 | UsageError(""); |
| 95 | UsageError(" --assume-profile-changed: assumes the profile information has changed"); |
| 96 | UsageError(" when deciding if the dex file needs to be optimized."); |
| 97 | UsageError(""); |
| 98 | UsageError(" --image=<filename>: optional, the image to be used to decide if the associated"); |
| 99 | UsageError(" oat file is up to date. Defaults to $ANDROID_ROOT/framework/boot.art."); |
| 100 | UsageError(" Example: --image=/system/framework/boot.art"); |
| 101 | UsageError(""); |
Vladimir Marko | 813b914 | 2018-11-29 11:20:07 +0000 | [diff] [blame] | 102 | UsageError(" --runtime-arg <argument>: used to specify various arguments for the runtime,"); |
| 103 | UsageError(" such as initial heap size, maximum heap size, and verbose output."); |
| 104 | UsageError(" Use a separate --runtime-arg switch for each argument."); |
| 105 | UsageError(" Example: --runtime-arg -Xms256m"); |
| 106 | UsageError(""); |
Calin Juravle | 36eb313 | 2017-01-13 16:32:38 -0800 | [diff] [blame] | 107 | UsageError(" --android-data=<directory>: optional, the directory which should be used as"); |
| 108 | UsageError(" android-data. By default ANDROID_DATA env variable is used."); |
| 109 | UsageError(""); |
Shubham Ajmera | b22dea0 | 2017-10-04 18:36:41 -0700 | [diff] [blame] | 110 | UsageError(" --oat-fd=number: file descriptor of the oat file which should be analyzed"); |
| 111 | UsageError(""); |
| 112 | UsageError(" --vdex-fd=number: file descriptor of the vdex file corresponding to the oat file"); |
| 113 | UsageError(""); |
Shubham Ajmera | c12bf4c | 2017-10-24 16:59:42 -0700 | [diff] [blame] | 114 | UsageError(" --zip-fd=number: specifies a file descriptor corresponding to the dex file."); |
| 115 | UsageError(""); |
Shubham Ajmera | e4e812a | 2017-05-25 20:09:58 -0700 | [diff] [blame] | 116 | UsageError(" --downgrade: optional, if the purpose of dexopt is to downgrade the dex file"); |
| 117 | UsageError(" By default, dexopt considers upgrade case."); |
| 118 | UsageError(""); |
Calin Juravle | 36eb313 | 2017-01-13 16:32:38 -0800 | [diff] [blame] | 119 | UsageError("Return code:"); |
| 120 | UsageError(" To make it easier to integrate with the internal tools this command will make"); |
| 121 | UsageError(" available its result (dexoptNeeded) as the exit/return code. i.e. it will not"); |
| 122 | UsageError(" return 0 for success and a non zero values for errors as the conventional"); |
| 123 | UsageError(" commands. The following return codes are possible:"); |
| 124 | UsageError(" kNoDexOptNeeded = 0"); |
| 125 | UsageError(" kDex2OatFromScratch = 1"); |
| 126 | UsageError(" kDex2OatForBootImageOat = 2"); |
| 127 | UsageError(" kDex2OatForFilterOat = 3"); |
Vladimir Marko | e066932 | 2018-09-03 15:44:54 +0100 | [diff] [blame] | 128 | UsageError(" kDex2OatForBootImageOdex = 4"); |
| 129 | UsageError(" kDex2OatForFilterOdex = 5"); |
Calin Juravle | 36eb313 | 2017-01-13 16:32:38 -0800 | [diff] [blame] | 130 | |
| 131 | UsageError(" kErrorInvalidArguments = 101"); |
| 132 | UsageError(" kErrorCannotCreateRuntime = 102"); |
| 133 | UsageError(" kErrorUnknownDexOptNeeded = 103"); |
| 134 | UsageError(""); |
| 135 | |
| 136 | exit(kErrorInvalidArguments); |
| 137 | } |
| 138 | |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 139 | class DexoptAnalyzer final { |
Calin Juravle | 36eb313 | 2017-01-13 16:32:38 -0800 | [diff] [blame] | 140 | public: |
Shubham Ajmera | e4e812a | 2017-05-25 20:09:58 -0700 | [diff] [blame] | 141 | DexoptAnalyzer() : |
| 142 | assume_profile_changed_(false), |
| 143 | downgrade_(false) {} |
Calin Juravle | 36eb313 | 2017-01-13 16:32:38 -0800 | [diff] [blame] | 144 | |
| 145 | void ParseArgs(int argc, char **argv) { |
| 146 | original_argc = argc; |
| 147 | original_argv = argv; |
| 148 | |
David Sehr | c431b9d | 2018-03-02 12:01:51 -0800 | [diff] [blame] | 149 | Locks::Init(); |
Andreas Gampe | 51d80cc | 2017-06-21 21:05:13 -0700 | [diff] [blame] | 150 | InitLogging(argv, Runtime::Abort); |
Calin Juravle | 36eb313 | 2017-01-13 16:32:38 -0800 | [diff] [blame] | 151 | // Skip over the command name. |
| 152 | argv++; |
| 153 | argc--; |
| 154 | |
| 155 | if (argc == 0) { |
| 156 | Usage("No arguments specified"); |
| 157 | } |
| 158 | |
| 159 | for (int i = 0; i < argc; ++i) { |
Vladimir Marko | e512556 | 2019-02-06 17:38:26 +0000 | [diff] [blame] | 160 | const char* raw_option = argv[i]; |
| 161 | const std::string_view option(raw_option); |
Calin Juravle | 36eb313 | 2017-01-13 16:32:38 -0800 | [diff] [blame] | 162 | if (option == "--assume-profile-changed") { |
| 163 | assume_profile_changed_ = true; |
Vladimir Marko | e512556 | 2019-02-06 17:38:26 +0000 | [diff] [blame] | 164 | } else if (StartsWith(option, "--dex-file=")) { |
| 165 | dex_file_ = std::string(option.substr(strlen("--dex-file="))); |
| 166 | } else if (StartsWith(option, "--compiler-filter=")) { |
| 167 | const char* filter_str = raw_option + strlen("--compiler-filter="); |
| 168 | if (!CompilerFilter::ParseCompilerFilter(filter_str, &compiler_filter_)) { |
| 169 | Usage("Invalid compiler filter '%s'", raw_option); |
Calin Juravle | 36eb313 | 2017-01-13 16:32:38 -0800 | [diff] [blame] | 170 | } |
Vladimir Marko | e512556 | 2019-02-06 17:38:26 +0000 | [diff] [blame] | 171 | } else if (StartsWith(option, "--isa=")) { |
| 172 | const char* isa_str = raw_option + strlen("--isa="); |
| 173 | isa_ = GetInstructionSetFromString(isa_str); |
Vladimir Marko | 33bff25 | 2017-11-01 14:35:42 +0000 | [diff] [blame] | 174 | if (isa_ == InstructionSet::kNone) { |
Vladimir Marko | e512556 | 2019-02-06 17:38:26 +0000 | [diff] [blame] | 175 | Usage("Invalid isa '%s'", raw_option); |
Calin Juravle | 36eb313 | 2017-01-13 16:32:38 -0800 | [diff] [blame] | 176 | } |
Vladimir Marko | e512556 | 2019-02-06 17:38:26 +0000 | [diff] [blame] | 177 | } else if (StartsWith(option, "--image=")) { |
| 178 | image_ = std::string(option.substr(strlen("--image="))); |
Vladimir Marko | 813b914 | 2018-11-29 11:20:07 +0000 | [diff] [blame] | 179 | } else if (option == "--runtime-arg") { |
| 180 | if (i + 1 == argc) { |
| 181 | Usage("Missing argument for --runtime-arg\n"); |
| 182 | } |
| 183 | ++i; |
| 184 | runtime_args_.push_back(argv[i]); |
Vladimir Marko | e512556 | 2019-02-06 17:38:26 +0000 | [diff] [blame] | 185 | } else if (StartsWith(option, "--android-data=")) { |
Calin Juravle | 36eb313 | 2017-01-13 16:32:38 -0800 | [diff] [blame] | 186 | // Overwrite android-data if needed (oat file assistant relies on a valid directory to |
| 187 | // compute dalvik-cache folder). This is mostly used in tests. |
Vladimir Marko | e512556 | 2019-02-06 17:38:26 +0000 | [diff] [blame] | 188 | const char* new_android_data = raw_option + strlen("--android-data="); |
| 189 | setenv("ANDROID_DATA", new_android_data, 1); |
| 190 | } else if (option == "--downgrade") { |
Shubham Ajmera | e4e812a | 2017-05-25 20:09:58 -0700 | [diff] [blame] | 191 | downgrade_ = true; |
Vladimir Marko | e512556 | 2019-02-06 17:38:26 +0000 | [diff] [blame] | 192 | } else if (StartsWith(option, "--oat-fd=")) { |
| 193 | oat_fd_ = std::stoi(std::string(option.substr(strlen("--oat-fd="))), nullptr, 0); |
Shubham Ajmera | c12bf4c | 2017-10-24 16:59:42 -0700 | [diff] [blame] | 194 | if (oat_fd_ < 0) { |
| 195 | Usage("Invalid --oat-fd %d", oat_fd_); |
| 196 | } |
Vladimir Marko | e512556 | 2019-02-06 17:38:26 +0000 | [diff] [blame] | 197 | } else if (StartsWith(option, "--vdex-fd=")) { |
| 198 | vdex_fd_ = std::stoi(std::string(option.substr(strlen("--vdex-fd="))), nullptr, 0); |
Shubham Ajmera | c12bf4c | 2017-10-24 16:59:42 -0700 | [diff] [blame] | 199 | if (vdex_fd_ < 0) { |
| 200 | Usage("Invalid --vdex-fd %d", vdex_fd_); |
| 201 | } |
Vladimir Marko | e512556 | 2019-02-06 17:38:26 +0000 | [diff] [blame] | 202 | } else if (StartsWith(option, "--zip-fd=")) { |
| 203 | zip_fd_ = std::stoi(std::string(option.substr(strlen("--zip-fd="))), nullptr, 0); |
| 204 | if (zip_fd_ < 0) { |
| 205 | Usage("Invalid --zip-fd %d", zip_fd_); |
| 206 | } |
| 207 | } else if (StartsWith(option, "--class-loader-context=")) { |
| 208 | context_str_ = std::string(option.substr(strlen("--class-loader-context="))); |
Calin Juravle | 20c4644 | 2017-09-12 00:54:26 -0700 | [diff] [blame] | 209 | } else { |
Vladimir Marko | e512556 | 2019-02-06 17:38:26 +0000 | [diff] [blame] | 210 | Usage("Unknown argument '%s'", raw_option); |
Calin Juravle | 20c4644 | 2017-09-12 00:54:26 -0700 | [diff] [blame] | 211 | } |
Calin Juravle | 36eb313 | 2017-01-13 16:32:38 -0800 | [diff] [blame] | 212 | } |
| 213 | |
| 214 | if (image_.empty()) { |
| 215 | // If we don't receive the image, try to use the default one. |
| 216 | // Tests may specify a different image (e.g. core image). |
| 217 | std::string error_msg; |
| 218 | image_ = GetDefaultBootImageLocation(&error_msg); |
| 219 | |
| 220 | if (image_.empty()) { |
| 221 | LOG(ERROR) << error_msg; |
| 222 | Usage("--image unspecified and ANDROID_ROOT not set or image file does not exist."); |
| 223 | } |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | bool CreateRuntime() { |
| 228 | RuntimeOptions options; |
| 229 | // The image could be custom, so make sure we explicitly pass it. |
| 230 | std::string img = "-Ximage:" + image_; |
Vladimir Marko | 813b914 | 2018-11-29 11:20:07 +0000 | [diff] [blame] | 231 | options.push_back(std::make_pair(img, nullptr)); |
Calin Juravle | 36eb313 | 2017-01-13 16:32:38 -0800 | [diff] [blame] | 232 | // The instruction set of the image should match the instruction set we will test. |
| 233 | const void* isa_opt = reinterpret_cast<const void*>(GetInstructionSetString(isa_)); |
| 234 | options.push_back(std::make_pair("imageinstructionset", isa_opt)); |
Vladimir Marko | 813b914 | 2018-11-29 11:20:07 +0000 | [diff] [blame] | 235 | // Explicit runtime args. |
| 236 | for (const char* runtime_arg : runtime_args_) { |
| 237 | options.push_back(std::make_pair(runtime_arg, nullptr)); |
| 238 | } |
Calin Juravle | 36eb313 | 2017-01-13 16:32:38 -0800 | [diff] [blame] | 239 | // Disable libsigchain. We don't don't need it to evaluate DexOptNeeded status. |
| 240 | options.push_back(std::make_pair("-Xno-sig-chain", nullptr)); |
| 241 | // Pretend we are a compiler so that we can re-use the same infrastructure to load a different |
| 242 | // ISA image and minimize the amount of things that get started. |
| 243 | NoopCompilerCallbacks callbacks; |
| 244 | options.push_back(std::make_pair("compilercallbacks", &callbacks)); |
| 245 | // Make sure we don't attempt to relocate. The tool should only retrieve the DexOptNeeded |
| 246 | // status and not attempt to relocate the boot image. |
| 247 | options.push_back(std::make_pair("-Xnorelocate", nullptr)); |
| 248 | |
| 249 | if (!Runtime::Create(options, false)) { |
| 250 | LOG(ERROR) << "Unable to initialize runtime"; |
| 251 | return false; |
| 252 | } |
| 253 | // Runtime::Create acquired the mutator_lock_ that is normally given away when we |
| 254 | // Runtime::Start. Give it away now. |
| 255 | Thread::Current()->TransitionFromRunnableToSuspended(kNative); |
| 256 | |
| 257 | return true; |
| 258 | } |
| 259 | |
| 260 | int GetDexOptNeeded() { |
Calin Juravle | 36eb313 | 2017-01-13 16:32:38 -0800 | [diff] [blame] | 261 | if (!CreateRuntime()) { |
| 262 | return kErrorCannotCreateRuntime; |
| 263 | } |
Andreas Gampe | 39f44b7 | 2017-04-26 22:00:04 -0700 | [diff] [blame] | 264 | std::unique_ptr<Runtime> runtime(Runtime::Current()); |
| 265 | |
Nicolas Geoffray | 35de14b | 2019-01-10 13:10:36 +0000 | [diff] [blame] | 266 | // Only when the runtime is created can we create the class loader context: the |
| 267 | // class loader context will open dex file and use the MemMap global lock that the |
| 268 | // runtime owns. |
| 269 | std::unique_ptr<ClassLoaderContext> class_loader_context; |
| 270 | if (!context_str_.empty()) { |
| 271 | class_loader_context = ClassLoaderContext::Create(context_str_); |
| 272 | if (class_loader_context == nullptr) { |
| 273 | Usage("Invalid --class-loader-context '%s'", context_str_.c_str()); |
| 274 | } |
| 275 | } |
| 276 | |
Shubham Ajmera | b22dea0 | 2017-10-04 18:36:41 -0700 | [diff] [blame] | 277 | std::unique_ptr<OatFileAssistant> oat_file_assistant; |
Shubham Ajmera | c12bf4c | 2017-10-24 16:59:42 -0700 | [diff] [blame] | 278 | oat_file_assistant = std::make_unique<OatFileAssistant>(dex_file_.c_str(), |
| 279 | isa_, |
Andreas Gampe | 9b031f7 | 2018-10-04 11:03:34 -0700 | [diff] [blame] | 280 | /*load_executable=*/ false, |
| 281 | /*only_load_system_executable=*/ false, |
Shubham Ajmera | c12bf4c | 2017-10-24 16:59:42 -0700 | [diff] [blame] | 282 | vdex_fd_, |
| 283 | oat_fd_, |
| 284 | zip_fd_); |
Calin Juravle | 36eb313 | 2017-01-13 16:32:38 -0800 | [diff] [blame] | 285 | // Always treat elements of the bootclasspath as up-to-date. |
| 286 | // TODO(calin): this check should be in OatFileAssistant. |
Shubham Ajmera | b22dea0 | 2017-10-04 18:36:41 -0700 | [diff] [blame] | 287 | if (oat_file_assistant->IsInBootClassPath()) { |
Calin Juravle | 36eb313 | 2017-01-13 16:32:38 -0800 | [diff] [blame] | 288 | return kNoDexOptNeeded; |
| 289 | } |
Calin Juravle | 44e5efa | 2017-09-12 00:54:26 -0700 | [diff] [blame] | 290 | |
Shubham Ajmera | b22dea0 | 2017-10-04 18:36:41 -0700 | [diff] [blame] | 291 | int dexoptNeeded = oat_file_assistant->GetDexOptNeeded( |
Nicolas Geoffray | 35de14b | 2019-01-10 13:10:36 +0000 | [diff] [blame] | 292 | compiler_filter_, assume_profile_changed_, downgrade_, class_loader_context.get()); |
Calin Juravle | 36eb313 | 2017-01-13 16:32:38 -0800 | [diff] [blame] | 293 | |
| 294 | // Convert OatFileAssitant codes to dexoptanalyzer codes. |
| 295 | switch (dexoptNeeded) { |
| 296 | case OatFileAssistant::kNoDexOptNeeded: return kNoDexOptNeeded; |
| 297 | case OatFileAssistant::kDex2OatFromScratch: return kDex2OatFromScratch; |
| 298 | case OatFileAssistant::kDex2OatForBootImage: return kDex2OatForBootImageOat; |
| 299 | case OatFileAssistant::kDex2OatForFilter: return kDex2OatForFilterOat; |
Calin Juravle | 36eb313 | 2017-01-13 16:32:38 -0800 | [diff] [blame] | 300 | |
| 301 | case -OatFileAssistant::kDex2OatForBootImage: return kDex2OatForBootImageOdex; |
| 302 | case -OatFileAssistant::kDex2OatForFilter: return kDex2OatForFilterOdex; |
Calin Juravle | 36eb313 | 2017-01-13 16:32:38 -0800 | [diff] [blame] | 303 | default: |
| 304 | LOG(ERROR) << "Unknown dexoptNeeded " << dexoptNeeded; |
| 305 | return kErrorUnknownDexOptNeeded; |
| 306 | } |
| 307 | } |
| 308 | |
| 309 | private: |
| 310 | std::string dex_file_; |
| 311 | InstructionSet isa_; |
| 312 | CompilerFilter::Filter compiler_filter_; |
Nicolas Geoffray | 35de14b | 2019-01-10 13:10:36 +0000 | [diff] [blame] | 313 | std::string context_str_; |
Calin Juravle | 36eb313 | 2017-01-13 16:32:38 -0800 | [diff] [blame] | 314 | bool assume_profile_changed_; |
Shubham Ajmera | e4e812a | 2017-05-25 20:09:58 -0700 | [diff] [blame] | 315 | bool downgrade_; |
Calin Juravle | 36eb313 | 2017-01-13 16:32:38 -0800 | [diff] [blame] | 316 | std::string image_; |
Vladimir Marko | 813b914 | 2018-11-29 11:20:07 +0000 | [diff] [blame] | 317 | std::vector<const char*> runtime_args_; |
Shubham Ajmera | b22dea0 | 2017-10-04 18:36:41 -0700 | [diff] [blame] | 318 | int oat_fd_ = -1; |
| 319 | int vdex_fd_ = -1; |
Shubham Ajmera | c12bf4c | 2017-10-24 16:59:42 -0700 | [diff] [blame] | 320 | // File descriptor corresponding to apk, dex_file, or zip. |
| 321 | int zip_fd_ = -1; |
Calin Juravle | 36eb313 | 2017-01-13 16:32:38 -0800 | [diff] [blame] | 322 | }; |
| 323 | |
| 324 | static int dexoptAnalyze(int argc, char** argv) { |
| 325 | DexoptAnalyzer analyzer; |
| 326 | |
| 327 | // Parse arguments. Argument mistakes will lead to exit(kErrorInvalidArguments) in UsageError. |
| 328 | analyzer.ParseArgs(argc, argv); |
| 329 | return analyzer.GetDexOptNeeded(); |
| 330 | } |
| 331 | |
| 332 | } // namespace art |
| 333 | |
| 334 | int main(int argc, char **argv) { |
| 335 | return art::dexoptAnalyze(argc, argv); |
| 336 | } |