Revert^2 "Pass boot class path to ImageSpace::LoadBootImage."
This reverts commit db4b1deebf425be5f1d0f597d1ef540f19908324.
Fixed JDWP tests, see "Test:" stanzas below.
Change-Id: I6fb56ac990b78164cbd3f93c9f6df66e0dd9a813
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Test: Pixel 2 XL boots.
Test: m test-art-target-gtest
Test: testrunner.py --target --optimizing
Test: run-libcore-tests.sh --mode=device --variant=X64
Test: run-jdwp-tests.sh --mode=host --variant=X64
Test: run-jdwp-tests.sh --mode=device --variant=X64
Bug: 119868597
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index f729934..a5bba9b 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -103,6 +103,7 @@
using android::base::StringAppendV;
using android::base::StringPrintf;
+using gc::space::ImageSpace;
static constexpr size_t kDefaultMinDexFilesForSwap = 2;
static constexpr size_t kDefaultMinDexFileCumulativeSizeForSwap = 20 * MB;
@@ -964,89 +965,22 @@
}
void ExpandOatAndImageFilenames() {
- std::string base_oat = oat_filenames_[0];
- size_t last_oat_slash = base_oat.rfind('/');
- if (last_oat_slash == std::string::npos) {
- Usage("Unusable boot image oat filename %s", base_oat.c_str());
+ if (image_filenames_[0].rfind('/') == std::string::npos) {
+ Usage("Unusable boot image filename %s", image_filenames_[0].c_str());
}
- // We also need to honor path components that were encoded through '@'. Otherwise the loading
- // code won't be able to find the images.
- if (base_oat.find('@', last_oat_slash) != std::string::npos) {
- last_oat_slash = base_oat.rfind('@');
- }
- base_oat = base_oat.substr(0, last_oat_slash + 1);
+ image_filenames_ = ImageSpace::ExpandMultiImageLocations(dex_locations_, image_filenames_[0]);
- std::string base_img = image_filenames_[0];
- size_t last_img_slash = base_img.rfind('/');
- if (last_img_slash == std::string::npos) {
- Usage("Unusable boot image filename %s", base_img.c_str());
+ if (oat_filenames_[0].rfind('/') == std::string::npos) {
+ Usage("Unusable boot image oat filename %s", oat_filenames_[0].c_str());
}
- // We also need to honor path components that were encoded through '@'. Otherwise the loading
- // code won't be able to find the images.
- if (base_img.find('@', last_img_slash) != std::string::npos) {
- last_img_slash = base_img.rfind('@');
- }
+ oat_filenames_ = ImageSpace::ExpandMultiImageLocations(dex_locations_, oat_filenames_[0]);
- // Get the prefix, which is the primary image name (without path components). Strip the
- // extension.
- std::string prefix = base_img.substr(last_img_slash + 1);
- if (prefix.rfind('.') != std::string::npos) {
- prefix = prefix.substr(0, prefix.rfind('.'));
- }
- if (!prefix.empty()) {
- prefix = prefix + "-";
- }
-
- base_img = base_img.substr(0, last_img_slash + 1);
-
- std::string base_symbol_oat;
if (!oat_unstripped_.empty()) {
- base_symbol_oat = oat_unstripped_[0];
- size_t last_symbol_oat_slash = base_symbol_oat.rfind('/');
- if (last_symbol_oat_slash == std::string::npos) {
- Usage("Unusable boot image symbol filename %s", base_symbol_oat.c_str());
+ if (oat_unstripped_[0].rfind('/') == std::string::npos) {
+ Usage("Unusable boot image symbol filename %s", oat_unstripped_[0].c_str());
}
- base_symbol_oat = base_symbol_oat.substr(0, last_symbol_oat_slash + 1);
+ oat_unstripped_ = ImageSpace::ExpandMultiImageLocations(dex_locations_, oat_unstripped_[0]);
}
-
- // Now create the other names. Use a counted loop to skip the first one.
- for (size_t i = 1; i < dex_locations_.size(); ++i) {
- // TODO: Make everything properly std::string.
- std::string image_name = CreateMultiImageName(dex_locations_[i], prefix, ".art");
- char_backing_storage_.push_front(base_img + image_name);
- image_filenames_.push_back(char_backing_storage_.front().c_str());
-
- std::string oat_name = CreateMultiImageName(dex_locations_[i], prefix, ".oat");
- char_backing_storage_.push_front(base_oat + oat_name);
- oat_filenames_.push_back(char_backing_storage_.front().c_str());
-
- if (!base_symbol_oat.empty()) {
- char_backing_storage_.push_front(base_symbol_oat + oat_name);
- oat_unstripped_.push_back(char_backing_storage_.front().c_str());
- }
- }
- }
-
- // Modify the input string in the following way:
- // 0) Assume input is /a/b/c.d
- // 1) Strip the path -> c.d
- // 2) Inject prefix p -> pc.d
- // 3) Replace suffix with s if it's "jar" -> d == "jar" -> pc.s
- static std::string CreateMultiImageName(std::string in,
- const std::string& prefix,
- const char* replace_suffix) {
- size_t last_dex_slash = in.rfind('/');
- if (last_dex_slash != std::string::npos) {
- in = in.substr(last_dex_slash + 1);
- }
- if (!prefix.empty()) {
- in = prefix + in;
- }
- if (android::base::EndsWith(in, ".jar")) {
- in = in.substr(0, in.length() - strlen(".jar")) +
- (replace_suffix != nullptr ? replace_suffix : "");
- }
- return in;
}
void InsertCompileOptions(int argc, char** argv) {
@@ -1497,11 +1431,8 @@
if (IsBootImage()) {
// If we're compiling the boot image, store the boot classpath into the Key-Value store.
- // We need this for the multi-image case.
- key_value_store_->Put(OatHeader::kBootClassPathKey,
- gc::space::ImageSpace::GetMultiImageBootClassPath(dex_locations_,
- oat_filenames_,
- image_filenames_));
+ // We use this when loading the boot image.
+ key_value_store_->Put(OatHeader::kBootClassPathKey, android::base::Join(dex_locations_, ':'));
}
if (!IsBootImage()) {
@@ -1513,8 +1444,7 @@
if (CompilerFilter::DependsOnImageChecksum(compiler_options_->GetCompilerFilter())) {
TimingLogger::ScopedTiming t3("Loading image checksum", timings_);
- std::vector<gc::space::ImageSpace*> image_spaces =
- Runtime::Current()->GetHeap()->GetBootImageSpaces();
+ std::vector<ImageSpace*> image_spaces = Runtime::Current()->GetHeap()->GetBootImageSpaces();
boot_image_checksum_ = image_spaces[0]->GetImageHeader().GetImageChecksum();
} else {
boot_image_checksum_ = 0u;
@@ -1953,7 +1883,7 @@
if (IsImage()) {
if (IsAppImage() && image_base_ == 0) {
gc::Heap* const heap = Runtime::Current()->GetHeap();
- for (gc::space::ImageSpace* image_space : heap->GetBootImageSpaces()) {
+ for (ImageSpace* image_space : heap->GetBootImageSpaces()) {
image_base_ = std::max(image_base_, RoundUp(
reinterpret_cast<uintptr_t>(image_space->GetImageHeader().GetOatFileEnd()),
kPageSize));