Elliott Hughes | 2faa5f1 | 2012-01-30 14:42:07 -0800 | [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 | */ |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 16 | |
| 17 | #include <stdio.h> |
| 18 | #include <stdlib.h> |
Brian Carlstrom | 6cd40e5 | 2012-05-03 14:15:11 -0700 | [diff] [blame] | 19 | #include <sys/stat.h> |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 20 | |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 21 | #include <iostream> |
| 22 | #include <fstream> |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 23 | #include <string> |
| 24 | #include <vector> |
| 25 | |
Elliott Hughes | 1aa246d | 2012-12-13 09:29:36 -0800 | [diff] [blame] | 26 | #include "base/stl_util.h" |
Elliott Hughes | e222ee0 | 2012-12-13 14:41:43 -0800 | [diff] [blame] | 27 | #include "base/stringpiece.h" |
Sameer Abu Asal | a843954 | 2013-02-14 16:06:42 -0800 | [diff] [blame] | 28 | #include "base/timing_logger.h" |
Elliott Hughes | 7616005 | 2012-12-12 16:31:20 -0800 | [diff] [blame] | 29 | #include "base/unix_file/fd_file.h" |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 30 | #include "class_linker.h" |
Ian Rogers | 1212a02 | 2013-03-04 10:48:41 -0800 | [diff] [blame] | 31 | #include "compiler/driver/compiler_driver.h" |
Ian Rogers | 4f6ad8a | 2013-03-18 15:27:28 -0700 | [diff] [blame] | 32 | #include "dex_file-inl.h" |
Ian Rogers | 1d54e73 | 2013-05-02 21:10:01 -0700 | [diff] [blame] | 33 | #include "gc/space/image_space.h" |
| 34 | #include "gc/space/space-inl.h" |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 35 | #include "image_writer.h" |
Ian Rogers | 6f1dfe4 | 2011-12-08 17:28:34 -0800 | [diff] [blame] | 36 | #include "leb128.h" |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 37 | #include "mirror/abstract_method-inl.h" |
| 38 | #include "mirror/class-inl.h" |
| 39 | #include "mirror/class_loader.h" |
| 40 | #include "mirror/object-inl.h" |
| 41 | #include "mirror/object_array-inl.h" |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 42 | #include "oat_writer.h" |
Ian Rogers | 6d4d9fc | 2011-11-30 16:24:48 -0800 | [diff] [blame] | 43 | #include "object_utils.h" |
Ian Rogers | 5e863dd | 2011-11-02 20:00:10 -0700 | [diff] [blame] | 44 | #include "os.h" |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 45 | #include "runtime.h" |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 46 | #include "ScopedLocalRef.h" |
| 47 | #include "scoped_thread_state_change.h" |
Ian Rogers | 1f53934 | 2012-10-03 21:09:42 -0700 | [diff] [blame] | 48 | #include "sirt_ref.h" |
Brian Carlstrom | 700c8d3 | 2012-11-05 10:42:02 -0800 | [diff] [blame] | 49 | #include "vector_output_stream.h" |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 50 | #include "well_known_classes.h" |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 51 | #include "zip_archive.h" |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 52 | |
| 53 | namespace art { |
| 54 | |
Brian Carlstrom | cbfe6fe | 2012-02-17 11:13:36 -0800 | [diff] [blame] | 55 | static void UsageErrorV(const char* fmt, va_list ap) { |
| 56 | std::string error; |
| 57 | StringAppendV(&error, fmt, ap); |
| 58 | LOG(ERROR) << error; |
| 59 | } |
| 60 | |
| 61 | static void UsageError(const char* fmt, ...) { |
| 62 | va_list ap; |
| 63 | va_start(ap, fmt); |
| 64 | UsageErrorV(fmt, ap); |
| 65 | va_end(ap); |
| 66 | } |
| 67 | |
| 68 | static void Usage(const char* fmt, ...) { |
| 69 | va_list ap; |
| 70 | va_start(ap, fmt); |
| 71 | UsageErrorV(fmt, ap); |
| 72 | va_end(ap); |
| 73 | |
| 74 | UsageError("Usage: dex2oat [options]..."); |
| 75 | UsageError(""); |
| 76 | UsageError(" --dex-file=<dex-file>: specifies a .dex file to compile."); |
| 77 | UsageError(" Example: --dex-file=/system/framework/core.jar"); |
| 78 | UsageError(""); |
| 79 | UsageError(" --zip-fd=<file-descriptor>: specifies a file descriptor of a zip file"); |
| 80 | UsageError(" containing a classes.dex file to compile."); |
| 81 | UsageError(" Example: --zip-fd=5"); |
| 82 | UsageError(""); |
| 83 | UsageError(" --zip-location=<zip-location>: specifies a symbolic name for the file corresponding"); |
| 84 | UsageError(" to the file descriptor specified by --zip-fd."); |
| 85 | UsageError(" Example: --zip-location=/system/app/Calculator.apk"); |
| 86 | UsageError(""); |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 87 | UsageError(" --oat-file=<file.oat>: specifies the oat output destination via a filename."); |
| 88 | UsageError(" Example: --oat-file=/system/framework/boot.oat"); |
| 89 | UsageError(""); |
| 90 | UsageError(" --oat-fd=<number>: specifies the oat output destination via a file descriptor."); |
Brian Carlstrom | cbfe6fe | 2012-02-17 11:13:36 -0800 | [diff] [blame] | 91 | UsageError(" Example: --oat-file=/system/framework/boot.oat"); |
| 92 | UsageError(""); |
| 93 | UsageError(" --oat-location=<oat-name>: specifies a symbolic name for the file corresponding"); |
| 94 | UsageError(" to the file descriptor specified by --oat-fd."); |
Brian Carlstrom | 7675e16 | 2013-06-10 16:18:04 -0700 | [diff] [blame] | 95 | UsageError(" Example: --oat-location=/data/dalvik-cache/system@app@Calculator.apk.oat"); |
Brian Carlstrom | cbfe6fe | 2012-02-17 11:13:36 -0800 | [diff] [blame] | 96 | UsageError(""); |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 97 | UsageError(" --oat-symbols=<file.oat>: specifies the oat output destination with full symbols."); |
| 98 | UsageError(" Example: --oat-symbols=/symbols/system/framework/boot.oat"); |
| 99 | UsageError(""); |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 100 | UsageError(" --bitcode=<file.bc>: specifies the optional bitcode filename."); |
| 101 | UsageError(" Example: --bitcode=/system/framework/boot.bc"); |
| 102 | UsageError(""); |
Brian Carlstrom | cbfe6fe | 2012-02-17 11:13:36 -0800 | [diff] [blame] | 103 | UsageError(" --image=<file.art>: specifies the output image filename."); |
| 104 | UsageError(" Example: --image=/system/framework/boot.art"); |
| 105 | UsageError(""); |
| 106 | UsageError(" --image-classes=<classname-file>: specifies classes to include in an image."); |
| 107 | UsageError(" Example: --image=frameworks/base/preloaded-classes"); |
| 108 | UsageError(""); |
| 109 | UsageError(" --base=<hex-address>: specifies the base address when creating a boot image."); |
| 110 | UsageError(" Example: --base=0x50000000"); |
| 111 | UsageError(""); |
| 112 | UsageError(" --boot-image=<file.art>: provide the image file for the boot class path."); |
| 113 | UsageError(" Example: --boot-image=/system/framework/boot.art"); |
| 114 | UsageError(" Default: <host-prefix>/system/framework/boot.art"); |
| 115 | UsageError(""); |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 116 | UsageError(" --host-prefix=<path>: used to translate host paths to target paths during"); |
Brian Carlstrom | cbfe6fe | 2012-02-17 11:13:36 -0800 | [diff] [blame] | 117 | UsageError(" cross compilation."); |
| 118 | UsageError(" Example: --host-prefix=out/target/product/crespo"); |
| 119 | UsageError(" Default: $ANDROID_PRODUCT_OUT"); |
| 120 | UsageError(""); |
Brian Carlstrom | 3f47c12 | 2013-03-07 00:02:40 -0800 | [diff] [blame] | 121 | UsageError(" --android-root=<path>: used to locate libraries for portable linking."); |
| 122 | UsageError(" Example: --android-root=out/host/linux-x86"); |
| 123 | UsageError(" Default: $ANDROID_ROOT"); |
| 124 | UsageError(""); |
jeffhao | 1f71ae8 | 2012-05-24 16:08:24 -0700 | [diff] [blame] | 125 | UsageError(" --instruction-set=(arm|mips|x86): compile for a particular instruction"); |
Ian Rogers | 49c4894 | 2012-03-11 15:15:37 -0700 | [diff] [blame] | 126 | UsageError(" set."); |
jeffhao | 1f71ae8 | 2012-05-24 16:08:24 -0700 | [diff] [blame] | 127 | UsageError(" Example: --instruction-set=x86"); |
| 128 | UsageError(" Default: arm"); |
Ian Rogers | 49c4894 | 2012-03-11 15:15:37 -0700 | [diff] [blame] | 129 | UsageError(""); |
buzbee | c531cef | 2012-10-18 07:09:20 -0700 | [diff] [blame] | 130 | UsageError(" --compiler-backend=(Quick|QuickGBC|Portable): select compiler backend"); |
| 131 | UsageError(" set."); |
| 132 | UsageError(" Example: --instruction-set=Portable"); |
| 133 | UsageError(" Default: Quick"); |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 134 | UsageError(""); |
| 135 | UsageError(" --host: used with Portable backend to link against host runtime libraries"); |
| 136 | UsageError(""); |
Brian Carlstrom | cbfe6fe | 2012-02-17 11:13:36 -0800 | [diff] [blame] | 137 | UsageError(" --runtime-arg <argument>: used to specify various arguments for the runtime,"); |
| 138 | UsageError(" such as initial heap size, maximum heap size, and verbose output."); |
| 139 | UsageError(" Use a separate --runtime-arg switch for each argument."); |
| 140 | UsageError(" Example: --runtime-arg -Xms256m"); |
| 141 | UsageError(""); |
| 142 | std::cerr << "See log for usage error information\n"; |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 143 | exit(EXIT_FAILURE); |
| 144 | } |
| 145 | |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 146 | class Dex2Oat { |
| 147 | public: |
buzbee | c531cef | 2012-10-18 07:09:20 -0700 | [diff] [blame] | 148 | static bool Create(Dex2Oat** p_dex2oat, Runtime::Options& options, CompilerBackend compiler_backend, |
Anwar Ghuloum | 8447d84 | 2013-04-30 17:27:40 -0700 | [diff] [blame] | 149 | InstructionSet instruction_set, size_t thread_count, bool support_debugging) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 150 | SHARED_TRYLOCK_FUNCTION(true, Locks::mutator_lock_) { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 151 | if (!CreateRuntime(options, instruction_set)) { |
| 152 | *p_dex2oat = NULL; |
| 153 | return false; |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 154 | } |
buzbee | c531cef | 2012-10-18 07:09:20 -0700 | [diff] [blame] | 155 | *p_dex2oat = new Dex2Oat(Runtime::Current(), compiler_backend, instruction_set, thread_count, |
Anwar Ghuloum | 8447d84 | 2013-04-30 17:27:40 -0700 | [diff] [blame] | 156 | support_debugging); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 157 | return true; |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 158 | } |
| 159 | |
| 160 | ~Dex2Oat() { |
| 161 | delete runtime_; |
Elliott Hughes | 5523ee0 | 2012-02-03 18:18:34 -0800 | [diff] [blame] | 162 | LOG(INFO) << "dex2oat took " << PrettyDuration(NanoTime() - start_ns_) << " (threads: " << thread_count_ << ")"; |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 163 | } |
| 164 | |
Anwar Ghuloum | c4f105d | 2013-04-10 16:12:11 -0700 | [diff] [blame] | 165 | |
Brian Carlstrom | 9639160 | 2013-06-13 19:49:50 -0700 | [diff] [blame] | 166 | // Reads the class names (java.lang.Object) and returns as set of class descriptors (Ljava/lang/Object;) |
| 167 | CompilerDriver::DescriptorSet* ReadImageClasses(const char* image_classes_filename) { |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 168 | UniquePtr<std::ifstream> image_classes_file(new std::ifstream(image_classes_filename, std::ifstream::in)); |
| 169 | if (image_classes_file.get() == NULL) { |
| 170 | LOG(ERROR) << "Failed to open image classes file " << image_classes_filename; |
| 171 | return NULL; |
| 172 | } |
| 173 | |
Brian Carlstrom | 9639160 | 2013-06-13 19:49:50 -0700 | [diff] [blame] | 174 | UniquePtr<CompilerDriver::DescriptorSet> image_classes(new CompilerDriver::DescriptorSet); |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 175 | while (image_classes_file->good()) { |
| 176 | std::string dot; |
| 177 | std::getline(*image_classes_file.get(), dot); |
Elliott Hughes | f1a5adc | 2012-02-10 18:09:35 -0800 | [diff] [blame] | 178 | if (StartsWith(dot, "#") || dot.empty()) { |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 179 | continue; |
| 180 | } |
Elliott Hughes | 9557241 | 2011-12-13 18:14:20 -0800 | [diff] [blame] | 181 | std::string descriptor(DotToDescriptor(dot.c_str())); |
Brian Carlstrom | 9639160 | 2013-06-13 19:49:50 -0700 | [diff] [blame] | 182 | image_classes->insert(descriptor); |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 183 | } |
| 184 | image_classes_file->close(); |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 185 | return image_classes.release(); |
| 186 | } |
| 187 | |
Ian Rogers | 1212a02 | 2013-03-04 10:48:41 -0800 | [diff] [blame] | 188 | const CompilerDriver* CreateOatFile(const std::string& boot_image_option, |
Brian Carlstrom | 3f47c12 | 2013-03-07 00:02:40 -0800 | [diff] [blame] | 189 | const std::string* host_prefix, |
| 190 | const std::string& android_root, |
| 191 | bool is_host, |
| 192 | const std::vector<const DexFile*>& dex_files, |
| 193 | File* oat_file, |
| 194 | const std::string& bitcode_filename, |
| 195 | bool image, |
Brian Carlstrom | 9639160 | 2013-06-13 19:49:50 -0700 | [diff] [blame] | 196 | UniquePtr<CompilerDriver::DescriptorSet>& image_classes, |
Brian Carlstrom | 3f47c12 | 2013-03-07 00:02:40 -0800 | [diff] [blame] | 197 | bool dump_stats, |
| 198 | bool dump_timings) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 199 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 200 | // SirtRef and ClassLoader creation needs to come after Runtime::Create |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 201 | jobject class_loader = NULL; |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 202 | if (!boot_image_option.empty()) { |
| 203 | ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 204 | std::vector<const DexFile*> class_path_files(dex_files); |
Brian Carlstrom | a004aa9 | 2012-02-08 18:05:09 -0800 | [diff] [blame] | 205 | OpenClassPathFiles(runtime_->GetClassPathString(), class_path_files); |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 206 | for (size_t i = 0; i < class_path_files.size(); i++) { |
| 207 | class_linker->RegisterDexFile(*class_path_files[i]); |
| 208 | } |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 209 | ScopedObjectAccessUnchecked soa(Thread::Current()); |
| 210 | soa.Env()->AllocObject(WellKnownClasses::dalvik_system_PathClassLoader); |
| 211 | ScopedLocalRef<jobject> class_loader_local(soa.Env(), |
| 212 | soa.Env()->AllocObject(WellKnownClasses::dalvik_system_PathClassLoader)); |
| 213 | class_loader = soa.Env()->NewGlobalRef(class_loader_local.get()); |
| 214 | Runtime::Current()->SetCompileTimeClassPath(class_loader, class_path_files); |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 215 | } |
| 216 | |
Ian Rogers | 1212a02 | 2013-03-04 10:48:41 -0800 | [diff] [blame] | 217 | UniquePtr<CompilerDriver> driver(new CompilerDriver(compiler_backend_, |
| 218 | instruction_set_, |
| 219 | image, |
Brian Carlstrom | 9639160 | 2013-06-13 19:49:50 -0700 | [diff] [blame] | 220 | image_classes.release(), |
Ian Rogers | 1212a02 | 2013-03-04 10:48:41 -0800 | [diff] [blame] | 221 | thread_count_, |
| 222 | support_debugging_, |
Ian Rogers | 1212a02 | 2013-03-04 10:48:41 -0800 | [diff] [blame] | 223 | dump_stats, |
| 224 | dump_timings)); |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 225 | |
Ian Rogers | c928de9 | 2013-02-27 14:30:44 -0800 | [diff] [blame] | 226 | if (compiler_backend_ == kPortable) { |
Ian Rogers | 1212a02 | 2013-03-04 10:48:41 -0800 | [diff] [blame] | 227 | driver->SetBitcodeFileName(bitcode_filename); |
buzbee | c531cef | 2012-10-18 07:09:20 -0700 | [diff] [blame] | 228 | } |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 229 | |
Anwar Ghuloum | 8447d84 | 2013-04-30 17:27:40 -0700 | [diff] [blame] | 230 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 231 | Thread::Current()->TransitionFromRunnableToSuspended(kNative); |
| 232 | |
Ian Rogers | 1212a02 | 2013-03-04 10:48:41 -0800 | [diff] [blame] | 233 | driver->CompileAll(class_loader, dex_files); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 234 | |
| 235 | Thread::Current()->TransitionFromSuspendedToRunnable(); |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 236 | |
Brian Carlstrom | 81f3ca1 | 2012-03-17 00:27:35 -0700 | [diff] [blame] | 237 | std::string image_file_location; |
Brian Carlstrom | 28db012 | 2012-10-18 16:20:41 -0700 | [diff] [blame] | 238 | uint32_t image_file_location_oat_checksum = 0; |
Brian Carlstrom | 700c8d3 | 2012-11-05 10:42:02 -0800 | [diff] [blame] | 239 | uint32_t image_file_location_oat_data_begin = 0; |
Jeff Hao | 0aba0ba | 2013-06-03 14:49:28 -0700 | [diff] [blame] | 240 | if (!driver->IsImage()) { |
Ian Rogers | 1d54e73 | 2013-05-02 21:10:01 -0700 | [diff] [blame] | 241 | gc::space::ImageSpace* image_space = Runtime::Current()->GetHeap()->GetImageSpace(); |
Brian Carlstrom | 28db012 | 2012-10-18 16:20:41 -0700 | [diff] [blame] | 242 | image_file_location_oat_checksum = image_space->GetImageHeader().GetOatChecksum(); |
Ian Rogers | 39ebcb8 | 2013-05-30 16:57:23 -0700 | [diff] [blame] | 243 | image_file_location_oat_data_begin = |
| 244 | reinterpret_cast<uint32_t>(image_space->GetImageHeader().GetOatDataBegin()); |
Brian Carlstrom | 81f3ca1 | 2012-03-17 00:27:35 -0700 | [diff] [blame] | 245 | image_file_location = image_space->GetImageFilename(); |
Brian Carlstrom | 34f1fa4 | 2012-04-05 18:28:12 -0700 | [diff] [blame] | 246 | if (host_prefix != NULL && StartsWith(image_file_location, host_prefix->c_str())) { |
| 247 | image_file_location = image_file_location.substr(host_prefix->size()); |
Brian Carlstrom | 81f3ca1 | 2012-03-17 00:27:35 -0700 | [diff] [blame] | 248 | } |
| 249 | } |
| 250 | |
Brian Carlstrom | 700c8d3 | 2012-11-05 10:42:02 -0800 | [diff] [blame] | 251 | std::vector<uint8_t> oat_contents; |
Ian Rogers | 39ebcb8 | 2013-05-30 16:57:23 -0700 | [diff] [blame] | 252 | // TODO: change ElfWriterQuick to not require the creation of oat_contents. The old pre-mclinker |
| 253 | // OatWriter streamed directly to disk. The new could can be adapted to do it as follows: |
| 254 | // 1.) use first pass of OatWriter to calculate size of oat structure, |
| 255 | // 2.) call ElfWriterQuick with pointer to OatWriter instead of contents, |
| 256 | // 3.) have ElfWriterQuick call back to OatWriter to stream generate the output directly in |
| 257 | // place in the elf file. |
| 258 | oat_contents.reserve(5 * MB); |
Brian Carlstrom | 700c8d3 | 2012-11-05 10:42:02 -0800 | [diff] [blame] | 259 | VectorOutputStream vector_output_stream(oat_file->GetPath(), oat_contents); |
| 260 | if (!OatWriter::Create(vector_output_stream, |
Brian Carlstrom | 81f3ca1 | 2012-03-17 00:27:35 -0700 | [diff] [blame] | 261 | dex_files, |
Brian Carlstrom | 28db012 | 2012-10-18 16:20:41 -0700 | [diff] [blame] | 262 | image_file_location_oat_checksum, |
Brian Carlstrom | 700c8d3 | 2012-11-05 10:42:02 -0800 | [diff] [blame] | 263 | image_file_location_oat_data_begin, |
Brian Carlstrom | 81f3ca1 | 2012-03-17 00:27:35 -0700 | [diff] [blame] | 264 | image_file_location, |
Ian Rogers | 1212a02 | 2013-03-04 10:48:41 -0800 | [diff] [blame] | 265 | *driver.get())) { |
Elliott Hughes | 7616005 | 2012-12-12 16:31:20 -0800 | [diff] [blame] | 266 | LOG(ERROR) << "Failed to create oat file " << oat_file->GetPath(); |
Brian Carlstrom | f582258 | 2012-03-19 22:34:31 -0700 | [diff] [blame] | 267 | return NULL; |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 268 | } |
Brian Carlstrom | 700c8d3 | 2012-11-05 10:42:02 -0800 | [diff] [blame] | 269 | |
Brian Carlstrom | 3f47c12 | 2013-03-07 00:02:40 -0800 | [diff] [blame] | 270 | if (!driver->WriteElf(android_root, is_host, dex_files, oat_contents, oat_file)) { |
Brian Carlstrom | 700c8d3 | 2012-11-05 10:42:02 -0800 | [diff] [blame] | 271 | LOG(ERROR) << "Failed to write ELF file " << oat_file->GetPath(); |
| 272 | return NULL; |
| 273 | } |
| 274 | |
Ian Rogers | 1212a02 | 2013-03-04 10:48:41 -0800 | [diff] [blame] | 275 | return driver.release(); |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 276 | } |
| 277 | |
Brian Carlstrom | a004aa9 | 2012-02-08 18:05:09 -0800 | [diff] [blame] | 278 | bool CreateImageFile(const std::string& image_filename, |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 279 | uintptr_t image_base, |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 280 | const std::string& oat_filename, |
Brian Carlstrom | f582258 | 2012-03-19 22:34:31 -0700 | [diff] [blame] | 281 | const std::string& oat_location, |
Ian Rogers | 1212a02 | 2013-03-04 10:48:41 -0800 | [diff] [blame] | 282 | const CompilerDriver& compiler) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 283 | LOCKS_EXCLUDED(Locks::mutator_lock_) { |
Brian Carlstrom | 700c8d3 | 2012-11-05 10:42:02 -0800 | [diff] [blame] | 284 | uintptr_t oat_data_begin; |
| 285 | { |
| 286 | // ImageWriter is scoped so it can free memory before doing FixupElf |
Brian Carlstrom | 9639160 | 2013-06-13 19:49:50 -0700 | [diff] [blame] | 287 | ImageWriter image_writer(compiler); |
| 288 | if (!image_writer.Write(image_filename, image_base, oat_filename, oat_location)) { |
Brian Carlstrom | 700c8d3 | 2012-11-05 10:42:02 -0800 | [diff] [blame] | 289 | LOG(ERROR) << "Failed to create image file " << image_filename; |
| 290 | return false; |
| 291 | } |
| 292 | oat_data_begin = image_writer.GetOatDataBegin(); |
| 293 | } |
| 294 | |
Brian Carlstrom | 700c8d3 | 2012-11-05 10:42:02 -0800 | [diff] [blame] | 295 | UniquePtr<File> oat_file(OS::OpenFile(oat_filename.c_str(), true, false)); |
Brian Carlstrom | 700c8d3 | 2012-11-05 10:42:02 -0800 | [diff] [blame] | 296 | if (oat_file.get() == NULL) { |
| 297 | PLOG(ERROR) << "Failed to open ELF file: " << oat_filename; |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 298 | return false; |
| 299 | } |
Brian Carlstrom | 700c8d3 | 2012-11-05 10:42:02 -0800 | [diff] [blame] | 300 | if (!compiler.FixupElf(oat_file.get(), oat_data_begin)) { |
| 301 | LOG(ERROR) << "Failed to fixup ELF file " << oat_file->GetPath(); |
| 302 | return false; |
| 303 | } |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 304 | return true; |
| 305 | } |
| 306 | |
| 307 | private: |
buzbee | c531cef | 2012-10-18 07:09:20 -0700 | [diff] [blame] | 308 | explicit Dex2Oat(Runtime* runtime, CompilerBackend compiler_backend, InstructionSet instruction_set, |
Anwar Ghuloum | 8447d84 | 2013-04-30 17:27:40 -0700 | [diff] [blame] | 309 | size_t thread_count, bool support_debugging) |
buzbee | c531cef | 2012-10-18 07:09:20 -0700 | [diff] [blame] | 310 | : compiler_backend_(compiler_backend), |
| 311 | instruction_set_(instruction_set), |
Ian Rogers | 49c4894 | 2012-03-11 15:15:37 -0700 | [diff] [blame] | 312 | runtime_(runtime), |
Elliott Hughes | de6e4cf | 2012-02-27 14:46:06 -0800 | [diff] [blame] | 313 | thread_count_(thread_count), |
| 314 | support_debugging_(support_debugging), |
| 315 | start_ns_(NanoTime()) { |
Elliott Hughes | bb551fa | 2012-01-25 16:35:29 -0800 | [diff] [blame] | 316 | } |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 317 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 318 | static bool CreateRuntime(Runtime::Options& options, InstructionSet instruction_set) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 319 | SHARED_TRYLOCK_FUNCTION(true, Locks::mutator_lock_) { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 320 | if (!Runtime::Create(options, false)) { |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 321 | LOG(ERROR) << "Failed to create runtime"; |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 322 | return false; |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 323 | } |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 324 | Runtime* runtime = Runtime::Current(); |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 325 | // if we loaded an existing image, we will reuse values from the image roots. |
Ian Rogers | 1984651 | 2012-02-24 11:42:47 -0800 | [diff] [blame] | 326 | if (!runtime->HasResolutionMethod()) { |
| 327 | runtime->SetResolutionMethod(runtime->CreateResolutionMethod()); |
| 328 | } |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 329 | for (int i = 0; i < Runtime::kLastCalleeSaveType; i++) { |
| 330 | Runtime::CalleeSaveType type = Runtime::CalleeSaveType(i); |
| 331 | if (!runtime->HasCalleeSaveMethod(type)) { |
Ian Rogers | 49c4894 | 2012-03-11 15:15:37 -0700 | [diff] [blame] | 332 | runtime->SetCalleeSaveMethod(runtime->CreateCalleeSaveMethod(instruction_set, type), type); |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 333 | } |
| 334 | } |
Ian Rogers | 1984651 | 2012-02-24 11:42:47 -0800 | [diff] [blame] | 335 | runtime->GetClassLinker()->FixupDexCaches(runtime->GetResolutionMethod()); |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 336 | return true; |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 337 | } |
| 338 | |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 339 | // Appends to dex_files any elements of class_path that it doesn't already |
| 340 | // contain. This will open those dex files as necessary. |
| 341 | static void OpenClassPathFiles(const std::string& class_path, std::vector<const DexFile*>& dex_files) { |
| 342 | std::vector<std::string> parsed; |
| 343 | Split(class_path, ':', parsed); |
Ian Rogers | 33e9566 | 2013-05-20 20:29:14 -0700 | [diff] [blame] | 344 | // Take Locks::mutator_lock_ so that lock ordering on the ClassLinker::dex_lock_ is maintained. |
| 345 | ScopedObjectAccess soa(Thread::Current()); |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 346 | for (size_t i = 0; i < parsed.size(); ++i) { |
| 347 | if (DexFilesContains(dex_files, parsed[i])) { |
| 348 | continue; |
| 349 | } |
Brian Carlstrom | a004aa9 | 2012-02-08 18:05:09 -0800 | [diff] [blame] | 350 | const DexFile* dex_file = DexFile::Open(parsed[i], parsed[i]); |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 351 | if (dex_file == NULL) { |
| 352 | LOG(WARNING) << "Failed to open dex file " << parsed[i]; |
| 353 | } else { |
| 354 | dex_files.push_back(dex_file); |
| 355 | } |
Jesse Wilson | 254db0f | 2011-11-16 16:44:11 -0500 | [diff] [blame] | 356 | } |
| 357 | } |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 358 | |
| 359 | // Returns true if dex_files has a dex with the named location. |
| 360 | static bool DexFilesContains(const std::vector<const DexFile*>& dex_files, const std::string& location) { |
| 361 | for (size_t i = 0; i < dex_files.size(); ++i) { |
| 362 | if (dex_files[i]->GetLocation() == location) { |
| 363 | return true; |
| 364 | } |
| 365 | } |
| 366 | return false; |
| 367 | } |
| 368 | |
buzbee | c531cef | 2012-10-18 07:09:20 -0700 | [diff] [blame] | 369 | const CompilerBackend compiler_backend_; |
| 370 | |
Ian Rogers | 49c4894 | 2012-03-11 15:15:37 -0700 | [diff] [blame] | 371 | const InstructionSet instruction_set_; |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 372 | |
Elliott Hughes | bb551fa | 2012-01-25 16:35:29 -0800 | [diff] [blame] | 373 | Runtime* runtime_; |
Elliott Hughes | 5523ee0 | 2012-02-03 18:18:34 -0800 | [diff] [blame] | 374 | size_t thread_count_; |
Elliott Hughes | de6e4cf | 2012-02-27 14:46:06 -0800 | [diff] [blame] | 375 | bool support_debugging_; |
Elliott Hughes | bb551fa | 2012-01-25 16:35:29 -0800 | [diff] [blame] | 376 | uint64_t start_ns_; |
| 377 | |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 378 | DISALLOW_IMPLICIT_CONSTRUCTORS(Dex2Oat); |
| 379 | }; |
Jesse Wilson | 254db0f | 2011-11-16 16:44:11 -0500 | [diff] [blame] | 380 | |
Elliott Hughes | 72395bf | 2012-04-24 13:45:26 -0700 | [diff] [blame] | 381 | static bool ParseInt(const char* in, int* out) { |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 382 | char* end; |
| 383 | int result = strtol(in, &end, 10); |
| 384 | if (in == end || *end != '\0') { |
| 385 | return false; |
| 386 | } |
| 387 | *out = result; |
| 388 | return true; |
| 389 | } |
| 390 | |
Elliott Hughes | bf1b457 | 2012-05-24 19:11:39 -0700 | [diff] [blame] | 391 | static size_t OpenDexFiles(const std::vector<const char*>& dex_filenames, |
| 392 | const std::vector<const char*>& dex_locations, |
| 393 | std::vector<const DexFile*>& dex_files) { |
| 394 | size_t failure_count = 0; |
Brian Carlstrom | 5b332c8 | 2012-02-01 15:02:31 -0800 | [diff] [blame] | 395 | for (size_t i = 0; i < dex_filenames.size(); i++) { |
| 396 | const char* dex_filename = dex_filenames[i]; |
Brian Carlstrom | a004aa9 | 2012-02-08 18:05:09 -0800 | [diff] [blame] | 397 | const char* dex_location = dex_locations[i]; |
| 398 | const DexFile* dex_file = DexFile::Open(dex_filename, dex_location); |
Brian Carlstrom | 5b332c8 | 2012-02-01 15:02:31 -0800 | [diff] [blame] | 399 | if (dex_file == NULL) { |
Ian Rogers | 33e9566 | 2013-05-20 20:29:14 -0700 | [diff] [blame] | 400 | LOG(WARNING) << "Could not open .dex from file '" << dex_filename << "'\n"; |
Elliott Hughes | bf1b457 | 2012-05-24 19:11:39 -0700 | [diff] [blame] | 401 | ++failure_count; |
jeffhao | 60f83e3 | 2012-02-13 17:16:30 -0800 | [diff] [blame] | 402 | } else { |
| 403 | dex_files.push_back(dex_file); |
Brian Carlstrom | 5b332c8 | 2012-02-01 15:02:31 -0800 | [diff] [blame] | 404 | } |
Brian Carlstrom | 5b332c8 | 2012-02-01 15:02:31 -0800 | [diff] [blame] | 405 | } |
Elliott Hughes | bf1b457 | 2012-05-24 19:11:39 -0700 | [diff] [blame] | 406 | return failure_count; |
Brian Carlstrom | 5b332c8 | 2012-02-01 15:02:31 -0800 | [diff] [blame] | 407 | } |
| 408 | |
Brian Carlstrom | bcc2926 | 2012-11-02 11:36:03 -0700 | [diff] [blame] | 409 | // The primary goal of the watchdog is to prevent stuck build servers |
| 410 | // during development when fatal aborts lead to a cascade of failures |
| 411 | // that result in a deadlock. |
| 412 | class WatchDog { |
| 413 | |
| 414 | // WatchDog defines its own CHECK_PTHREAD_CALL to avoid using Log which uses locks |
| 415 | #undef CHECK_PTHREAD_CALL |
| 416 | #define CHECK_WATCH_DOG_PTHREAD_CALL(call, args, what) \ |
| 417 | do { \ |
| 418 | int rc = call args; \ |
| 419 | if (rc != 0) { \ |
| 420 | errno = rc; \ |
| 421 | std::string message(# call); \ |
| 422 | message += " failed for "; \ |
| 423 | message += reason; \ |
Brian Carlstrom | ed11564 | 2013-03-15 16:04:40 -0700 | [diff] [blame] | 424 | Fatal(message); \ |
Brian Carlstrom | bcc2926 | 2012-11-02 11:36:03 -0700 | [diff] [blame] | 425 | } \ |
| 426 | } while (false) |
| 427 | |
| 428 | public: |
Brian Carlstrom | 994d62a | 2012-11-05 20:43:45 -0800 | [diff] [blame] | 429 | WatchDog(bool is_watch_dog_enabled) { |
| 430 | is_watch_dog_enabled_ = is_watch_dog_enabled; |
| 431 | if (!is_watch_dog_enabled_) { |
Brian Carlstrom | bcc2926 | 2012-11-02 11:36:03 -0700 | [diff] [blame] | 432 | return; |
| 433 | } |
| 434 | shutting_down_ = false; |
| 435 | const char* reason = "dex2oat watch dog thread startup"; |
| 436 | CHECK_WATCH_DOG_PTHREAD_CALL(pthread_mutex_init, (&mutex_, NULL), reason); |
| 437 | CHECK_WATCH_DOG_PTHREAD_CALL(pthread_cond_init, (&cond_, NULL), reason); |
| 438 | CHECK_WATCH_DOG_PTHREAD_CALL(pthread_attr_init, (&attr_), reason); |
| 439 | CHECK_WATCH_DOG_PTHREAD_CALL(pthread_create, (&pthread_, &attr_, &CallBack, this), reason); |
| 440 | CHECK_WATCH_DOG_PTHREAD_CALL(pthread_attr_destroy, (&attr_), reason); |
| 441 | } |
| 442 | ~WatchDog() { |
Brian Carlstrom | 994d62a | 2012-11-05 20:43:45 -0800 | [diff] [blame] | 443 | if (!is_watch_dog_enabled_) { |
Brian Carlstrom | bcc2926 | 2012-11-02 11:36:03 -0700 | [diff] [blame] | 444 | return; |
| 445 | } |
| 446 | const char* reason = "dex2oat watch dog thread shutdown"; |
| 447 | CHECK_WATCH_DOG_PTHREAD_CALL(pthread_mutex_lock, (&mutex_), reason); |
| 448 | shutting_down_ = true; |
| 449 | CHECK_WATCH_DOG_PTHREAD_CALL(pthread_cond_signal, (&cond_), reason); |
| 450 | CHECK_WATCH_DOG_PTHREAD_CALL(pthread_mutex_unlock, (&mutex_), reason); |
| 451 | |
| 452 | CHECK_WATCH_DOG_PTHREAD_CALL(pthread_join, (pthread_, NULL), reason); |
| 453 | |
| 454 | CHECK_WATCH_DOG_PTHREAD_CALL(pthread_cond_destroy, (&cond_), reason); |
| 455 | CHECK_WATCH_DOG_PTHREAD_CALL(pthread_mutex_destroy, (&mutex_), reason); |
| 456 | } |
| 457 | |
| 458 | private: |
| 459 | static void* CallBack(void* arg) { |
| 460 | WatchDog* self = reinterpret_cast<WatchDog*>(arg); |
Ian Rogers | 1d54e73 | 2013-05-02 21:10:01 -0700 | [diff] [blame] | 461 | ::art::SetThreadName("dex2oat watch dog"); |
Brian Carlstrom | bcc2926 | 2012-11-02 11:36:03 -0700 | [diff] [blame] | 462 | self->Wait(); |
| 463 | return NULL; |
| 464 | } |
| 465 | |
Brian Carlstrom | ed11564 | 2013-03-15 16:04:40 -0700 | [diff] [blame] | 466 | static void Message(char severity, const std::string& message) { |
Ian Rogers | 1d54e73 | 2013-05-02 21:10:01 -0700 | [diff] [blame] | 467 | // TODO: Remove when we switch to LOG when we can guarantee it won't prevent shutdown in error |
| 468 | // cases. |
Brian Carlstrom | ed11564 | 2013-03-15 16:04:40 -0700 | [diff] [blame] | 469 | fprintf(stderr, "dex2oat%s %c %d %d %s\n", |
| 470 | kIsDebugBuild ? "d" : "", |
| 471 | severity, |
| 472 | getpid(), |
| 473 | GetTid(), |
| 474 | message.c_str()); |
Ian Rogers | eb5cb60 | 2013-02-25 15:06:01 -0800 | [diff] [blame] | 475 | } |
| 476 | |
Brian Carlstrom | ed11564 | 2013-03-15 16:04:40 -0700 | [diff] [blame] | 477 | static void Warn(const std::string& message) { |
| 478 | Message('W', message); |
| 479 | } |
| 480 | |
| 481 | static void Fatal(const std::string& message) { |
| 482 | Message('F', message); |
Brian Carlstrom | bcc2926 | 2012-11-02 11:36:03 -0700 | [diff] [blame] | 483 | exit(1); |
| 484 | } |
| 485 | |
| 486 | void Wait() { |
Ian Rogers | eb5cb60 | 2013-02-25 15:06:01 -0800 | [diff] [blame] | 487 | bool warning = true; |
Ian Rogers | eb5cb60 | 2013-02-25 15:06:01 -0800 | [diff] [blame] | 488 | CHECK_GT(kWatchDogTimeoutSeconds, kWatchDogWarningSeconds); |
Ian Rogers | 1d54e73 | 2013-05-02 21:10:01 -0700 | [diff] [blame] | 489 | // TODO: tune the multiplier for GC verification, the following is just to make the timeout |
| 490 | // large. |
| 491 | int64_t multiplier = gc::kDesiredHeapVerification > gc::kVerifyAllFast ? 100 : 1; |
Brian Carlstrom | ed11564 | 2013-03-15 16:04:40 -0700 | [diff] [blame] | 492 | timespec warning_ts; |
Ian Rogers | 1d54e73 | 2013-05-02 21:10:01 -0700 | [diff] [blame] | 493 | InitTimeSpec(true, CLOCK_REALTIME, multiplier * kWatchDogWarningSeconds * 1000, 0, &warning_ts); |
Brian Carlstrom | ed11564 | 2013-03-15 16:04:40 -0700 | [diff] [blame] | 494 | timespec timeout_ts; |
Ian Rogers | 1d54e73 | 2013-05-02 21:10:01 -0700 | [diff] [blame] | 495 | InitTimeSpec(true, CLOCK_REALTIME, multiplier * kWatchDogTimeoutSeconds * 1000, 0, &timeout_ts); |
Brian Carlstrom | bcc2926 | 2012-11-02 11:36:03 -0700 | [diff] [blame] | 496 | const char* reason = "dex2oat watch dog thread waiting"; |
| 497 | CHECK_WATCH_DOG_PTHREAD_CALL(pthread_mutex_lock, (&mutex_), reason); |
| 498 | while (!shutting_down_) { |
Ian Rogers | eb5cb60 | 2013-02-25 15:06:01 -0800 | [diff] [blame] | 499 | int rc = TEMP_FAILURE_RETRY(pthread_cond_timedwait(&cond_, &mutex_, |
| 500 | warning ? &warning_ts |
| 501 | : &timeout_ts)); |
Brian Carlstrom | bcc2926 | 2012-11-02 11:36:03 -0700 | [diff] [blame] | 502 | if (rc == ETIMEDOUT) { |
| 503 | std::string message(StringPrintf("dex2oat did not finish after %d seconds", |
Ian Rogers | eb5cb60 | 2013-02-25 15:06:01 -0800 | [diff] [blame] | 504 | warning ? kWatchDogWarningSeconds |
| 505 | : kWatchDogTimeoutSeconds)); |
| 506 | if (warning) { |
| 507 | Warn(message.c_str()); |
| 508 | warning = false; |
| 509 | } else { |
Brian Carlstrom | ed11564 | 2013-03-15 16:04:40 -0700 | [diff] [blame] | 510 | Fatal(message.c_str()); |
Ian Rogers | eb5cb60 | 2013-02-25 15:06:01 -0800 | [diff] [blame] | 511 | } |
| 512 | } else if (rc != 0) { |
Brian Carlstrom | bcc2926 | 2012-11-02 11:36:03 -0700 | [diff] [blame] | 513 | std::string message(StringPrintf("pthread_cond_timedwait failed: %s", |
| 514 | strerror(errno))); |
Brian Carlstrom | ed11564 | 2013-03-15 16:04:40 -0700 | [diff] [blame] | 515 | Fatal(message.c_str()); |
Brian Carlstrom | bcc2926 | 2012-11-02 11:36:03 -0700 | [diff] [blame] | 516 | } |
| 517 | } |
| 518 | CHECK_WATCH_DOG_PTHREAD_CALL(pthread_mutex_unlock, (&mutex_), reason); |
| 519 | } |
| 520 | |
Brian Carlstrom | ed11564 | 2013-03-15 16:04:40 -0700 | [diff] [blame] | 521 | // When setting timeouts, keep in mind that the build server may not be as fast as your desktop. |
| 522 | #if ART_USE_PORTABLE_COMPILER |
| 523 | static const unsigned int kWatchDogWarningSeconds = 2 * 60; // 2 minutes. |
Ian Rogers | eb5cb60 | 2013-02-25 15:06:01 -0800 | [diff] [blame] | 524 | static const unsigned int kWatchDogTimeoutSeconds = 30 * 60; // 25 minutes + buffer. |
Brian Carlstrom | bcc2926 | 2012-11-02 11:36:03 -0700 | [diff] [blame] | 525 | #else |
Brian Carlstrom | ed11564 | 2013-03-15 16:04:40 -0700 | [diff] [blame] | 526 | static const unsigned int kWatchDogWarningSeconds = 1 * 60; // 1 minute. |
| 527 | static const unsigned int kWatchDogTimeoutSeconds = 6 * 60; // 5 minutes + buffer. |
Brian Carlstrom | bcc2926 | 2012-11-02 11:36:03 -0700 | [diff] [blame] | 528 | #endif |
| 529 | |
Brian Carlstrom | 994d62a | 2012-11-05 20:43:45 -0800 | [diff] [blame] | 530 | bool is_watch_dog_enabled_; |
Brian Carlstrom | bcc2926 | 2012-11-02 11:36:03 -0700 | [diff] [blame] | 531 | bool shutting_down_; |
Ian Rogers | 1d54e73 | 2013-05-02 21:10:01 -0700 | [diff] [blame] | 532 | // TODO: Switch to Mutex when we can guarantee it won't prevent shutdown in error cases. |
Brian Carlstrom | bcc2926 | 2012-11-02 11:36:03 -0700 | [diff] [blame] | 533 | pthread_mutex_t mutex_; |
| 534 | pthread_cond_t cond_; |
| 535 | pthread_attr_t attr_; |
| 536 | pthread_t pthread_; |
| 537 | }; |
Ian Rogers | 1c653d5 | 2013-06-13 15:04:30 -0700 | [diff] [blame] | 538 | const unsigned int WatchDog::kWatchDogWarningSeconds; |
| 539 | const unsigned int WatchDog::kWatchDogTimeoutSeconds; |
Brian Carlstrom | bcc2926 | 2012-11-02 11:36:03 -0700 | [diff] [blame] | 540 | |
Elliott Hughes | 72395bf | 2012-04-24 13:45:26 -0700 | [diff] [blame] | 541 | static int dex2oat(int argc, char** argv) { |
Elliott Hughes | 0d39c12 | 2012-06-06 16:41:17 -0700 | [diff] [blame] | 542 | InitLogging(argv); |
Elliott Hughes | 72395bf | 2012-04-24 13:45:26 -0700 | [diff] [blame] | 543 | |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 544 | // Skip over argv[0]. |
| 545 | argv++; |
| 546 | argc--; |
| 547 | |
| 548 | if (argc == 0) { |
Brian Carlstrom | cbfe6fe | 2012-02-17 11:13:36 -0800 | [diff] [blame] | 549 | Usage("no arguments specified"); |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 550 | } |
| 551 | |
| 552 | std::vector<const char*> dex_filenames; |
Brian Carlstrom | a004aa9 | 2012-02-08 18:05:09 -0800 | [diff] [blame] | 553 | std::vector<const char*> dex_locations; |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 554 | int zip_fd = -1; |
Brian Carlstrom | a004aa9 | 2012-02-08 18:05:09 -0800 | [diff] [blame] | 555 | std::string zip_location; |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 556 | std::string oat_filename; |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 557 | std::string oat_symbols; |
Brian Carlstrom | a004aa9 | 2012-02-08 18:05:09 -0800 | [diff] [blame] | 558 | std::string oat_location; |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 559 | int oat_fd = -1; |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 560 | std::string bitcode_filename; |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 561 | const char* image_classes_filename = NULL; |
Brian Carlstrom | a004aa9 | 2012-02-08 18:05:09 -0800 | [diff] [blame] | 562 | std::string image_filename; |
Brian Carlstrom | b001126 | 2011-12-09 12:17:24 -0800 | [diff] [blame] | 563 | std::string boot_image_filename; |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 564 | uintptr_t image_base = 0; |
Brian Carlstrom | 34f1fa4 | 2012-04-05 18:28:12 -0700 | [diff] [blame] | 565 | UniquePtr<std::string> host_prefix; |
Brian Carlstrom | 3f47c12 | 2013-03-07 00:02:40 -0800 | [diff] [blame] | 566 | std::string android_root; |
jeffhao | 5d84040 | 2011-10-24 17:09:45 -0700 | [diff] [blame] | 567 | std::vector<const char*> runtime_args; |
Elliott Hughes | 5c59994 | 2012-06-13 16:45:05 -0700 | [diff] [blame] | 568 | int thread_count = sysconf(_SC_NPROCESSORS_CONF); |
Elliott Hughes | de6e4cf | 2012-02-27 14:46:06 -0800 | [diff] [blame] | 569 | bool support_debugging = false; |
buzbee | c531cef | 2012-10-18 07:09:20 -0700 | [diff] [blame] | 570 | #if defined(ART_USE_PORTABLE_COMPILER) |
| 571 | CompilerBackend compiler_backend = kPortable; |
buzbee | c531cef | 2012-10-18 07:09:20 -0700 | [diff] [blame] | 572 | #else |
| 573 | CompilerBackend compiler_backend = kQuick; |
| 574 | #endif |
jeffhao | 9ad4f22 | 2012-05-30 18:51:19 -0700 | [diff] [blame] | 575 | #if defined(__arm__) |
Ian Rogers | 49c4894 | 2012-03-11 15:15:37 -0700 | [diff] [blame] | 576 | InstructionSet instruction_set = kThumb2; |
jeffhao | 9ad4f22 | 2012-05-30 18:51:19 -0700 | [diff] [blame] | 577 | #elif defined(__i386__) |
| 578 | InstructionSet instruction_set = kX86; |
| 579 | #elif defined(__mips__) |
| 580 | InstructionSet instruction_set = kMips; |
| 581 | #else |
| 582 | #error "Unsupported architecture" |
| 583 | #endif |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 584 | bool is_host = false; |
Elliott Hughes | 67d9200 | 2012-03-26 15:08:51 -0700 | [diff] [blame] | 585 | bool dump_stats = kIsDebugBuild; |
| 586 | bool dump_timings = kIsDebugBuild; |
Brian Carlstrom | 994d62a | 2012-11-05 20:43:45 -0800 | [diff] [blame] | 587 | bool watch_dog_enabled = !kIsTargetBuild; |
Brian Carlstrom | 1619286 | 2011-09-12 17:50:06 -0700 | [diff] [blame] | 588 | |
Anwar Ghuloum | c4f105d | 2013-04-10 16:12:11 -0700 | [diff] [blame] | 589 | |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 590 | for (int i = 0; i < argc; i++) { |
| 591 | const StringPiece option(argv[i]); |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 592 | bool log_options = false; |
| 593 | if (log_options) { |
Brian Carlstrom | b7bbba4 | 2011-10-13 14:58:47 -0700 | [diff] [blame] | 594 | LOG(INFO) << "dex2oat: option[" << i << "]=" << argv[i]; |
| 595 | } |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 596 | if (option.starts_with("--dex-file=")) { |
| 597 | dex_filenames.push_back(option.substr(strlen("--dex-file=")).data()); |
Brian Carlstrom | a004aa9 | 2012-02-08 18:05:09 -0800 | [diff] [blame] | 598 | } else if (option.starts_with("--dex-location=")) { |
| 599 | dex_locations.push_back(option.substr(strlen("--dex-location=")).data()); |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 600 | } else if (option.starts_with("--zip-fd=")) { |
| 601 | const char* zip_fd_str = option.substr(strlen("--zip-fd=")).data(); |
Elliott Hughes | bb551fa | 2012-01-25 16:35:29 -0800 | [diff] [blame] | 602 | if (!ParseInt(zip_fd_str, &zip_fd)) { |
Brian Carlstrom | cbfe6fe | 2012-02-17 11:13:36 -0800 | [diff] [blame] | 603 | Usage("could not parse --zip-fd argument '%s' as an integer", zip_fd_str); |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 604 | } |
Brian Carlstrom | a004aa9 | 2012-02-08 18:05:09 -0800 | [diff] [blame] | 605 | } else if (option.starts_with("--zip-location=")) { |
| 606 | zip_location = option.substr(strlen("--zip-location=")).data(); |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 607 | } else if (option.starts_with("--oat-file=")) { |
| 608 | oat_filename = option.substr(strlen("--oat-file=")).data(); |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 609 | } else if (option.starts_with("--oat-symbols=")) { |
| 610 | oat_symbols = option.substr(strlen("--oat-symbols=")).data(); |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 611 | } else if (option.starts_with("--oat-fd=")) { |
| 612 | const char* oat_fd_str = option.substr(strlen("--oat-fd=")).data(); |
Elliott Hughes | bb551fa | 2012-01-25 16:35:29 -0800 | [diff] [blame] | 613 | if (!ParseInt(oat_fd_str, &oat_fd)) { |
Brian Carlstrom | cbfe6fe | 2012-02-17 11:13:36 -0800 | [diff] [blame] | 614 | Usage("could not parse --oat-fd argument '%s' as an integer", oat_fd_str); |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 615 | } |
Brian Carlstrom | 994d62a | 2012-11-05 20:43:45 -0800 | [diff] [blame] | 616 | } else if (option == "-g") { |
Elliott Hughes | de6e4cf | 2012-02-27 14:46:06 -0800 | [diff] [blame] | 617 | support_debugging = true; |
Brian Carlstrom | 994d62a | 2012-11-05 20:43:45 -0800 | [diff] [blame] | 618 | } else if (option == "--watch-dog") { |
| 619 | watch_dog_enabled = true; |
| 620 | } else if (option == "--no-watch-dog") { |
| 621 | watch_dog_enabled = false; |
Elliott Hughes | 5523ee0 | 2012-02-03 18:18:34 -0800 | [diff] [blame] | 622 | } else if (option.starts_with("-j")) { |
Brian Carlstrom | b12552a | 2012-02-04 17:17:31 -0800 | [diff] [blame] | 623 | const char* thread_count_str = option.substr(strlen("-j")).data(); |
Elliott Hughes | 5523ee0 | 2012-02-03 18:18:34 -0800 | [diff] [blame] | 624 | if (!ParseInt(thread_count_str, &thread_count)) { |
Brian Carlstrom | cbfe6fe | 2012-02-17 11:13:36 -0800 | [diff] [blame] | 625 | Usage("could not parse -j argument '%s' as an integer", thread_count_str); |
Elliott Hughes | 5523ee0 | 2012-02-03 18:18:34 -0800 | [diff] [blame] | 626 | } |
Brian Carlstrom | a004aa9 | 2012-02-08 18:05:09 -0800 | [diff] [blame] | 627 | } else if (option.starts_with("--oat-location=")) { |
| 628 | oat_location = option.substr(strlen("--oat-location=")).data(); |
Logan Chien | 8b977d3 | 2012-02-21 19:14:55 +0800 | [diff] [blame] | 629 | } else if (option.starts_with("--bitcode=")) { |
| 630 | bitcode_filename = option.substr(strlen("--bitcode=")).data(); |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 631 | } else if (option.starts_with("--image=")) { |
| 632 | image_filename = option.substr(strlen("--image=")).data(); |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 633 | } else if (option.starts_with("--image-classes=")) { |
| 634 | image_classes_filename = option.substr(strlen("--image-classes=")).data(); |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 635 | } else if (option.starts_with("--base=")) { |
| 636 | const char* image_base_str = option.substr(strlen("--base=")).data(); |
| 637 | char* end; |
| 638 | image_base = strtoul(image_base_str, &end, 16); |
| 639 | if (end == image_base_str || *end != '\0') { |
Brian Carlstrom | cbfe6fe | 2012-02-17 11:13:36 -0800 | [diff] [blame] | 640 | Usage("Failed to parse hexadecimal value for option %s", option.data()); |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 641 | } |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 642 | } else if (option.starts_with("--boot-image=")) { |
Brian Carlstrom | b001126 | 2011-12-09 12:17:24 -0800 | [diff] [blame] | 643 | boot_image_filename = option.substr(strlen("--boot-image=")).data(); |
Brian Carlstrom | 58ae941 | 2011-10-04 00:56:06 -0700 | [diff] [blame] | 644 | } else if (option.starts_with("--host-prefix=")) { |
Brian Carlstrom | 34f1fa4 | 2012-04-05 18:28:12 -0700 | [diff] [blame] | 645 | host_prefix.reset(new std::string(option.substr(strlen("--host-prefix=")).data())); |
Brian Carlstrom | 3f47c12 | 2013-03-07 00:02:40 -0800 | [diff] [blame] | 646 | } else if (option.starts_with("--android-root=")) { |
| 647 | android_root = option.substr(strlen("--android-root=")).data(); |
Ian Rogers | 49c4894 | 2012-03-11 15:15:37 -0700 | [diff] [blame] | 648 | } else if (option.starts_with("--instruction-set=")) { |
| 649 | StringPiece instruction_set_str = option.substr(strlen("--instruction-set=")).data(); |
jeffhao | 1f71ae8 | 2012-05-24 16:08:24 -0700 | [diff] [blame] | 650 | if (instruction_set_str == "arm") { |
Ian Rogers | 49c4894 | 2012-03-11 15:15:37 -0700 | [diff] [blame] | 651 | instruction_set = kThumb2; |
jeffhao | 1f71ae8 | 2012-05-24 16:08:24 -0700 | [diff] [blame] | 652 | } else if (instruction_set_str == "mips") { |
Ian Rogers | 49c4894 | 2012-03-11 15:15:37 -0700 | [diff] [blame] | 653 | instruction_set = kMips; |
jeffhao | 1f71ae8 | 2012-05-24 16:08:24 -0700 | [diff] [blame] | 654 | } else if (instruction_set_str == "x86") { |
Ian Rogers | 49c4894 | 2012-03-11 15:15:37 -0700 | [diff] [blame] | 655 | instruction_set = kX86; |
| 656 | } |
buzbee | c531cef | 2012-10-18 07:09:20 -0700 | [diff] [blame] | 657 | } else if (option.starts_with("--compiler-backend=")) { |
| 658 | StringPiece backend_str = option.substr(strlen("--compiler-backend=")).data(); |
| 659 | if (backend_str == "Quick") { |
| 660 | compiler_backend = kQuick; |
buzbee | c531cef | 2012-10-18 07:09:20 -0700 | [diff] [blame] | 661 | } else if (backend_str == "Portable") { |
| 662 | compiler_backend = kPortable; |
| 663 | } |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 664 | } else if (option == "--host") { |
| 665 | is_host = true; |
jeffhao | 5d84040 | 2011-10-24 17:09:45 -0700 | [diff] [blame] | 666 | } else if (option == "--runtime-arg") { |
| 667 | if (++i >= argc) { |
Brian Carlstrom | cbfe6fe | 2012-02-17 11:13:36 -0800 | [diff] [blame] | 668 | Usage("Missing required argument for --runtime-arg"); |
jeffhao | 5d84040 | 2011-10-24 17:09:45 -0700 | [diff] [blame] | 669 | } |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 670 | if (log_options) { |
| 671 | LOG(INFO) << "dex2oat: option[" << i << "]=" << argv[i]; |
| 672 | } |
jeffhao | 5d84040 | 2011-10-24 17:09:45 -0700 | [diff] [blame] | 673 | runtime_args.push_back(argv[i]); |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 674 | } else { |
Brian Carlstrom | cbfe6fe | 2012-02-17 11:13:36 -0800 | [diff] [blame] | 675 | Usage("unknown argument %s", option.data()); |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 676 | } |
| 677 | } |
| 678 | |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 679 | if (oat_filename.empty() && oat_fd == -1) { |
Brian Carlstrom | cbfe6fe | 2012-02-17 11:13:36 -0800 | [diff] [blame] | 680 | Usage("Output must be supplied with either --oat-file or --oat-fd"); |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 681 | } |
| 682 | |
| 683 | if (!oat_filename.empty() && oat_fd != -1) { |
Brian Carlstrom | cbfe6fe | 2012-02-17 11:13:36 -0800 | [diff] [blame] | 684 | Usage("--oat-file should not be used with --oat-fd"); |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 685 | } |
| 686 | |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 687 | if (!oat_symbols.empty() && oat_fd != -1) { |
| 688 | Usage("--oat-symbols should not be used with --oat-fd"); |
| 689 | } |
| 690 | |
| 691 | if (!oat_symbols.empty() && is_host) { |
| 692 | Usage("--oat-symbols should not be used with --host"); |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 693 | } |
| 694 | |
Brian Carlstrom | a004aa9 | 2012-02-08 18:05:09 -0800 | [diff] [blame] | 695 | if (oat_fd != -1 && !image_filename.empty()) { |
Brian Carlstrom | cbfe6fe | 2012-02-17 11:13:36 -0800 | [diff] [blame] | 696 | Usage("--oat-fd should not be used with --image"); |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 697 | } |
| 698 | |
Brian Carlstrom | 34f1fa4 | 2012-04-05 18:28:12 -0700 | [diff] [blame] | 699 | if (host_prefix.get() == NULL) { |
Brian Carlstrom | b001126 | 2011-12-09 12:17:24 -0800 | [diff] [blame] | 700 | const char* android_product_out = getenv("ANDROID_PRODUCT_OUT"); |
| 701 | if (android_product_out != NULL) { |
Brian Carlstrom | 34f1fa4 | 2012-04-05 18:28:12 -0700 | [diff] [blame] | 702 | host_prefix.reset(new std::string(android_product_out)); |
Brian Carlstrom | b001126 | 2011-12-09 12:17:24 -0800 | [diff] [blame] | 703 | } |
| 704 | } |
| 705 | |
Brian Carlstrom | 3f47c12 | 2013-03-07 00:02:40 -0800 | [diff] [blame] | 706 | if (android_root.empty()) { |
| 707 | const char* android_root_env_var = getenv("ANDROID_ROOT"); |
| 708 | if (android_root_env_var == NULL) { |
Brian Carlstrom | 54d22c2 | 2013-03-13 15:14:57 -0700 | [diff] [blame] | 709 | Usage("--android-root unspecified and ANDROID_ROOT not set"); |
Brian Carlstrom | 3f47c12 | 2013-03-07 00:02:40 -0800 | [diff] [blame] | 710 | } |
| 711 | android_root += android_root_env_var; |
| 712 | } |
| 713 | |
Brian Carlstrom | a004aa9 | 2012-02-08 18:05:09 -0800 | [diff] [blame] | 714 | bool image = (!image_filename.empty()); |
Brian Carlstrom | b001126 | 2011-12-09 12:17:24 -0800 | [diff] [blame] | 715 | if (!image && boot_image_filename.empty()) { |
Brian Carlstrom | 34f1fa4 | 2012-04-05 18:28:12 -0700 | [diff] [blame] | 716 | if (host_prefix.get() == NULL) { |
Brian Carlstrom | a56fcd6 | 2012-02-04 21:23:01 -0800 | [diff] [blame] | 717 | boot_image_filename += GetAndroidRoot(); |
| 718 | } else { |
Brian Carlstrom | 34f1fa4 | 2012-04-05 18:28:12 -0700 | [diff] [blame] | 719 | boot_image_filename += *host_prefix.get(); |
Brian Carlstrom | a56fcd6 | 2012-02-04 21:23:01 -0800 | [diff] [blame] | 720 | boot_image_filename += "/system"; |
| 721 | } |
| 722 | boot_image_filename += "/framework/boot.art"; |
Brian Carlstrom | b001126 | 2011-12-09 12:17:24 -0800 | [diff] [blame] | 723 | } |
| 724 | std::string boot_image_option; |
Brian Carlstrom | a004aa9 | 2012-02-08 18:05:09 -0800 | [diff] [blame] | 725 | if (!boot_image_filename.empty()) { |
Brian Carlstrom | b001126 | 2011-12-09 12:17:24 -0800 | [diff] [blame] | 726 | boot_image_option += "-Ximage:"; |
| 727 | boot_image_option += boot_image_filename; |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 728 | } |
| 729 | |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 730 | if (image_classes_filename != NULL && !image) { |
Brian Carlstrom | cbfe6fe | 2012-02-17 11:13:36 -0800 | [diff] [blame] | 731 | Usage("--image-classes should only be used with --image"); |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 732 | } |
| 733 | |
| 734 | if (image_classes_filename != NULL && !boot_image_option.empty()) { |
Brian Carlstrom | cbfe6fe | 2012-02-17 11:13:36 -0800 | [diff] [blame] | 735 | Usage("--image-classes should not be used with --boot-image"); |
Brian Carlstrom | 78128a6 | 2011-09-15 17:21:19 -0700 | [diff] [blame] | 736 | } |
| 737 | |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 738 | if (dex_filenames.empty() && zip_fd == -1) { |
Brian Carlstrom | cbfe6fe | 2012-02-17 11:13:36 -0800 | [diff] [blame] | 739 | Usage("Input must be supplied with either --dex-file or --zip-fd"); |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 740 | } |
| 741 | |
| 742 | if (!dex_filenames.empty() && zip_fd != -1) { |
Brian Carlstrom | cbfe6fe | 2012-02-17 11:13:36 -0800 | [diff] [blame] | 743 | Usage("--dex-file should not be used with --zip-fd"); |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 744 | } |
| 745 | |
Brian Carlstrom | a004aa9 | 2012-02-08 18:05:09 -0800 | [diff] [blame] | 746 | if (!dex_filenames.empty() && !zip_location.empty()) { |
Brian Carlstrom | cbfe6fe | 2012-02-17 11:13:36 -0800 | [diff] [blame] | 747 | Usage("--dex-file should not be used with --zip-location"); |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 748 | } |
| 749 | |
Brian Carlstrom | a004aa9 | 2012-02-08 18:05:09 -0800 | [diff] [blame] | 750 | if (dex_locations.empty()) { |
| 751 | for (size_t i = 0; i < dex_filenames.size(); i++) { |
| 752 | dex_locations.push_back(dex_filenames[i]); |
| 753 | } |
| 754 | } else if (dex_locations.size() != dex_filenames.size()) { |
Brian Carlstrom | cbfe6fe | 2012-02-17 11:13:36 -0800 | [diff] [blame] | 755 | Usage("--dex-location arguments do not match --dex-file arguments"); |
Brian Carlstrom | a004aa9 | 2012-02-08 18:05:09 -0800 | [diff] [blame] | 756 | } |
| 757 | |
| 758 | if (zip_fd != -1 && zip_location.empty()) { |
Brian Carlstrom | cbfe6fe | 2012-02-17 11:13:36 -0800 | [diff] [blame] | 759 | Usage("--zip-location should be supplied with --zip-fd"); |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 760 | } |
| 761 | |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 762 | if (boot_image_option.empty()) { |
| 763 | if (image_base == 0) { |
Brian Carlstrom | cbfe6fe | 2012-02-17 11:13:36 -0800 | [diff] [blame] | 764 | Usage("non-zero --base not specified"); |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 765 | } |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 766 | } |
| 767 | |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 768 | std::string oat_stripped(oat_filename); |
| 769 | std::string oat_unstripped; |
| 770 | if (!oat_symbols.empty()) { |
| 771 | oat_unstripped += oat_symbols; |
| 772 | } else { |
| 773 | oat_unstripped += oat_filename; |
| 774 | } |
| 775 | |
Brian Carlstrom | 994d62a | 2012-11-05 20:43:45 -0800 | [diff] [blame] | 776 | // Done with usage checks, enable watchdog if requested |
| 777 | WatchDog watch_dog(watch_dog_enabled); |
| 778 | |
Brian Carlstrom | 6ef827a | 2011-12-11 14:57:47 -0800 | [diff] [blame] | 779 | // Check early that the result of compilation can be written |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 780 | UniquePtr<File> oat_file; |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 781 | bool create_file = !oat_unstripped.empty(); // as opposed to using open file descriptor |
Brian Carlstrom | 6cd40e5 | 2012-05-03 14:15:11 -0700 | [diff] [blame] | 782 | if (create_file) { |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 783 | oat_file.reset(OS::OpenFile(oat_unstripped.c_str(), true)); |
Brian Carlstrom | a004aa9 | 2012-02-08 18:05:09 -0800 | [diff] [blame] | 784 | if (oat_location.empty()) { |
| 785 | oat_location = oat_filename; |
| 786 | } |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 787 | } else { |
Elliott Hughes | 7616005 | 2012-12-12 16:31:20 -0800 | [diff] [blame] | 788 | oat_file.reset(new File(oat_fd, oat_location)); |
| 789 | oat_file->DisableAutoClose(); |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 790 | } |
Brian Carlstrom | 6ef827a | 2011-12-11 14:57:47 -0800 | [diff] [blame] | 791 | if (oat_file.get() == NULL) { |
Brian Carlstrom | 6cd40e5 | 2012-05-03 14:15:11 -0700 | [diff] [blame] | 792 | PLOG(ERROR) << "Failed to create oat file: " << oat_location; |
| 793 | return EXIT_FAILURE; |
| 794 | } |
| 795 | if (create_file && fchmod(oat_file->Fd(), 0644) != 0) { |
| 796 | PLOG(ERROR) << "Failed to make oat file world readable: " << oat_location; |
Brian Carlstrom | 6ef827a | 2011-12-11 14:57:47 -0800 | [diff] [blame] | 797 | return EXIT_FAILURE; |
Ian Rogers | 5e863dd | 2011-11-02 20:00:10 -0700 | [diff] [blame] | 798 | } |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 799 | |
Brian Carlstrom | a004aa9 | 2012-02-08 18:05:09 -0800 | [diff] [blame] | 800 | LOG(INFO) << "dex2oat: " << oat_location; |
Ian Rogers | 5e863dd | 2011-11-02 20:00:10 -0700 | [diff] [blame] | 801 | |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 802 | Runtime::Options options; |
Brian Carlstrom | 5de8fe5 | 2011-10-16 14:10:09 -0700 | [diff] [blame] | 803 | options.push_back(std::make_pair("compiler", reinterpret_cast<void*>(NULL))); |
Brian Carlstrom | a004aa9 | 2012-02-08 18:05:09 -0800 | [diff] [blame] | 804 | std::vector<const DexFile*> boot_class_path; |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 805 | if (boot_image_option.empty()) { |
Elliott Hughes | bf1b457 | 2012-05-24 19:11:39 -0700 | [diff] [blame] | 806 | size_t failure_count = OpenDexFiles(dex_filenames, dex_locations, boot_class_path); |
| 807 | if (failure_count > 0) { |
| 808 | LOG(ERROR) << "Failed to open some dex files: " << failure_count; |
| 809 | return EXIT_FAILURE; |
| 810 | } |
Brian Carlstrom | a004aa9 | 2012-02-08 18:05:09 -0800 | [diff] [blame] | 811 | options.push_back(std::make_pair("bootclasspath", &boot_class_path)); |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 812 | } else { |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 813 | options.push_back(std::make_pair(boot_image_option.c_str(), reinterpret_cast<void*>(NULL))); |
| 814 | } |
Brian Carlstrom | 34f1fa4 | 2012-04-05 18:28:12 -0700 | [diff] [blame] | 815 | if (host_prefix.get() != NULL) { |
| 816 | options.push_back(std::make_pair("host-prefix", host_prefix->c_str())); |
Brian Carlstrom | 58ae941 | 2011-10-04 00:56:06 -0700 | [diff] [blame] | 817 | } |
jeffhao | 5d84040 | 2011-10-24 17:09:45 -0700 | [diff] [blame] | 818 | for (size_t i = 0; i < runtime_args.size(); i++) { |
| 819 | options.push_back(std::make_pair(runtime_args[i], reinterpret_cast<void*>(NULL))); |
| 820 | } |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 821 | |
Anwar Ghuloum | 8447d84 | 2013-04-30 17:27:40 -0700 | [diff] [blame] | 822 | #if ART_SMALL_MODE |
| 823 | options.push_back(std::make_pair("-small", reinterpret_cast<void*>(NULL))); |
| 824 | #endif // ART_SMALL_MODE |
| 825 | |
Dragos Sbirlea | 7467ee0 | 2013-06-21 09:20:34 -0700 | [diff] [blame^] | 826 | |
| 827 | #ifdef ART_SEA_IR_MODE |
| 828 | options.push_back(std::make_pair("-sea_ir", reinterpret_cast<void*>(NULL))); |
| 829 | #endif |
| 830 | |
| 831 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 832 | Dex2Oat* p_dex2oat; |
Brian Carlstrom | 9639160 | 2013-06-13 19:49:50 -0700 | [diff] [blame] | 833 | if (!Dex2Oat::Create(&p_dex2oat, options, compiler_backend, instruction_set, thread_count, |
Anwar Ghuloum | 8447d84 | 2013-04-30 17:27:40 -0700 | [diff] [blame] | 834 | support_debugging)) { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 835 | LOG(ERROR) << "Failed to create dex2oat"; |
| 836 | return EXIT_FAILURE; |
| 837 | } |
| 838 | UniquePtr<Dex2Oat> dex2oat(p_dex2oat); |
| 839 | // Runtime::Create acquired the mutator_lock_ that is normally given away when we Runtime::Start, |
| 840 | // give it away now and then switch to a more managable ScopedObjectAccess. |
| 841 | Thread::Current()->TransitionFromRunnableToSuspended(kNative); |
| 842 | // Whilst we're in native take the opportunity to initialize well known classes. |
| 843 | WellKnownClasses::InitClasses(Thread::Current()->GetJniEnv()); |
| 844 | ScopedObjectAccess soa(Thread::Current()); |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 845 | |
Elliott Hughes | bb551fa | 2012-01-25 16:35:29 -0800 | [diff] [blame] | 846 | // If --image-classes was specified, calculate the full list of classes to include in the image |
Brian Carlstrom | 9639160 | 2013-06-13 19:49:50 -0700 | [diff] [blame] | 847 | UniquePtr<CompilerDriver::DescriptorSet> image_classes(NULL); |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 848 | if (image_classes_filename != NULL) { |
Brian Carlstrom | 9639160 | 2013-06-13 19:49:50 -0700 | [diff] [blame] | 849 | image_classes.reset(dex2oat->ReadImageClasses(image_classes_filename)); |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 850 | if (image_classes.get() == NULL) { |
| 851 | LOG(ERROR) << "Failed to create list of image classes from " << image_classes_filename; |
| 852 | return EXIT_FAILURE; |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 853 | } |
| 854 | } |
| 855 | |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 856 | std::vector<const DexFile*> dex_files; |
| 857 | if (boot_image_option.empty()) { |
| 858 | dex_files = Runtime::Current()->GetClassLinker()->GetBootClassPath(); |
| 859 | } else { |
| 860 | if (dex_filenames.empty()) { |
| 861 | UniquePtr<ZipArchive> zip_archive(ZipArchive::OpenFromFd(zip_fd)); |
| 862 | if (zip_archive.get() == NULL) { |
Brian Carlstrom | a004aa9 | 2012-02-08 18:05:09 -0800 | [diff] [blame] | 863 | LOG(ERROR) << "Failed to zip from file descriptor for " << zip_location; |
Brian Carlstrom | 2e3d1b2 | 2012-01-09 18:01:56 -0800 | [diff] [blame] | 864 | return EXIT_FAILURE; |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 865 | } |
Brian Carlstrom | a004aa9 | 2012-02-08 18:05:09 -0800 | [diff] [blame] | 866 | const DexFile* dex_file = DexFile::Open(*zip_archive.get(), zip_location); |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 867 | if (dex_file == NULL) { |
Brian Carlstrom | a004aa9 | 2012-02-08 18:05:09 -0800 | [diff] [blame] | 868 | LOG(ERROR) << "Failed to open dex from file descriptor for zip file: " << zip_location; |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 869 | return EXIT_FAILURE; |
| 870 | } |
| 871 | dex_files.push_back(dex_file); |
| 872 | } else { |
Elliott Hughes | bf1b457 | 2012-05-24 19:11:39 -0700 | [diff] [blame] | 873 | size_t failure_count = OpenDexFiles(dex_filenames, dex_locations, dex_files); |
| 874 | if (failure_count > 0) { |
| 875 | LOG(ERROR) << "Failed to open some dex files: " << failure_count; |
| 876 | return EXIT_FAILURE; |
| 877 | } |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 878 | } |
| 879 | } |
| 880 | |
Anwar Ghuloum | 8447d84 | 2013-04-30 17:27:40 -0700 | [diff] [blame] | 881 | // If we're in small mode, but the program is small, turn off small mode. |
| 882 | // It doesn't make a difference for the boot image, so let's skip the check |
| 883 | // altogether. |
| 884 | if (Runtime::Current()->IsSmallMode() && !image) { |
| 885 | size_t num_methods = 0; |
| 886 | for (size_t i = 0; i != dex_files.size(); ++i) { |
| 887 | const DexFile* dex_file = dex_files[i]; |
| 888 | CHECK(dex_file != NULL); |
| 889 | num_methods += dex_file->NumMethodIds(); |
| 890 | } |
| 891 | if (num_methods <= Runtime::Current()->GetSmallModeMethodThreshold()) { |
| 892 | Runtime::Current()->SetSmallMode(false); |
| 893 | LOG(INFO) << "Below method threshold, compiling anyways"; |
| 894 | } |
| 895 | } |
Anwar Ghuloum | c4f105d | 2013-04-10 16:12:11 -0700 | [diff] [blame] | 896 | |
Ian Rogers | 1212a02 | 2013-03-04 10:48:41 -0800 | [diff] [blame] | 897 | UniquePtr<const CompilerDriver> compiler(dex2oat->CreateOatFile(boot_image_option, |
| 898 | host_prefix.get(), |
Brian Carlstrom | 3f47c12 | 2013-03-07 00:02:40 -0800 | [diff] [blame] | 899 | android_root, |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 900 | is_host, |
Ian Rogers | 1212a02 | 2013-03-04 10:48:41 -0800 | [diff] [blame] | 901 | dex_files, |
| 902 | oat_file.get(), |
| 903 | bitcode_filename, |
| 904 | image, |
Brian Carlstrom | 9639160 | 2013-06-13 19:49:50 -0700 | [diff] [blame] | 905 | image_classes, |
Ian Rogers | 1212a02 | 2013-03-04 10:48:41 -0800 | [diff] [blame] | 906 | dump_stats, |
| 907 | dump_timings)); |
Brian Carlstrom | f582258 | 2012-03-19 22:34:31 -0700 | [diff] [blame] | 908 | |
| 909 | if (compiler.get() == NULL) { |
Brian Carlstrom | a004aa9 | 2012-02-08 18:05:09 -0800 | [diff] [blame] | 910 | LOG(ERROR) << "Failed to create oat file: " << oat_location; |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 911 | return EXIT_FAILURE; |
| 912 | } |
| 913 | |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 914 | LOG(INFO) << "Oat file written successfully (unstripped): " << oat_location; |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 915 | |
Brian Carlstrom | 700c8d3 | 2012-11-05 10:42:02 -0800 | [diff] [blame] | 916 | // Notes on the interleaving of creating the image and oat file to |
| 917 | // ensure the references between the two are correct. |
| 918 | // |
| 919 | // Currently we have a memory layout that looks something like this: |
| 920 | // |
| 921 | // +--------------+ |
| 922 | // | image | |
| 923 | // +--------------+ |
| 924 | // | boot oat | |
| 925 | // +--------------+ |
| 926 | // | alloc spaces | |
| 927 | // +--------------+ |
| 928 | // |
| 929 | // There are several constraints on the loading of the imag and boot.oat. |
| 930 | // |
| 931 | // 1. The image is expected to be loaded at an absolute address and |
| 932 | // contains Objects with absolute pointers within the image. |
| 933 | // |
| 934 | // 2. There are absolute pointers from Methods in the image to their |
| 935 | // code in the oat. |
| 936 | // |
| 937 | // 3. There are absolute pointers from the code in the oat to Methods |
| 938 | // in the image. |
| 939 | // |
| 940 | // 4. There are absolute pointers from code in the oat to other code |
| 941 | // in the oat. |
| 942 | // |
| 943 | // To get this all correct, we go through several steps. |
| 944 | // |
| 945 | // 1. We have already created that oat file above with |
| 946 | // CreateOatFile. Originally this was just our own proprietary file |
| 947 | // but now it is contained within an ELF dynamic object (aka .so |
| 948 | // file). The Compiler returned by CreateOatFile provides |
| 949 | // PatchInformation for references to oat code and Methods that need |
| 950 | // to be update once we know where the oat file will be located |
| 951 | // after the image. |
| 952 | // |
| 953 | // 2. We create the image file. It needs to know where the oat file |
| 954 | // will be loaded after itself. Originally when oat file was simply |
| 955 | // memory mapped so we could predict where its contents were based |
| 956 | // on the file size. Now that it is an ELF file, we need to inspect |
| 957 | // the ELF file to understand the in memory segment layout including |
| 958 | // where the oat header is located within. ImageWriter's |
| 959 | // PatchOatCodeAndMethods uses the PatchInformation from the |
| 960 | // Compiler to touch up absolute references in the oat file. |
| 961 | // |
| 962 | // 3. We fixup the ELF program headers so that dlopen will try to |
| 963 | // load the .so at the desired location at runtime by offsetting the |
| 964 | // Elf32_Phdr.p_vaddr values by the desired base address. |
| 965 | // |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 966 | if (image) { |
| 967 | Thread::Current()->TransitionFromRunnableToSuspended(kNative); |
| 968 | bool image_creation_success = dex2oat->CreateImageFile(image_filename, |
| 969 | image_base, |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 970 | oat_unstripped, |
| 971 | oat_location, |
| 972 | *compiler.get()); |
| 973 | Thread::Current()->TransitionFromSuspendedToRunnable(); |
| 974 | LOG(INFO) << "Image written successfully: " << image_filename; |
| 975 | if (!image_creation_success) { |
| 976 | return EXIT_FAILURE; |
| 977 | } |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 978 | } |
| 979 | |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 980 | if (is_host) { |
| 981 | return EXIT_SUCCESS; |
| 982 | } |
| 983 | |
| 984 | // If we don't want to strip in place, copy from unstripped location to stripped location. |
| 985 | // We need to strip after image creation because FixupElf needs to use .strtab. |
| 986 | if (oat_unstripped != oat_stripped) { |
| 987 | oat_file.reset(); |
| 988 | UniquePtr<File> in(OS::OpenFile(oat_unstripped.c_str(), false)); |
| 989 | UniquePtr<File> out(OS::OpenFile(oat_stripped.c_str(), true)); |
| 990 | size_t buffer_size = 8192; |
| 991 | UniquePtr<uint8_t> buffer(new uint8_t[buffer_size]); |
| 992 | while (true) { |
| 993 | int bytes_read = TEMP_FAILURE_RETRY(read(in->Fd(), buffer.get(), buffer_size)); |
| 994 | if (bytes_read <= 0) { |
| 995 | break; |
| 996 | } |
| 997 | bool write_ok = out->WriteFully(buffer.get(), bytes_read); |
| 998 | CHECK(write_ok); |
| 999 | } |
| 1000 | oat_file.reset(out.release()); |
| 1001 | LOG(INFO) << "Oat file copied successfully (stripped): " << oat_stripped; |
| 1002 | } |
| 1003 | |
| 1004 | // Strip unneeded sections for target |
| 1005 | off_t seek_actual = lseek(oat_file->Fd(), 0, SEEK_SET); |
| 1006 | CHECK_EQ(0, seek_actual); |
| 1007 | compiler->StripElf(oat_file.get()); |
| 1008 | |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 1009 | // We wrote the oat file successfully, and want to keep it. |
Brian Carlstrom | 54d22c2 | 2013-03-13 15:14:57 -0700 | [diff] [blame] | 1010 | LOG(INFO) << "Oat file written successfully (stripped): " << oat_location; |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 1011 | return EXIT_SUCCESS; |
| 1012 | } |
| 1013 | |
| 1014 | } // namespace art |
| 1015 | |
| 1016 | int main(int argc, char** argv) { |
| 1017 | return art::dex2oat(argc, argv); |
| 1018 | } |