Fix multi-image boot class path construction.
This changes the stored boot class path components of the
boot image prebuilts to exclude the bogus
out/target/product/taimen/dex_bootjars/system/framework/
part and leaves only
/system/framework/boot*.art
but it does not impact the loading of the boot image at all.
Also remove the "infix" from core image filenames as it was
duplicating a part of the prefix, thus
core-interp-ac-core-libart-interp-ac.art
shall change to
core-interp-ac-core-libart.art
Test: Manual inspection of "m dump-oat-boot" output.
Test: m test-art-host-gtest
Test: testrunner.py --host
Change-Id: Iffbab30be8b8ce6f8f2aec8985e94177db517653
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index b4aa327..690802b 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -1010,25 +1010,6 @@
base_img = base_img.substr(0, last_img_slash + 1);
- // Note: we have some special case here for our testing. We have to inject the differentiating
- // parts for the different core images.
- std::string infix; // Empty infix by default.
- {
- // Check the first name.
- std::string dex_file = oat_filenames_[0];
- size_t last_dex_slash = dex_file.rfind('/');
- if (last_dex_slash != std::string::npos) {
- dex_file = dex_file.substr(last_dex_slash + 1);
- }
- size_t last_dex_dot = dex_file.rfind('.');
- if (last_dex_dot != std::string::npos) {
- dex_file = dex_file.substr(0, last_dex_dot);
- }
- if (android::base::StartsWith(dex_file, "core-")) {
- infix = dex_file.substr(strlen("core"));
- }
- }
-
std::string base_symbol_oat;
if (!oat_unstripped_.empty()) {
base_symbol_oat = oat_unstripped_[0];
@@ -1042,11 +1023,11 @@
// 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, infix, ".art");
+ 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, infix, ".oat");
+ 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());
@@ -1061,11 +1042,9 @@
// 0) Assume input is /a/b/c.d
// 1) Strip the path -> c.d
// 2) Inject prefix p -> pc.d
- // 3) Inject infix i -> pci.d
- // 4) Replace suffix with s if it's "jar" -> d == "jar" -> pci.s
+ // 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 std::string& infix,
const char* replace_suffix) {
size_t last_dex_slash = in.rfind('/');
if (last_dex_slash != std::string::npos) {
@@ -1074,13 +1053,6 @@
if (!prefix.empty()) {
in = prefix + in;
}
- if (!infix.empty()) {
- // Inject infix.
- size_t last_dot = in.rfind('.');
- if (last_dot != std::string::npos) {
- in.insert(last_dot, infix);
- }
- }
if (android::base::EndsWith(in, ".jar")) {
in = in.substr(0, in.length() - strlen(".jar")) +
(replace_suffix != nullptr ? replace_suffix : "");
diff --git a/runtime/gc/space/image_space.cc b/runtime/gc/space/image_space.cc
index 1d01883..fa36835 100644
--- a/runtime/gc/space/image_space.cc
+++ b/runtime/gc/space/image_space.cc
@@ -2378,6 +2378,12 @@
DCHECK_GT(oat_filenames.size(), 1u);
// If the image filename was adapted (e.g., for our tests), we need to change this here,
// too, but need to strip all path components (they will be re-established when loading).
+ // For example, dex location
+ // /system/framework/core-libart.art
+ // with image name
+ // out/target/product/taimen/dex_bootjars/system/framework/arm64/boot-core-libart.art
+ // yields boot class path component
+ // /system/framework/boot-core-libart.art .
std::ostringstream bootcp_oss;
bool first_bootcp = true;
for (size_t i = 0; i < dex_locations.size(); ++i) {
@@ -2397,7 +2403,7 @@
size_t image_last_sep = (image_last_slash == std::string::npos)
? image_last_at
: (image_last_at == std::string::npos)
- ? std::string::npos
+ ? image_last_slash
: std::max(image_last_slash, image_last_at);
// Note: whenever image_last_sep == npos, +1 overflow means using the full string.