summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Mathieu Chartier <mathieuc@google.com> 2017-02-10 18:41:39 -0800
committer Mathieu Chartier <mathieuc@google.com> 2017-02-10 18:42:21 -0800
commit66b1d575d3be1de84c50623a0485792dfffce6cc (patch)
treee3a40edb621731958d8bf870734fe60729b98989
parent806ac631e53f12061cb0ae7640aa9cd0dd79243d (diff)
Use null error_msg for pic images
Reduces 20ms of overhead for reading proc maps when the map can't be placed at the optimal address. Bug: 34927277 Test: test-art-host && device boot Change-Id: Ib91fff2b832f61c49e67edcd2b7a222ab4409984
-rw-r--r--runtime/gc/space/image_space.cc23
-rw-r--r--runtime/mem_map.cc2
2 files changed, 16 insertions, 9 deletions
diff --git a/runtime/gc/space/image_space.cc b/runtime/gc/space/image_space.cc
index ffbca525d9..fe1c8e8cc5 100644
--- a/runtime/gc/space/image_space.cc
+++ b/runtime/gc/space/image_space.cc
@@ -587,15 +587,18 @@ class ImageSpaceLoader {
}
std::unique_ptr<MemMap> map;
+
// GetImageBegin is the preferred address to map the image. If we manage to map the
// image at the image begin, the amount of fixup work required is minimized.
+ // If it is pic we will retry with error_msg for the failure case. Pass a null error_msg to
+ // avoid reading proc maps for a mapping failure and slowing everything down.
map.reset(LoadImageFile(image_filename,
image_location,
*image_header,
image_header->GetImageBegin(),
file->Fd(),
logger,
- error_msg));
+ image_header->IsPic() ? nullptr : error_msg));
// If the header specifies PIC mode, we can also map at a random low_4gb address since we can
// relocate in-place.
if (map == nullptr && image_header->IsPic()) {
@@ -765,8 +768,10 @@ class ImageSpaceLoader {
if (storage_mode != ImageHeader::kStorageModeLZ4 &&
storage_mode != ImageHeader::kStorageModeLZ4HC) {
- *error_msg = StringPrintf("Invalid storage mode in image header %d",
- static_cast<int>(storage_mode));
+ if (error_msg != nullptr) {
+ *error_msg = StringPrintf("Invalid storage mode in image header %d",
+ static_cast<int>(storage_mode));
+ }
return nullptr;
}
@@ -790,7 +795,7 @@ class ImageSpaceLoader {
image_filename,
error_msg));
if (temp_map == nullptr) {
- DCHECK(!error_msg->empty());
+ DCHECK(error_msg == nullptr || !error_msg->empty());
return nullptr;
}
memcpy(map->Begin(), &image_header, sizeof(ImageHeader));
@@ -804,10 +809,12 @@ class ImageSpaceLoader {
map->Size() - decompress_offset);
VLOG(image) << "Decompressing image took " << PrettyDuration(NanoTime() - start);
if (decompressed_size + sizeof(ImageHeader) != image_header.GetImageSize()) {
- *error_msg = StringPrintf(
- "Decompressed size does not match expected image size %zu vs %zu",
- decompressed_size + sizeof(ImageHeader),
- image_header.GetImageSize());
+ if (error_msg != nullptr) {
+ *error_msg = StringPrintf(
+ "Decompressed size does not match expected image size %zu vs %zu",
+ decompressed_size + sizeof(ImageHeader),
+ image_header.GetImageSize());
+ }
return nullptr;
}
}
diff --git a/runtime/mem_map.cc b/runtime/mem_map.cc
index dce56b3c58..93c212bafb 100644
--- a/runtime/mem_map.cc
+++ b/runtime/mem_map.cc
@@ -400,7 +400,7 @@ MemMap* MemMap::MapFileAtAddress(uint8_t* expected_ptr,
// reuse means it is okay that it overlaps an existing page mapping.
// Only use this if you actually made the page reservation yourself.
CHECK(expected_ptr != nullptr);
-
+ DCHECK(error_msg != nullptr);
DCHECK(ContainedWithinExistingMap(expected_ptr, byte_count, error_msg))
<< ((error_msg != nullptr) ? *error_msg : std::string());
flags |= MAP_FIXED;