Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 1 | // Copyright 2011 Google Inc. All Rights Reserved. |
| 2 | |
| 3 | #include <stdio.h> |
| 4 | #include <stdlib.h> |
| 5 | |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 6 | #include <iostream> |
| 7 | #include <fstream> |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 8 | #include <string> |
| 9 | #include <vector> |
| 10 | |
| 11 | #include "class_linker.h" |
| 12 | #include "class_loader.h" |
| 13 | #include "compiler.h" |
Ian Rogers | 5e863dd | 2011-11-02 20:00:10 -0700 | [diff] [blame] | 14 | #include "file.h" |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 15 | #include "image_writer.h" |
Ian Rogers | 6f1dfe4 | 2011-12-08 17:28:34 -0800 | [diff] [blame] | 16 | #include "leb128.h" |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 17 | #include "oat_writer.h" |
Ian Rogers | 6d4d9fc | 2011-11-30 16:24:48 -0800 | [diff] [blame] | 18 | #include "object_utils.h" |
Ian Rogers | 5e863dd | 2011-11-02 20:00:10 -0700 | [diff] [blame] | 19 | #include "os.h" |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 20 | #include "runtime.h" |
| 21 | #include "stringpiece.h" |
Elliott Hughes | bb551fa | 2012-01-25 16:35:29 -0800 | [diff] [blame] | 22 | #include "timing_logger.h" |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 23 | #include "zip_archive.h" |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 24 | |
| 25 | namespace art { |
| 26 | |
| 27 | static void usage() { |
| 28 | fprintf(stderr, |
| 29 | "Usage: dex2oat [options]...\n" |
| 30 | "\n"); |
| 31 | fprintf(stderr, |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 32 | " --dex-file=<dex-file>: specifies a .dex file to compile.\n" |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 33 | " Example: --dex-file=/system/framework/core.jar\n" |
| 34 | "\n"); |
| 35 | fprintf(stderr, |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 36 | " --zip-fd=<file-descriptor>: specifies a file descriptor of a zip file\n" |
| 37 | " containing a classes.dex file to compile.\n" |
| 38 | " Example: --zip-fd=5\n" |
| 39 | "\n"); |
| 40 | fprintf(stderr, |
| 41 | " --zip-name=<zip-name>: specifies a symbolic name for the file corresponding\n" |
| 42 | " to the file descriptor specified by --zip-fd.\n" |
| 43 | " Example: --zip-name=/system/app/Calculator.apk\n" |
| 44 | "\n"); |
| 45 | fprintf(stderr, |
| 46 | " --oat-file=<file.oat>: specifies the required oat filename.\n" |
| 47 | " Example: --oat-file=/system/framework/boot.oat\n" |
| 48 | "\n"); |
| 49 | fprintf(stderr, |
| 50 | " --oat-name=<oat-name>: specifies a symbolic name for the file corresponding\n" |
| 51 | " to the file descriptor specified by --oat-fd.\n" |
| 52 | " Example: --oat-name=/data/art-cache/system@app@Calculator.apk.oat\n" |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 53 | "\n"); |
| 54 | fprintf(stderr, |
| 55 | " --image=<file.art>: specifies the output image filename.\n" |
Brian Carlstrom | 29e7ac7 | 2011-12-05 23:42:57 -0800 | [diff] [blame] | 56 | " Example: --image=/system/framework/boot.art\n" |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 57 | "\n"); |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 58 | fprintf(stderr, |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 59 | " --image-classes=<classname-file>: specifies classes to include in an image.\n" |
| 60 | " Example: --image=frameworks/base/preloaded-classes\n" |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 61 | "\n"); |
| 62 | fprintf(stderr, |
| 63 | " --base=<hex-address>: specifies the base address when creating a boot image.\n" |
| 64 | " Example: --base=0x50000000\n" |
| 65 | "\n"); |
| 66 | fprintf(stderr, |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 67 | " --boot-image=<file.art>: provide the image file for the boot class path.\n" |
Brian Carlstrom | 29e7ac7 | 2011-12-05 23:42:57 -0800 | [diff] [blame] | 68 | " Example: --boot-image=/system/framework/boot.art\n" |
| 69 | " Default: <host-prefix>/system/framework/boot.art\n" |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 70 | "\n"); |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 71 | fprintf(stderr, |
Brian Carlstrom | 58ae941 | 2011-10-04 00:56:06 -0700 | [diff] [blame] | 72 | " --host-prefix may be used to translate host paths to target paths during\n" |
| 73 | " cross compilation.\n" |
| 74 | " Example: --host-prefix=out/target/product/crespo\n" |
Brian Carlstrom | b001126 | 2011-12-09 12:17:24 -0800 | [diff] [blame] | 75 | " Default: $ANDROID_PRODUCT_OUT\n" |
Brian Carlstrom | 1619286 | 2011-09-12 17:50:06 -0700 | [diff] [blame] | 76 | "\n"); |
Brian Carlstrom | 27ec961 | 2011-09-19 20:20:38 -0700 | [diff] [blame] | 77 | fprintf(stderr, |
jeffhao | 5d84040 | 2011-10-24 17:09:45 -0700 | [diff] [blame] | 78 | " --runtime-arg <argument>: used to specify various arguments for the runtime,\n" |
| 79 | " such as initial heap size, maximum heap size, and verbose output.\n" |
| 80 | " Use a separate --runtime-arg switch for each argument.\n" |
| 81 | " Example: --runtime-arg -Xms256m\n" |
Brian Carlstrom | 27ec961 | 2011-09-19 20:20:38 -0700 | [diff] [blame] | 82 | "\n"); |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 83 | exit(EXIT_FAILURE); |
| 84 | } |
| 85 | |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 86 | class Dex2Oat { |
| 87 | public: |
| 88 | |
| 89 | static Dex2Oat* Create(Runtime::Options& options) { |
| 90 | UniquePtr<Runtime> runtime(CreateRuntime(options)); |
| 91 | if (runtime.get() == NULL) { |
| 92 | return NULL; |
| 93 | } |
| 94 | return new Dex2Oat(runtime.release()); |
| 95 | } |
| 96 | |
| 97 | ~Dex2Oat() { |
| 98 | delete runtime_; |
Ian Rogers | 3bb17a6 | 2012-01-27 23:56:44 -0800 | [diff] [blame] | 99 | LOG(INFO) << "dex2oat took " << PrettyDuration(NanoTime() - start_ns_); |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | // Make a list of descriptors for classes to include in the image |
| 103 | const std::set<std::string>* GetImageClassDescriptors(const char* image_classes_filename) { |
| 104 | UniquePtr<std::ifstream> image_classes_file(new std::ifstream(image_classes_filename, std::ifstream::in)); |
| 105 | if (image_classes_file.get() == NULL) { |
| 106 | LOG(ERROR) << "Failed to open image classes file " << image_classes_filename; |
| 107 | return NULL; |
| 108 | } |
| 109 | |
Ian Rogers | 6f1dfe4 | 2011-12-08 17:28:34 -0800 | [diff] [blame] | 110 | // Load all the classes specified in the file |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 111 | ClassLinker* class_linker = runtime_->GetClassLinker(); |
| 112 | while (image_classes_file->good()) { |
| 113 | std::string dot; |
| 114 | std::getline(*image_classes_file.get(), dot); |
| 115 | if (StringPiece(dot).starts_with("#") || dot.empty()) { |
| 116 | continue; |
| 117 | } |
Elliott Hughes | 9557241 | 2011-12-13 18:14:20 -0800 | [diff] [blame] | 118 | std::string descriptor(DotToDescriptor(dot.c_str())); |
Elliott Hughes | c3b77c7 | 2011-12-15 20:56:48 -0800 | [diff] [blame] | 119 | SirtRef<Class> klass(class_linker->FindSystemClass(descriptor.c_str())); |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 120 | if (klass.get() == NULL) { |
| 121 | LOG(WARNING) << "Failed to find class " << descriptor; |
| 122 | Thread::Current()->ClearException(); |
| 123 | } |
| 124 | } |
| 125 | image_classes_file->close(); |
| 126 | |
Ian Rogers | 6f1dfe4 | 2011-12-08 17:28:34 -0800 | [diff] [blame] | 127 | // Resolve exception classes referenced by the loaded classes. The catch logic assumes |
| 128 | // exceptions are resolved by the verifier when there is a catch block in an interested method. |
| 129 | // Do this here so that exception classes appear to have been specified image classes. |
| 130 | std::set<std::pair<uint16_t, const DexFile*> > unresolved_exception_types; |
| 131 | do { |
| 132 | unresolved_exception_types.clear(); |
| 133 | class_linker->VisitClasses(ResolveCatchBlockExceptionsClassVisitor, |
| 134 | &unresolved_exception_types); |
| 135 | typedef std::set<std::pair<uint16_t, const DexFile*> >::const_iterator It; // TODO: C++0x auto |
| 136 | for (It it = unresolved_exception_types.begin(), |
| 137 | end = unresolved_exception_types.end(); |
| 138 | it != end; ++it) { |
| 139 | uint16_t exception_type_idx = it->first; |
| 140 | const DexFile* dex_file = it->second; |
| 141 | DexCache* dex_cache = class_linker->FindDexCache(*dex_file); |
| 142 | ClassLoader* class_loader = NULL; |
| 143 | SirtRef<Class> klass(class_linker->ResolveType(*dex_file, exception_type_idx, dex_cache, |
| 144 | class_loader)); |
| 145 | if (klass.get() == NULL) { |
| 146 | const DexFile::TypeId& type_id = dex_file->GetTypeId(exception_type_idx); |
| 147 | const char* descriptor = dex_file->GetTypeDescriptor(type_id); |
| 148 | LOG(FATAL) << "Failed to resolve class " << descriptor; |
| 149 | } |
| 150 | DCHECK(klass->IsThrowableClass()); |
| 151 | } |
| 152 | // Resolving exceptions may load classes that reference more exceptions, iterate until no |
| 153 | // more are found |
| 154 | } while (!unresolved_exception_types.empty()); |
| 155 | |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 156 | // We walk the roots looking for classes so that we'll pick up the |
| 157 | // above classes plus any classes them depend on such super |
| 158 | // classes, interfaces, and the required ClassLinker roots. |
| 159 | UniquePtr<std::set<std::string> > image_classes(new std::set<std::string>()); |
Ian Rogers | 6f1dfe4 | 2011-12-08 17:28:34 -0800 | [diff] [blame] | 160 | class_linker->VisitClasses(RecordImageClassesVisitor, image_classes.get()); |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 161 | CHECK_NE(image_classes->size(), 0U); |
| 162 | return image_classes.release(); |
| 163 | } |
| 164 | |
| 165 | bool CreateOatFile(const std::string& boot_image_option, |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 166 | const std::vector<const DexFile*>& dex_files, |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 167 | File* oat_file, |
| 168 | bool image, |
| 169 | const std::set<std::string>* image_classes) { |
| 170 | // SirtRef and ClassLoader creation needs to come after Runtime::Create |
| 171 | UniquePtr<SirtRef<ClassLoader> > class_loader(new SirtRef<ClassLoader>(NULL)); |
| 172 | if (class_loader.get() == NULL) { |
| 173 | LOG(ERROR) << "Failed to create SirtRef for class loader"; |
| 174 | return false; |
| 175 | } |
| 176 | |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 177 | if (!boot_image_option.empty()) { |
| 178 | ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 179 | std::vector<const DexFile*> class_path_files(dex_files); |
| 180 | OpenClassPathFiles(runtime_->GetClassPath(), class_path_files); |
| 181 | for (size_t i = 0; i < class_path_files.size(); i++) { |
| 182 | class_linker->RegisterDexFile(*class_path_files[i]); |
| 183 | } |
| 184 | class_loader.get()->reset(PathClassLoader::AllocCompileTime(class_path_files)); |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 185 | } |
| 186 | |
| 187 | Compiler compiler(instruction_set_, image, image_classes); |
| 188 | compiler.CompileAll(class_loader->get(), dex_files); |
| 189 | |
jeffhao | 10037c8 | 2012-01-23 15:06:23 -0800 | [diff] [blame] | 190 | if (!OatWriter::Create(oat_file, class_loader->get(), dex_files, compiler)) { |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 191 | LOG(ERROR) << "Failed to create oat file " << oat_file->name(); |
| 192 | return false; |
| 193 | } |
| 194 | return true; |
| 195 | } |
| 196 | |
| 197 | bool CreateImageFile(const char* image_filename, |
| 198 | uintptr_t image_base, |
| 199 | const std::set<std::string>* image_classes, |
| 200 | const std::string& oat_filename, |
| 201 | const std::string& host_prefix) { |
| 202 | // If we have an existing boot image, position new space after its oat file |
| 203 | if (Heap::GetSpaces().size() > 1) { |
Ian Rogers | 30fab40 | 2012-01-23 15:43:46 -0800 | [diff] [blame] | 204 | ImageSpace* last_image_space = NULL; |
| 205 | const std::vector<Space*>& spaces = Heap::GetSpaces(); |
| 206 | for (size_t i=0; i < spaces.size(); i++) { |
| 207 | if (spaces[i]->IsImageSpace()) { |
| 208 | last_image_space = spaces[i]->AsImageSpace(); |
| 209 | } |
| 210 | } |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 211 | CHECK(last_image_space != NULL); |
| 212 | CHECK(last_image_space->IsImageSpace()); |
| 213 | CHECK(!Heap::GetSpaces()[Heap::GetSpaces().size()-1]->IsImageSpace()); |
Ian Rogers | 30fab40 | 2012-01-23 15:43:46 -0800 | [diff] [blame] | 214 | byte* oat_limit_addr = last_image_space->GetImageHeader().GetOatEnd(); |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 215 | image_base = RoundUp(reinterpret_cast<uintptr_t>(oat_limit_addr), kPageSize); |
| 216 | } |
| 217 | |
| 218 | ImageWriter image_writer(image_classes); |
| 219 | if (!image_writer.Write(image_filename, image_base, oat_filename, host_prefix)) { |
| 220 | LOG(ERROR) << "Failed to create image file " << image_filename; |
| 221 | return false; |
| 222 | } |
| 223 | return true; |
| 224 | } |
| 225 | |
| 226 | private: |
| 227 | |
Elliott Hughes | bb551fa | 2012-01-25 16:35:29 -0800 | [diff] [blame] | 228 | explicit Dex2Oat(Runtime* runtime) : runtime_(runtime), start_ns_(NanoTime()) { |
| 229 | } |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 230 | |
| 231 | static Runtime* CreateRuntime(Runtime::Options& options) { |
| 232 | Runtime* runtime = Runtime::Create(options, false); |
| 233 | if (runtime == NULL) { |
| 234 | LOG(ERROR) << "Failed to create runtime"; |
| 235 | return NULL; |
| 236 | } |
| 237 | |
| 238 | // if we loaded an existing image, we will reuse values from the image roots. |
| 239 | if (!runtime->HasJniDlsymLookupStub()) { |
Elliott Hughes | 8add92d | 2012-01-18 18:18:43 -0800 | [diff] [blame] | 240 | runtime->SetJniDlsymLookupStub(Compiler::CreateJniDlsymLookupStub(instruction_set_)); |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 241 | } |
| 242 | if (!runtime->HasAbstractMethodErrorStubArray()) { |
| 243 | runtime->SetAbstractMethodErrorStubArray(Compiler::CreateAbstractMethodErrorStub(instruction_set_)); |
| 244 | } |
| 245 | for (int i = 0; i < Runtime::kLastTrampolineMethodType; i++) { |
| 246 | Runtime::TrampolineType type = Runtime::TrampolineType(i); |
| 247 | if (!runtime->HasResolutionStubArray(type)) { |
| 248 | runtime->SetResolutionStubArray(Compiler::CreateResolutionStub(instruction_set_, type), type); |
| 249 | } |
| 250 | } |
| 251 | for (int i = 0; i < Runtime::kLastCalleeSaveType; i++) { |
| 252 | Runtime::CalleeSaveType type = Runtime::CalleeSaveType(i); |
| 253 | if (!runtime->HasCalleeSaveMethod(type)) { |
| 254 | runtime->SetCalleeSaveMethod(runtime->CreateCalleeSaveMethod(instruction_set_, type), type); |
| 255 | } |
| 256 | } |
| 257 | return runtime; |
| 258 | } |
| 259 | |
Ian Rogers | 6f1dfe4 | 2011-12-08 17:28:34 -0800 | [diff] [blame] | 260 | static void ResolveExceptionsForMethod(MethodHelper* mh, |
| 261 | std::set<std::pair<uint16_t, const DexFile*> >& exceptions_to_resolve) { |
| 262 | const DexFile::CodeItem* code_item = mh->GetCodeItem(); |
| 263 | if (code_item == NULL) { |
| 264 | return; // native or abstract method |
| 265 | } |
| 266 | if (code_item->tries_size_ == 0) { |
| 267 | return; // nothing to process |
| 268 | } |
| 269 | const byte* encoded_catch_handler_list = DexFile::GetCatchHandlerData(*code_item, 0); |
| 270 | size_t num_encoded_catch_handlers = DecodeUnsignedLeb128(&encoded_catch_handler_list); |
| 271 | for (size_t i = 0; i < num_encoded_catch_handlers; i++) { |
| 272 | int32_t encoded_catch_handler_size = DecodeSignedLeb128(&encoded_catch_handler_list); |
| 273 | bool has_catch_all = false; |
| 274 | if (encoded_catch_handler_size <= 0) { |
| 275 | encoded_catch_handler_size = -encoded_catch_handler_size; |
| 276 | has_catch_all = true; |
| 277 | } |
| 278 | for (int32_t j = 0; j < encoded_catch_handler_size; j++) { |
| 279 | uint16_t encoded_catch_handler_handlers_type_idx = |
| 280 | DecodeUnsignedLeb128(&encoded_catch_handler_list); |
| 281 | // Add to set of types to resolve if not already in the dex cache resolved types |
| 282 | if (!mh->IsResolvedTypeIdx(encoded_catch_handler_handlers_type_idx)) { |
| 283 | exceptions_to_resolve.insert( |
| 284 | std::pair<uint16_t, const DexFile*>(encoded_catch_handler_handlers_type_idx, |
| 285 | &mh->GetDexFile())); |
| 286 | } |
| 287 | // ignore address associated with catch handler |
| 288 | DecodeUnsignedLeb128(&encoded_catch_handler_list); |
| 289 | } |
| 290 | if (has_catch_all) { |
| 291 | // ignore catch all address |
| 292 | DecodeUnsignedLeb128(&encoded_catch_handler_list); |
| 293 | } |
| 294 | } |
| 295 | } |
| 296 | static bool ResolveCatchBlockExceptionsClassVisitor(Class* c, void* arg) { |
| 297 | std::set<std::pair<uint16_t, const DexFile*> >* exceptions_to_resolve = |
| 298 | reinterpret_cast<std::set<std::pair<uint16_t, const DexFile*> >*>(arg); |
| 299 | MethodHelper mh; |
| 300 | for (size_t i = 0; i < c->NumVirtualMethods(); ++i) { |
| 301 | Method* m = c->GetVirtualMethod(i); |
| 302 | mh.ChangeMethod(m); |
| 303 | ResolveExceptionsForMethod(&mh, *exceptions_to_resolve); |
| 304 | } |
| 305 | for (size_t i = 0; i < c->NumDirectMethods(); ++i) { |
| 306 | Method* m = c->GetDirectMethod(i); |
| 307 | mh.ChangeMethod(m); |
| 308 | ResolveExceptionsForMethod(&mh, *exceptions_to_resolve); |
| 309 | } |
| 310 | return true; |
| 311 | } |
| 312 | static bool RecordImageClassesVisitor(Class* klass, void* arg) { |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 313 | std::set<std::string>* image_classes = reinterpret_cast<std::set<std::string>*>(arg); |
| 314 | if (klass->IsArrayClass() || klass->IsPrimitive()) { |
Jesse Wilson | 254db0f | 2011-11-16 16:44:11 -0500 | [diff] [blame] | 315 | return true; |
| 316 | } |
Ian Rogers | 6d4d9fc | 2011-11-30 16:24:48 -0800 | [diff] [blame] | 317 | image_classes->insert(ClassHelper(klass).GetDescriptor()); |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 318 | return true; |
Jesse Wilson | 254db0f | 2011-11-16 16:44:11 -0500 | [diff] [blame] | 319 | } |
Jesse Wilson | 254db0f | 2011-11-16 16:44:11 -0500 | [diff] [blame] | 320 | |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 321 | // Appends to dex_files any elements of class_path that it doesn't already |
| 322 | // contain. This will open those dex files as necessary. |
| 323 | static void OpenClassPathFiles(const std::string& class_path, std::vector<const DexFile*>& dex_files) { |
| 324 | std::vector<std::string> parsed; |
| 325 | Split(class_path, ':', parsed); |
| 326 | for (size_t i = 0; i < parsed.size(); ++i) { |
| 327 | if (DexFilesContains(dex_files, parsed[i])) { |
| 328 | continue; |
| 329 | } |
| 330 | const DexFile* dex_file = DexFile::Open(parsed[i], Runtime::Current()->GetHostPrefix()); |
| 331 | if (dex_file == NULL) { |
| 332 | LOG(WARNING) << "Failed to open dex file " << parsed[i]; |
| 333 | } else { |
| 334 | dex_files.push_back(dex_file); |
| 335 | } |
Jesse Wilson | 254db0f | 2011-11-16 16:44:11 -0500 | [diff] [blame] | 336 | } |
| 337 | } |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 338 | |
| 339 | // Returns true if dex_files has a dex with the named location. |
| 340 | static bool DexFilesContains(const std::vector<const DexFile*>& dex_files, const std::string& location) { |
| 341 | for (size_t i = 0; i < dex_files.size(); ++i) { |
| 342 | if (dex_files[i]->GetLocation() == location) { |
| 343 | return true; |
| 344 | } |
| 345 | } |
| 346 | return false; |
| 347 | } |
| 348 | |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 349 | static const InstructionSet instruction_set_ = kThumb2; |
| 350 | |
Elliott Hughes | bb551fa | 2012-01-25 16:35:29 -0800 | [diff] [blame] | 351 | Runtime* runtime_; |
| 352 | uint64_t start_ns_; |
| 353 | |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 354 | DISALLOW_IMPLICIT_CONSTRUCTORS(Dex2Oat); |
| 355 | }; |
Jesse Wilson | 254db0f | 2011-11-16 16:44:11 -0500 | [diff] [blame] | 356 | |
Elliott Hughes | bb551fa | 2012-01-25 16:35:29 -0800 | [diff] [blame] | 357 | bool ParseInt(const char* in, int* out) { |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 358 | char* end; |
| 359 | int result = strtol(in, &end, 10); |
| 360 | if (in == end || *end != '\0') { |
| 361 | return false; |
| 362 | } |
| 363 | *out = result; |
| 364 | return true; |
| 365 | } |
| 366 | |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 367 | int dex2oat(int argc, char** argv) { |
| 368 | // Skip over argv[0]. |
| 369 | argv++; |
| 370 | argc--; |
| 371 | |
| 372 | if (argc == 0) { |
| 373 | fprintf(stderr, "no arguments specified\n"); |
| 374 | usage(); |
| 375 | } |
| 376 | |
| 377 | std::vector<const char*> dex_filenames; |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 378 | int zip_fd = -1; |
| 379 | std::string zip_name; |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 380 | std::string oat_filename; |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 381 | int oat_fd = -1; |
| 382 | std::string oat_name; |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 383 | const char* image_filename = NULL; |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 384 | const char* image_classes_filename = NULL; |
Brian Carlstrom | b001126 | 2011-12-09 12:17:24 -0800 | [diff] [blame] | 385 | std::string boot_image_filename; |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 386 | uintptr_t image_base = 0; |
Brian Carlstrom | 58ae941 | 2011-10-04 00:56:06 -0700 | [diff] [blame] | 387 | std::string host_prefix; |
jeffhao | 5d84040 | 2011-10-24 17:09:45 -0700 | [diff] [blame] | 388 | std::vector<const char*> runtime_args; |
Brian Carlstrom | 1619286 | 2011-09-12 17:50:06 -0700 | [diff] [blame] | 389 | |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 390 | for (int i = 0; i < argc; i++) { |
| 391 | const StringPiece option(argv[i]); |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 392 | bool log_options = false; |
| 393 | if (log_options) { |
Brian Carlstrom | b7bbba4 | 2011-10-13 14:58:47 -0700 | [diff] [blame] | 394 | LOG(INFO) << "dex2oat: option[" << i << "]=" << argv[i]; |
| 395 | } |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 396 | if (option.starts_with("--dex-file=")) { |
| 397 | dex_filenames.push_back(option.substr(strlen("--dex-file=")).data()); |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 398 | } else if (option.starts_with("--zip-fd=")) { |
| 399 | const char* zip_fd_str = option.substr(strlen("--zip-fd=")).data(); |
Elliott Hughes | bb551fa | 2012-01-25 16:35:29 -0800 | [diff] [blame] | 400 | if (!ParseInt(zip_fd_str, &zip_fd)) { |
Brian Carlstrom | 866c862 | 2012-01-06 16:35:13 -0800 | [diff] [blame] | 401 | fprintf(stderr, "could not parse --zip-fd argument '%s' as an integer\n", zip_fd_str); |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 402 | usage(); |
| 403 | } |
| 404 | } else if (option.starts_with("--zip-name=")) { |
| 405 | zip_name = option.substr(strlen("--zip-name=")).data(); |
| 406 | } else if (option.starts_with("--oat-file=")) { |
| 407 | oat_filename = option.substr(strlen("--oat-file=")).data(); |
| 408 | } else if (option.starts_with("--oat-fd=")) { |
| 409 | const char* oat_fd_str = option.substr(strlen("--oat-fd=")).data(); |
Elliott Hughes | bb551fa | 2012-01-25 16:35:29 -0800 | [diff] [blame] | 410 | if (!ParseInt(oat_fd_str, &oat_fd)) { |
Brian Carlstrom | 866c862 | 2012-01-06 16:35:13 -0800 | [diff] [blame] | 411 | fprintf(stderr, "could not parse --oat-fd argument '%s' as an integer\n", oat_fd_str); |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 412 | usage(); |
| 413 | } |
| 414 | } else if (option.starts_with("--oat-name=")) { |
| 415 | oat_name = option.substr(strlen("--oat-name=")).data(); |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 416 | } else if (option.starts_with("--image=")) { |
| 417 | image_filename = option.substr(strlen("--image=")).data(); |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 418 | } else if (option.starts_with("--image-classes=")) { |
| 419 | image_classes_filename = option.substr(strlen("--image-classes=")).data(); |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 420 | } else if (option.starts_with("--base=")) { |
| 421 | const char* image_base_str = option.substr(strlen("--base=")).data(); |
| 422 | char* end; |
| 423 | image_base = strtoul(image_base_str, &end, 16); |
| 424 | if (end == image_base_str || *end != '\0') { |
Brian Carlstrom | 27ec961 | 2011-09-19 20:20:38 -0700 | [diff] [blame] | 425 | fprintf(stderr, "Failed to parse hexadecimal value for option %s\n", option.data()); |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 426 | usage(); |
| 427 | } |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 428 | } else if (option.starts_with("--boot-image=")) { |
Brian Carlstrom | b001126 | 2011-12-09 12:17:24 -0800 | [diff] [blame] | 429 | boot_image_filename = option.substr(strlen("--boot-image=")).data(); |
Brian Carlstrom | 58ae941 | 2011-10-04 00:56:06 -0700 | [diff] [blame] | 430 | } else if (option.starts_with("--host-prefix=")) { |
| 431 | host_prefix = option.substr(strlen("--host-prefix=")).data(); |
jeffhao | 5d84040 | 2011-10-24 17:09:45 -0700 | [diff] [blame] | 432 | } else if (option == "--runtime-arg") { |
| 433 | if (++i >= argc) { |
| 434 | fprintf(stderr, "Missing required argument for --runtime-arg\n"); |
| 435 | usage(); |
| 436 | } |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 437 | if (log_options) { |
| 438 | LOG(INFO) << "dex2oat: option[" << i << "]=" << argv[i]; |
| 439 | } |
jeffhao | 5d84040 | 2011-10-24 17:09:45 -0700 | [diff] [blame] | 440 | runtime_args.push_back(argv[i]); |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 441 | } else { |
| 442 | fprintf(stderr, "unknown argument %s\n", option.data()); |
| 443 | usage(); |
| 444 | } |
| 445 | } |
| 446 | |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 447 | if (oat_filename.empty() && oat_fd == -1) { |
| 448 | fprintf(stderr, "Output must be supplied with either --oat-file or --oat-fd\n"); |
| 449 | return EXIT_FAILURE; |
| 450 | } |
| 451 | |
| 452 | if (!oat_filename.empty() && oat_fd != -1) { |
| 453 | fprintf(stderr, "--oat-file should not be used with --oat-fd\n"); |
| 454 | return EXIT_FAILURE; |
| 455 | } |
| 456 | |
| 457 | if (!oat_filename.empty() && oat_fd != -1) { |
| 458 | fprintf(stderr, "--oat-file should not be used with --oat-fd\n"); |
| 459 | return EXIT_FAILURE; |
| 460 | } |
| 461 | |
| 462 | if (!oat_filename.empty() && !oat_name.empty()) { |
| 463 | fprintf(stderr, "--oat-file should not be used with --oat-name\n"); |
| 464 | return EXIT_FAILURE; |
| 465 | } |
| 466 | |
| 467 | if (oat_fd != -1 && oat_name.empty()) { |
| 468 | fprintf(stderr, "--oat-name should be supplied with --oat-fd\n"); |
| 469 | return EXIT_FAILURE; |
| 470 | } |
| 471 | |
| 472 | if (oat_fd != -1 && image_filename != NULL) { |
| 473 | fprintf(stderr, "--oat-fd should not be used with --image\n"); |
Elliott Hughes | 362f9bc | 2011-10-17 18:56:41 -0700 | [diff] [blame] | 474 | return EXIT_FAILURE; |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 475 | } |
| 476 | |
Brian Carlstrom | b001126 | 2011-12-09 12:17:24 -0800 | [diff] [blame] | 477 | if (host_prefix.empty()) { |
| 478 | const char* android_product_out = getenv("ANDROID_PRODUCT_OUT"); |
| 479 | if (android_product_out != NULL) { |
| 480 | host_prefix = android_product_out; |
| 481 | } |
| 482 | } |
| 483 | |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 484 | bool image = (image_filename != NULL); |
Brian Carlstrom | b001126 | 2011-12-09 12:17:24 -0800 | [diff] [blame] | 485 | if (!image && boot_image_filename.empty()) { |
| 486 | boot_image_filename += host_prefix; |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 487 | boot_image_filename += "/system/framework/boot.art"; |
Brian Carlstrom | b001126 | 2011-12-09 12:17:24 -0800 | [diff] [blame] | 488 | } |
| 489 | std::string boot_image_option; |
| 490 | if (boot_image_filename != NULL) { |
| 491 | boot_image_option += "-Ximage:"; |
| 492 | boot_image_option += boot_image_filename; |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 493 | } |
| 494 | |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 495 | if (image_classes_filename != NULL && !image) { |
| 496 | fprintf(stderr, "--image-classes should only be used with --image\n"); |
| 497 | return EXIT_FAILURE; |
| 498 | } |
| 499 | |
| 500 | if (image_classes_filename != NULL && !boot_image_option.empty()) { |
| 501 | fprintf(stderr, "--image-classes should not be used with --boot-image\n"); |
Elliott Hughes | 362f9bc | 2011-10-17 18:56:41 -0700 | [diff] [blame] | 502 | return EXIT_FAILURE; |
Brian Carlstrom | 78128a6 | 2011-09-15 17:21:19 -0700 | [diff] [blame] | 503 | } |
| 504 | |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 505 | if (dex_filenames.empty() && zip_fd == -1) { |
| 506 | fprintf(stderr, "Input must be supplied with either --dex-file or --zip-fd\n"); |
| 507 | return EXIT_FAILURE; |
| 508 | } |
| 509 | |
| 510 | if (!dex_filenames.empty() && zip_fd != -1) { |
| 511 | fprintf(stderr, "--dex-file should not be used with --zip-fd\n"); |
| 512 | return EXIT_FAILURE; |
| 513 | } |
| 514 | |
| 515 | if (!dex_filenames.empty() && !zip_name.empty()) { |
| 516 | fprintf(stderr, "--dex-file should not be used with --zip-name\n"); |
| 517 | return EXIT_FAILURE; |
| 518 | } |
| 519 | |
| 520 | if (zip_fd != -1 && zip_name.empty()) { |
| 521 | fprintf(stderr, "--zip-name should be supplied with --zip-fd\n"); |
| 522 | return EXIT_FAILURE; |
| 523 | } |
| 524 | |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 525 | if (boot_image_option.empty()) { |
| 526 | if (image_base == 0) { |
| 527 | fprintf(stderr, "non-zero --base not specified\n"); |
| 528 | return EXIT_FAILURE; |
| 529 | } |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 530 | } |
| 531 | |
Brian Carlstrom | 6ef827a | 2011-12-11 14:57:47 -0800 | [diff] [blame] | 532 | // Check early that the result of compilation can be written |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 533 | UniquePtr<File> oat_file; |
| 534 | if (!oat_filename.empty()) { |
| 535 | oat_file.reset(OS::OpenFile(oat_filename.c_str(), true)); |
| 536 | oat_name = oat_filename; |
| 537 | } else { |
| 538 | oat_file.reset(OS::FileFromFd(oat_name.c_str(), oat_fd)); |
| 539 | } |
Brian Carlstrom | 6ef827a | 2011-12-11 14:57:47 -0800 | [diff] [blame] | 540 | if (oat_file.get() == NULL) { |
Elliott Hughes | fd8cba4 | 2012-01-11 14:34:28 -0800 | [diff] [blame] | 541 | PLOG(ERROR) << "Unable to create oat file: " << oat_name; |
Brian Carlstrom | 6ef827a | 2011-12-11 14:57:47 -0800 | [diff] [blame] | 542 | return EXIT_FAILURE; |
Ian Rogers | 5e863dd | 2011-11-02 20:00:10 -0700 | [diff] [blame] | 543 | } |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 544 | |
| 545 | LOG(INFO) << "dex2oat: " << oat_name; |
Ian Rogers | 5e863dd | 2011-11-02 20:00:10 -0700 | [diff] [blame] | 546 | |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 547 | Runtime::Options options; |
Brian Carlstrom | 5de8fe5 | 2011-10-16 14:10:09 -0700 | [diff] [blame] | 548 | options.push_back(std::make_pair("compiler", reinterpret_cast<void*>(NULL))); |
Brian Carlstrom | b7bbba4 | 2011-10-13 14:58:47 -0700 | [diff] [blame] | 549 | std::string boot_class_path_string; |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 550 | if (boot_image_option.empty()) { |
Brian Carlstrom | 58ae941 | 2011-10-04 00:56:06 -0700 | [diff] [blame] | 551 | boot_class_path_string += "-Xbootclasspath:"; |
| 552 | for (size_t i = 0; i < dex_filenames.size()-1; i++) { |
| 553 | boot_class_path_string += dex_filenames[i]; |
| 554 | boot_class_path_string += ":"; |
| 555 | } |
| 556 | boot_class_path_string += dex_filenames[dex_filenames.size()-1]; |
| 557 | options.push_back(std::make_pair(boot_class_path_string.c_str(), reinterpret_cast<void*>(NULL))); |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 558 | } else { |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 559 | options.push_back(std::make_pair(boot_image_option.c_str(), reinterpret_cast<void*>(NULL))); |
| 560 | } |
Brian Carlstrom | 58ae941 | 2011-10-04 00:56:06 -0700 | [diff] [blame] | 561 | if (!host_prefix.empty()) { |
| 562 | options.push_back(std::make_pair("host-prefix", host_prefix.c_str())); |
| 563 | } |
jeffhao | 5d84040 | 2011-10-24 17:09:45 -0700 | [diff] [blame] | 564 | for (size_t i = 0; i < runtime_args.size(); i++) { |
| 565 | options.push_back(std::make_pair(runtime_args[i], reinterpret_cast<void*>(NULL))); |
| 566 | } |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 567 | |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 568 | UniquePtr<Dex2Oat> dex2oat(Dex2Oat::Create(options)); |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 569 | |
Elliott Hughes | bb551fa | 2012-01-25 16:35:29 -0800 | [diff] [blame] | 570 | // If --image-classes was specified, calculate the full list of classes to include in the image |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 571 | UniquePtr<const std::set<std::string> > image_classes(NULL); |
| 572 | if (image_classes_filename != NULL) { |
| 573 | image_classes.reset(dex2oat->GetImageClassDescriptors(image_classes_filename)); |
| 574 | if (image_classes.get() == NULL) { |
| 575 | LOG(ERROR) << "Failed to create list of image classes from " << image_classes_filename; |
| 576 | return EXIT_FAILURE; |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 577 | } |
| 578 | } |
| 579 | |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 580 | std::vector<const DexFile*> dex_files; |
| 581 | if (boot_image_option.empty()) { |
| 582 | dex_files = Runtime::Current()->GetClassLinker()->GetBootClassPath(); |
| 583 | } else { |
| 584 | if (dex_filenames.empty()) { |
| 585 | UniquePtr<ZipArchive> zip_archive(ZipArchive::OpenFromFd(zip_fd)); |
| 586 | if (zip_archive.get() == NULL) { |
| 587 | LOG(ERROR) << "Failed to zip from file descriptor for " << zip_name; |
Brian Carlstrom | 2e3d1b2 | 2012-01-09 18:01:56 -0800 | [diff] [blame] | 588 | return EXIT_FAILURE; |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 589 | } |
| 590 | const DexFile* dex_file = DexFile::Open(*zip_archive.get(), zip_name); |
| 591 | if (dex_file == NULL) { |
Elliott Hughes | fd8cba4 | 2012-01-11 14:34:28 -0800 | [diff] [blame] | 592 | LOG(ERROR) << "Failed to open dex from file descriptor for zip file: " << zip_name; |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 593 | return EXIT_FAILURE; |
| 594 | } |
| 595 | dex_files.push_back(dex_file); |
| 596 | } else { |
| 597 | DexFile::OpenDexFiles(dex_filenames, dex_files, host_prefix); |
| 598 | } |
| 599 | } |
| 600 | |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 601 | if (!dex2oat->CreateOatFile(boot_image_option, |
Brian Carlstrom | a6cc893 | 2012-01-04 14:44:07 -0800 | [diff] [blame] | 602 | dex_files, |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 603 | oat_file.get(), |
| 604 | image, |
| 605 | image_classes.get())) { |
Elliott Hughes | fd8cba4 | 2012-01-11 14:34:28 -0800 | [diff] [blame] | 606 | LOG(ERROR) << "Failed to create oat file: " << oat_name; |
Brian Carlstrom | e24fa61 | 2011-09-29 00:53:55 -0700 | [diff] [blame] | 607 | return EXIT_FAILURE; |
| 608 | } |
| 609 | |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 610 | if (!image) { |
Elliott Hughes | fd8cba4 | 2012-01-11 14:34:28 -0800 | [diff] [blame] | 611 | LOG(INFO) << "Oat file written successfully: " << oat_name; |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 612 | return EXIT_SUCCESS; |
| 613 | } |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 614 | |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 615 | if (!dex2oat->CreateImageFile(image_filename, |
| 616 | image_base, |
| 617 | image_classes.get(), |
| 618 | oat_filename, |
| 619 | host_prefix)) { |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 620 | return EXIT_FAILURE; |
| 621 | } |
| 622 | |
Brian Carlstrom | ae82698 | 2011-11-09 01:33:42 -0800 | [diff] [blame] | 623 | // We wrote the oat file successfully, and want to keep it. |
Elliott Hughes | bb551fa | 2012-01-25 16:35:29 -0800 | [diff] [blame] | 624 | LOG(INFO) << "Oat file written successfully: " << oat_filename; |
| 625 | LOG(INFO) << "Image written successfully: " << image_filename; |
Brian Carlstrom | 69b15fb | 2011-09-03 12:25:21 -0700 | [diff] [blame] | 626 | return EXIT_SUCCESS; |
| 627 | } |
| 628 | |
| 629 | } // namespace art |
| 630 | |
| 631 | int main(int argc, char** argv) { |
| 632 | return art::dex2oat(argc, argv); |
| 633 | } |