[heap] Add accounting for committed memory of the Unmapper.

Change-Id: I26c2ba8d22aecac0e1d6a406eb90521ff52e1ec4
Reviewed-on: https://chromium-review.googlesource.com/1097119
Commit-Queue: Hannes Payer <hpayer@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53689}
This commit is contained in:
Hannes Payer 2018-06-13 10:12:24 +02:00 committed by Commit Bot
parent 7ebbda48bb
commit 3f84955bc6
4 changed files with 31 additions and 0 deletions

View File

@ -290,6 +290,13 @@ size_t Heap::CommittedOldGenerationMemory() {
return total + lo_space_->Size();
}
size_t Heap::CommittedMemoryOfHeapAndUnmapper() {
if (!HasBeenSetUp()) return 0;
return CommittedMemory() +
memory_allocator()->unmapper()->CommittedBufferedMemory();
}
size_t Heap::CommittedMemory() {
if (!HasBeenSetUp()) return 0;
@ -439,6 +446,10 @@ void Heap::PrintShortHeapStatistics() {
", committed: %6" PRIuS " KB\n",
lo_space_->SizeOfObjects() / KB, lo_space_->Available() / KB,
lo_space_->CommittedMemory() / KB);
PrintIsolate(isolate_,
"Unmapper buffering %d chunks of committed: %6" PRIuS " KB\n",
memory_allocator()->unmapper()->NumberOfChunks(),
CommittedMemoryOfHeapAndUnmapper() / KB);
PrintIsolate(isolate_, "All spaces, used: %6" PRIuS
" KB"
", available: %6" PRIuS

View File

@ -1451,6 +1451,10 @@ class Heap {
// Returns the capacity of the old generation.
size_t OldGenerationCapacity();
// Returns the amount of memory currently committed for the heap and memory
// held alive by the unmapper.
size_t CommittedMemoryOfHeapAndUnmapper();
// Returns the amount of memory currently committed for the heap.
size_t CommittedMemory();

View File

@ -439,6 +439,21 @@ int MemoryAllocator::Unmapper::NumberOfChunks() {
return static_cast<int>(result);
}
size_t MemoryAllocator::Unmapper::CommittedBufferedMemory() {
base::LockGuard<base::Mutex> guard(&mutex_);
size_t sum = 0;
// kPooled chunks are already uncommited. We only have to account for
// kRegular and kNonRegular chunks.
for (auto& chunk : chunks_[kRegular]) {
sum += chunk->size();
}
for (auto& chunk : chunks_[kNonRegular]) {
sum += chunk->size();
}
return sum;
}
bool MemoryAllocator::CommitMemory(Address base, size_t size) {
if (!SetPermissions(base, size, PageAllocator::kReadWrite)) {
return false;

View File

@ -1210,6 +1210,7 @@ class V8_EXPORT_PRIVATE MemoryAllocator {
void EnsureUnmappingCompleted();
void TearDown();
int NumberOfChunks();
size_t CommittedBufferedMemory();
private:
static const int kReservedQueueingSlots = 64;