diff options
| author | 2013-02-22 11:32:44 -0800 | |
|---|---|---|
| committer | 2013-02-22 23:26:22 -0800 | |
| commit | a40307e8562c20d9b9ce46e773864d07d95512a1 (patch) | |
| tree | ed4e85f5a7cd52458326a8dcb6ad4f89efa9131b | |
| parent | 5fe2c162a422426687ba3570df1dc68864386764 (diff) | |
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
| -rw-r--r-- | src/common_test.h | 2 | ||||
| -rw-r--r-- | src/gc/card_table.cc | 2 | ||||
| -rw-r--r-- | src/gc/large_object_space.cc | 3 | ||||
| -rw-r--r-- | src/gc/mod_union_table.h | 4 | ||||
| -rw-r--r-- | src/gc/space.cc | 6 | ||||
| -rw-r--r-- | src/gc/space_bitmap_test.cc | 4 | ||||
| -rw-r--r-- | src/heap.cc | 6 | ||||
| -rw-r--r-- | src/heap_test.cc | 2 | ||||
| -rw-r--r-- | src/image_writer.cc | 2 | ||||
| -rw-r--r-- | src/mem_map.cc | 6 |
10 files changed, 21 insertions, 16 deletions
diff --git a/src/common_test.h b/src/common_test.h index 46a8309c2a..d2c9102725 100644 --- a/src/common_test.h +++ b/src/common_test.h @@ -529,7 +529,7 @@ class CommonTest : public testing::Test { 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 4331270131..e053a06644 100644 --- a/src/gc/card_table.cc +++ b/src/gc/card_table.cc @@ -53,7 +53,7 @@ CardTable* CardTable::Create(const byte* heap_begin, size_t heap_capacity) { /* 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 69320faffd..a589e67ed9 100644 --- a/src/gc/large_object_space.cc +++ b/src/gc/large_object_space.cc @@ -60,7 +60,8 @@ LargeObjectMapSpace* LargeObjectMapSpace::Create(const std::string& name) { } 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 23c0a516e3..c0b95357e6 100644 --- a/src/gc/mod_union_table.h +++ b/src/gc/mod_union_table.h @@ -63,12 +63,12 @@ class ModUnionTable { // 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 9db84f24ba..9c71841a55 100644 --- a/src/gc/space.cc +++ b/src/gc/space.cc @@ -105,12 +105,12 @@ DlMallocSpace::DlMallocSpace(const std::string& name, MemMap* mem_map, void* msp 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 @@ ImageSpace::ImageSpace(const std::string& name, MemMap* mem_map) : 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 5a829e4f66..4645659470 100644 --- a/src/gc/space_bitmap_test.cc +++ b/src/gc/space_bitmap_test.cc @@ -33,7 +33,7 @@ class SpaceBitmapTest : public CommonTest { 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 @@ TEST_F(SpaceBitmapTest, ScanRange) { 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 f7abe0a210..c8df031ec7 100644 --- a/src/heap.cc +++ b/src/heap.cc @@ -284,10 +284,10 @@ Heap::Heap(size_t initial_size, size_t growth_limit, size_t min_free, size_t max // 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 79cc835471..8bed7e3175 100644 --- a/src/heap_test.cc +++ b/src/heap_test.cc @@ -57,7 +57,7 @@ TEST_F(HeapTest, GarbageCollectClassLinkerInit) { 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 dc19d72cca..e21ff72d57 100644 --- a/src/image_writer.cc +++ b/src/image_writer.cc @@ -143,7 +143,7 @@ bool ImageWriter::AllocMemory() { 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 32f05305b5..a7fb5c4d73 100644 --- a/src/mem_map.cc +++ b/src/mem_map.cc @@ -73,7 +73,11 @@ MemMap* MemMap::MapAnonymous(const char* name, byte* addr, size_t byte_count, in 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 << ")"; |