Changes for vogar compatibility
Make sure dex2oat can make an image with an empty list of image_classes.
Add in some checks to make sure that no bad arguments sneak into
CompilerDriver.
If we're not on the ART_TARGET, we should check for the "hostdex"
versions of the libraries to substitute in our libart version.
Change-Id: I5e8485c6089d25664492f0217b43ef64ca84c061
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index 6817f14..ff4806b 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -377,8 +377,10 @@
compiler_->Init();
CHECK(!Runtime::Current()->IsStarted());
- if (!image_) {
- CHECK(image_classes_.get() == NULL);
+ if (image_) {
+ CHECK(image_classes_.get() != nullptr);
+ } else {
+ CHECK(image_classes_.get() == nullptr);
}
// Are we generating CFI information?
@@ -591,7 +593,7 @@
ThreadPool* thread_pool, TimingLogger* timings) {
for (size_t i = 0; i != dex_files.size(); ++i) {
const DexFile* dex_file = dex_files[i];
- CHECK(dex_file != NULL);
+ CHECK(dex_file != nullptr);
ResolveDexFile(class_loader, *dex_file, thread_pool, timings);
}
}
@@ -689,6 +691,7 @@
// Make a list of descriptors for classes to include in the image
void CompilerDriver::LoadImageClasses(TimingLogger* timings)
LOCKS_EXCLUDED(Locks::mutator_lock_) {
+ CHECK(timings != nullptr);
if (!IsImage()) {
return;
}
@@ -698,6 +701,7 @@
Thread* self = Thread::Current();
ScopedObjectAccess soa(self);
ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
+ CHECK(image_classes_.get() != nullptr);
for (auto it = image_classes_->begin(), end = image_classes_->end(); it != end;) {
const std::string& descriptor(*it);
SirtRef<mirror::Class> klass(self, class_linker->FindSystemClass(self, descriptor.c_str()));
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index e0bfc6b..fe0ebf1 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -1139,21 +1139,23 @@
WellKnownClasses::Init(self->GetJniEnv());
// If --image-classes was specified, calculate the full list of classes to include in the image
- UniquePtr<CompilerDriver::DescriptorSet> image_classes(NULL);
- if (image_classes_filename != NULL) {
+ UniquePtr<CompilerDriver::DescriptorSet> image_classes(nullptr);
+ if (image_classes_filename != nullptr) {
std::string error_msg;
- if (image_classes_zip_filename != NULL) {
+ if (image_classes_zip_filename != nullptr) {
image_classes.reset(dex2oat->ReadImageClassesFromZip(image_classes_zip_filename,
image_classes_filename,
&error_msg));
} else {
image_classes.reset(dex2oat->ReadImageClassesFromFile(image_classes_filename));
}
- if (image_classes.get() == NULL) {
+ if (image_classes.get() == nullptr) {
LOG(ERROR) << "Failed to create list of image classes from '" << image_classes_filename <<
"': " << error_msg;
return EXIT_FAILURE;
}
+ } else if (image) {
+ image_classes.reset(new CompilerDriver::DescriptorSet);
}
std::vector<const DexFile*> dex_files;
diff --git a/runtime/parsed_options.cc b/runtime/parsed_options.cc
index 8c18dff..623b0c6 100644
--- a/runtime/parsed_options.cc
+++ b/runtime/parsed_options.cc
@@ -674,10 +674,17 @@
// the art specific version. This can happen with on device
// boot.art/boot.oat generation by GenerateImage which relies on the
// value of BOOTCLASSPATH.
+#if defined(ART_TARGET)
std::string core_jar("/core.jar");
+ std::string core_libart_jar("/core-libart.jar");
+#else
+ // The host uses hostdex files.
+ std::string core_jar("/core-hostdex.jar");
+ std::string core_libart_jar("/core-libart-hostdex.jar");
+#endif
size_t core_jar_pos = boot_class_path_string_.find(core_jar);
if (core_jar_pos != std::string::npos) {
- boot_class_path_string_.replace(core_jar_pos, core_jar.size(), "/core-libart.jar");
+ boot_class_path_string_.replace(core_jar_pos, core_jar.size(), core_libart_jar);
}
if (compiler_callbacks_ == nullptr && image_.empty()) {