Ensure VM's heap is accounted correctly.
The meminfo dumping assumes that dalvik heap is created using ashmem and has a
prefix of "dalvik-". Ensure ART's anonymous mmaps fit this pattern. Tidy up
anonymous mmaps so naming is more consistent.
Change-Id: I9c62a9d1da21da6a048effb0399a1f85865cb12d
diff --git a/src/common_test.h b/src/common_test.h
index 46a8309..d2c9102 100644
--- a/src/common_test.h
+++ b/src/common_test.h
@@ -529,7 +529,7 @@
void ReserveImageSpace() {
// Reserve where the image will be loaded up front so that other parts of test set up don't
// accidentally end up colliding with the fixed memory address when we need to load the image.
- image_reservation_.reset(MemMap::MapAnonymous("Image reservation", (byte*)ART_BASE_ADDRESS,
+ image_reservation_.reset(MemMap::MapAnonymous("image reservation", (byte*)ART_BASE_ADDRESS,
(size_t)100 * 1024 * 1024, // 100MB
PROT_NONE));
}
diff --git a/src/gc/card_table.cc b/src/gc/card_table.cc
index 4331270..e053a06 100644
--- a/src/gc/card_table.cc
+++ b/src/gc/card_table.cc
@@ -53,7 +53,7 @@
/* Set up the card table */
size_t capacity = heap_capacity / kCardSize;
/* Allocate an extra 256 bytes to allow fixed low-byte of base */
- UniquePtr<MemMap> mem_map(MemMap::MapAnonymous("dalvik-card-table", NULL,
+ UniquePtr<MemMap> mem_map(MemMap::MapAnonymous("card table", NULL,
capacity + 256, PROT_READ | PROT_WRITE));
CHECK(mem_map.get() != NULL) << "couldn't allocate card table";
// All zeros is the correct initial value; all clean. Anonymous mmaps are initialized to zero, we
diff --git a/src/gc/large_object_space.cc b/src/gc/large_object_space.cc
index 69320fa..a589e67 100644
--- a/src/gc/large_object_space.cc
+++ b/src/gc/large_object_space.cc
@@ -60,7 +60,8 @@
}
mirror::Object* LargeObjectMapSpace::Alloc(Thread* self, size_t num_bytes) {
- MemMap* mem_map = MemMap::MapAnonymous("allocation", NULL, num_bytes, PROT_READ | PROT_WRITE);
+ MemMap* mem_map = MemMap::MapAnonymous("large object space allocation", NULL, num_bytes,
+ PROT_READ | PROT_WRITE);
if (mem_map == NULL) {
return NULL;
}
diff --git a/src/gc/mod_union_table.h b/src/gc/mod_union_table.h
index 23c0a51..c0b9535 100644
--- a/src/gc/mod_union_table.h
+++ b/src/gc/mod_union_table.h
@@ -63,12 +63,12 @@
// bitmap or not.
virtual void Verify() EXCLUSIVE_LOCKS_REQUIRED(Locks::heap_bitmap_lock_) = 0;
- Heap* GetHeap() {
+ Heap* GetHeap() const {
return heap_;
}
protected:
- Heap* heap_;
+ Heap* const heap_;
};
// Bitmap implementation.
diff --git a/src/gc/space.cc b/src/gc/space.cc
index 9db84f2..9c71841 100644
--- a/src/gc/space.cc
+++ b/src/gc/space.cc
@@ -105,12 +105,12 @@
CHECK(reinterpret_cast<uintptr_t>(mem_map->Begin()) % kGcCardSize == 0);
CHECK(reinterpret_cast<uintptr_t>(mem_map->End()) % kGcCardSize == 0);
live_bitmap_.reset(SpaceBitmap::Create(
- StringPrintf("allocspace-%s-live-bitmap-%d", name.c_str(), static_cast<int>(bitmap_index)),
+ StringPrintf("allocspace %s live-bitmap %d", name.c_str(), static_cast<int>(bitmap_index)),
Begin(), Capacity()));
DCHECK(live_bitmap_.get() != NULL) << "could not create allocspace live bitmap #" << bitmap_index;
mark_bitmap_.reset(SpaceBitmap::Create(
- StringPrintf("allocspace-%s-mark-bitmap-%d", name.c_str(), static_cast<int>(bitmap_index)),
+ StringPrintf("allocspace %s mark-bitmap %d", name.c_str(), static_cast<int>(bitmap_index)),
Begin(), Capacity()));
DCHECK(live_bitmap_.get() != NULL) << "could not create allocspace mark bitmap #" << bitmap_index;
}
@@ -469,7 +469,7 @@
: MemMapSpace(name, mem_map, mem_map->Size(), kGcRetentionPolicyNeverCollect) {
const size_t bitmap_index = bitmap_index_++;
live_bitmap_.reset(SpaceBitmap::Create(
- StringPrintf("imagespace-%s-live-bitmap-%d", name.c_str(), static_cast<int>(bitmap_index)),
+ StringPrintf("imagespace %s live-bitmap %d", name.c_str(), static_cast<int>(bitmap_index)),
Begin(), Capacity()));
DCHECK(live_bitmap_.get() != NULL) << "could not create imagespace live bitmap #" << bitmap_index;
}
diff --git a/src/gc/space_bitmap_test.cc b/src/gc/space_bitmap_test.cc
index 5a829e4..4645659 100644
--- a/src/gc/space_bitmap_test.cc
+++ b/src/gc/space_bitmap_test.cc
@@ -33,7 +33,7 @@
TEST_F(SpaceBitmapTest, Init) {
byte* heap_begin = reinterpret_cast<byte*>(0x10000000);
size_t heap_capacity = 16 * MB;
- UniquePtr<SpaceBitmap> space_bitmap(SpaceBitmap::Create("test-bitmap",
+ UniquePtr<SpaceBitmap> space_bitmap(SpaceBitmap::Create("test bitmap",
heap_begin, heap_capacity));
EXPECT_TRUE(space_bitmap.get() != NULL);
}
@@ -60,7 +60,7 @@
byte* heap_begin = reinterpret_cast<byte*>(0x10000000);
size_t heap_capacity = 16 * MB;
- UniquePtr<SpaceBitmap> space_bitmap(SpaceBitmap::Create("test-bitmap",
+ UniquePtr<SpaceBitmap> space_bitmap(SpaceBitmap::Create("test bitmap",
heap_begin, heap_capacity));
EXPECT_TRUE(space_bitmap.get() != NULL);
diff --git a/src/heap.cc b/src/heap.cc
index f7abe0a..c8df031 100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -284,10 +284,10 @@
// Default mark stack size in bytes.
static const size_t default_mark_stack_size = 64 * KB;
- mark_stack_.reset(ObjectStack::Create("dalvik-mark-stack", default_mark_stack_size));
- allocation_stack_.reset(ObjectStack::Create("dalvik-allocation-stack",
+ mark_stack_.reset(ObjectStack::Create("mark stack", default_mark_stack_size));
+ allocation_stack_.reset(ObjectStack::Create("allocation stack",
max_allocation_stack_size_));
- live_stack_.reset(ObjectStack::Create("dalvik-live-stack",
+ live_stack_.reset(ObjectStack::Create("live stack",
max_allocation_stack_size_));
// It's still too early to take a lock because there are no threads yet, but we can create locks
diff --git a/src/heap_test.cc b/src/heap_test.cc
index 79cc835..8bed7e3 100644
--- a/src/heap_test.cc
+++ b/src/heap_test.cc
@@ -57,7 +57,7 @@
TEST_F(HeapTest, HeapBitmapCapacityTest) {
byte* heap_begin = reinterpret_cast<byte*>(0x1000);
const size_t heap_capacity = SpaceBitmap::kAlignment * (sizeof(intptr_t) * 8 + 1);
- UniquePtr<SpaceBitmap> bitmap(SpaceBitmap::Create("test-bitmap", heap_begin, heap_capacity));
+ UniquePtr<SpaceBitmap> bitmap(SpaceBitmap::Create("test bitmap", heap_begin, heap_capacity));
bitmap->Set(reinterpret_cast<const mirror::Object*>(&heap_begin[heap_capacity - SpaceBitmap::kAlignment]));
}
diff --git a/src/image_writer.cc b/src/image_writer.cc
index dc19d72..e21ff72 100644
--- a/src/image_writer.cc
+++ b/src/image_writer.cc
@@ -143,7 +143,7 @@
int prot = PROT_READ | PROT_WRITE;
size_t length = RoundUp(size, kPageSize);
- image_.reset(MemMap::MapAnonymous("image-writer-image", NULL, length, prot));
+ image_.reset(MemMap::MapAnonymous("image writer image", NULL, length, prot));
if (image_.get() == NULL) {
LOG(ERROR) << "Failed to allocate memory for image file generation";
return false;
diff --git a/src/mem_map.cc b/src/mem_map.cc
index 32f0530..a7fb5c4 100644
--- a/src/mem_map.cc
+++ b/src/mem_map.cc
@@ -73,7 +73,11 @@
CheckMapRequest(addr, page_aligned_byte_count);
#ifdef USE_ASHMEM
- ScopedFd fd(ashmem_create_region(name, page_aligned_byte_count));
+ // android_os_Debug.cpp read_mapinfo assumes all ashmem regions associated with the VM are
+ // prefixed "dalvik-".
+ std::string debug_friendly_name("dalvik-");
+ debug_friendly_name += name;
+ ScopedFd fd(ashmem_create_region(debug_friendly_name.c_str(), page_aligned_byte_count));
int flags = MAP_PRIVATE;
if (fd.get() == -1) {
PLOG(ERROR) << "ashmem_create_region failed (" << name << ")";