Replace "dummy" with "placeholder" for MemMaps.
Test: m
Bug: 161336379
Change-Id: I0b9e94bb4fe288668aa578507e141f09ea84ccba
diff --git a/libartbase/base/mem_map.cc b/libartbase/base/mem_map.cc
index bd880da..aa07f1c 100644
--- a/libartbase/base/mem_map.cc
+++ b/libartbase/base/mem_map.cc
@@ -389,7 +389,7 @@
reuse);
}
-MemMap MemMap::MapDummy(const char* name, uint8_t* addr, size_t byte_count) {
+MemMap MemMap::MapPlaceholder(const char* name, uint8_t* addr, size_t byte_count) {
if (byte_count == 0) {
return Invalid();
}
diff --git a/libartbase/base/mem_map.h b/libartbase/base/mem_map.h
index 4b6257b..4c41388 100644
--- a/libartbase/base/mem_map.h
+++ b/libartbase/base/mem_map.h
@@ -171,7 +171,7 @@
// This is useful when we do not have control over the code calling mmap,
// but when we still want to keep track of it in the list.
// The region is not considered to be owned and will not be unmmaped.
- static MemMap MapDummy(const char* name, uint8_t* addr, size_t byte_count);
+ static MemMap MapPlaceholder(const char* name, uint8_t* addr, size_t byte_count);
// Map part of a file, taking care of non-page aligned offsets. The
// "start" offset is absolute, not relative.
diff --git a/runtime/oat_file.cc b/runtime/oat_file.cc
index d8fd1ea..d8ef21d 100644
--- a/runtime/oat_file.cc
+++ b/runtime/oat_file.cc
@@ -1025,7 +1025,7 @@
// Guarded by host_dlopen_handles_lock_;
static std::unordered_set<void*> host_dlopen_handles_;
- // Reservation and dummy memory map objects corresponding to the regions mapped by dlopen.
+ // Reservation and placeholder memory map objects corresponding to the regions mapped by dlopen.
// Note: Must be destroyed after dlclose() as it can hold the owning reservation.
std::vector<MemMap> dlopen_mmaps_;
@@ -1232,7 +1232,7 @@
LOG(FATAL) << "Should not reach here.";
UNREACHABLE();
#else
- struct DummyMapData {
+ struct PlaceholderMapData {
const char* name;
uint8_t* vaddr;
size_t memsz;
@@ -1264,7 +1264,7 @@
}
}
}
- // Add dummy mmaps for this file.
+ // Add placeholder mmaps for this file.
if (contains_begin) {
for (Elf_Half i = 0; i < info->dlpi_phnum; i++) {
if (info->dlpi_phdr[i].p_type == PT_LOAD) {
@@ -1272,17 +1272,19 @@
info->dlpi_phdr[i].p_vaddr);
size_t memsz = info->dlpi_phdr[i].p_memsz;
size_t name_size = strlen(info->dlpi_name) + 1u;
- std::vector<char>* dummy_maps_names = context->dummy_maps_names_;
+ std::vector<char>* placeholder_maps_names = context->placeholder_maps_names_;
// We must not allocate any memory in the callback, see b/156312036 .
- if (name_size < dummy_maps_names->capacity() - dummy_maps_names->size() &&
- context->dummy_maps_data_->size() < context->dummy_maps_data_->capacity()) {
- dummy_maps_names->insert(
- dummy_maps_names->end(), info->dlpi_name, info->dlpi_name + name_size);
- const char* name = &(*dummy_maps_names)[dummy_maps_names->size() - name_size];
- context->dummy_maps_data_->push_back({ name, vaddr, memsz });
+ if (name_size < placeholder_maps_names->capacity() - placeholder_maps_names->size() &&
+ context->placeholder_maps_data_->size() <
+ context->placeholder_maps_data_->capacity()) {
+ placeholder_maps_names->insert(
+ placeholder_maps_names->end(), info->dlpi_name, info->dlpi_name + name_size);
+ const char* name =
+ &(*placeholder_maps_names)[placeholder_maps_names->size() - name_size];
+ context->placeholder_maps_data_->push_back({ name, vaddr, memsz });
}
- context->num_dummy_maps_ += 1u;
- context->dummy_maps_names_size_ += name_size;
+ context->num_placeholder_maps_ += 1u;
+ context->placeholder_maps_names_size_ += name_size;
}
}
return 1; // Stop iteration and return 1 from dl_iterate_phdr.
@@ -1290,27 +1292,27 @@
return 0; // Continue iteration and return 0 from dl_iterate_phdr when finished.
}
const uint8_t* const begin_;
- std::vector<DummyMapData>* dummy_maps_data_;
- size_t num_dummy_maps_;
- std::vector<char>* dummy_maps_names_;
- size_t dummy_maps_names_size_;
+ std::vector<PlaceholderMapData>* placeholder_maps_data_;
+ size_t num_placeholder_maps_;
+ std::vector<char>* placeholder_maps_names_;
+ size_t placeholder_maps_names_size_;
size_t shared_objects_before;
size_t shared_objects_seen;
};
// We must not allocate any memory in the callback, see b/156312036 .
- // Therefore we pre-allocate storage for the data we need for creating the dummy maps.
- std::vector<DummyMapData> dummy_maps_data;
- dummy_maps_data.reserve(32); // 32 should be enough. If not, we'll retry.
- std::vector<char> dummy_maps_names;
- dummy_maps_names.reserve(4 * KB); // 4KiB should be enough. If not, we'll retry.
+ // Therefore we pre-allocate storage for the data we need for creating the placeholder maps.
+ std::vector<PlaceholderMapData> placeholder_maps_data;
+ placeholder_maps_data.reserve(32); // 32 should be enough. If not, we'll retry.
+ std::vector<char> placeholder_maps_names;
+ placeholder_maps_names.reserve(4 * KB); // 4KiB should be enough. If not, we'll retry.
dl_iterate_context context = {
Begin(),
- &dummy_maps_data,
- /*num_dummy_maps_*/ 0u,
- &dummy_maps_names,
- /*dummy_maps_names_size_*/ 0u,
+ &placeholder_maps_data,
+ /*num_placeholder_maps_*/ 0u,
+ &placeholder_maps_names,
+ /*placeholder_maps_names_size_*/ 0u,
shared_objects_before_,
/*shared_objects_seen*/ 0u
};
@@ -1320,10 +1322,10 @@
// before giving up. This should be unusual.
VLOG(oat) << "Need a second run in PreSetup, didn't find with shared_objects_before="
<< shared_objects_before_;
- DCHECK(dummy_maps_data.empty());
- DCHECK_EQ(context.num_dummy_maps_, 0u);
- DCHECK(dummy_maps_names.empty());
- DCHECK_EQ(context.dummy_maps_names_size_, 0u);
+ DCHECK(placeholder_maps_data.empty());
+ DCHECK_EQ(context.num_placeholder_maps_, 0u);
+ DCHECK(placeholder_maps_names.empty());
+ DCHECK_EQ(context.placeholder_maps_names_size_, 0u);
context.shared_objects_before = 0u;
context.shared_objects_seen = 0u;
if (dl_iterate_phdr(dl_iterate_context::callback, &context) == 0) {
@@ -1333,26 +1335,27 @@
}
}
- if (dummy_maps_data.size() < context.num_dummy_maps_) {
+ if (placeholder_maps_data.size() < context.num_placeholder_maps_) {
// Insufficient capacity. Reserve more space and retry.
- dummy_maps_data.clear();
- dummy_maps_data.reserve(context.num_dummy_maps_);
- context.num_dummy_maps_ = 0u;
- dummy_maps_names.clear();
- dummy_maps_names.reserve(context.dummy_maps_names_size_);
- context.dummy_maps_names_size_ = 0u;
+ placeholder_maps_data.clear();
+ placeholder_maps_data.reserve(context.num_placeholder_maps_);
+ context.num_placeholder_maps_ = 0u;
+ placeholder_maps_names.clear();
+ placeholder_maps_names.reserve(context.placeholder_maps_names_size_);
+ context.placeholder_maps_names_size_ = 0u;
context.shared_objects_before = 0u;
context.shared_objects_seen = 0u;
bool success = (dl_iterate_phdr(dl_iterate_context::callback, &context) != 0);
CHECK(success);
}
- CHECK_EQ(dummy_maps_data.size(), context.num_dummy_maps_);
- CHECK_EQ(dummy_maps_names.size(), context.dummy_maps_names_size_);
- DCHECK_EQ(static_cast<size_t>(std::count(dummy_maps_names.begin(), dummy_maps_names.end(), '\0')),
- context.num_dummy_maps_);
- for (const DummyMapData& data : dummy_maps_data) {
- MemMap mmap = MemMap::MapDummy(data.name, data.vaddr, data.memsz);
+ CHECK_EQ(placeholder_maps_data.size(), context.num_placeholder_maps_);
+ CHECK_EQ(placeholder_maps_names.size(), context.placeholder_maps_names_size_);
+ DCHECK_EQ(static_cast<size_t>(std::count(placeholder_maps_names.begin(),
+ placeholder_maps_names.end(), '\0')),
+ context.num_placeholder_maps_);
+ for (const PlaceholderMapData& data : placeholder_maps_data) {
+ MemMap mmap = MemMap::MapPlaceholder(data.name, data.vaddr, data.memsz);
dlopen_mmaps_.push_back(std::move(mmap));
}
#endif
@@ -1525,7 +1528,7 @@
// SetVdex will take ownership of the VdexFile.
SetVdex(vdex_file.release());
- // Create a dummy OatHeader with a key store containing only the compiler
+ // Create a fake OatHeader with a key store containing only the compiler
// filter (it helps debugging and is required by
// OatHeader::GetCompilerFilter).
std::unique_ptr<const InstructionSetFeatures> isa_features =