Commit 6d32126c authored by mlippautz's avatar mlippautz Committed by Commit bot

[heap] Make committed counters on space size_t

BUG=

Review-Url: https://codereview.chromium.org/2371133002
Cr-Commit-Position: refs/heads/master@{#39811}
parent 990a8e39
......@@ -120,16 +120,20 @@ void StatisticsExtension::GetCounters(
{heap->memory_allocator()->Size(), "total_committed_bytes"},
{heap->new_space()->Size(), "new_space_live_bytes"},
{heap->new_space()->Available(), "new_space_available_bytes"},
{heap->new_space()->CommittedMemory(), "new_space_commited_bytes"},
{static_cast<intptr_t>(heap->new_space()->CommittedMemory()),
"new_space_commited_bytes"},
{heap->old_space()->Size(), "old_space_live_bytes"},
{heap->old_space()->Available(), "old_space_available_bytes"},
{heap->old_space()->CommittedMemory(), "old_space_commited_bytes"},
{static_cast<intptr_t>(heap->old_space()->CommittedMemory()),
"old_space_commited_bytes"},
{heap->code_space()->Size(), "code_space_live_bytes"},
{heap->code_space()->Available(), "code_space_available_bytes"},
{heap->code_space()->CommittedMemory(), "code_space_commited_bytes"},
{static_cast<intptr_t>(heap->code_space()->CommittedMemory()),
"code_space_commited_bytes"},
{heap->lo_space()->Size(), "lo_space_live_bytes"},
{heap->lo_space()->Available(), "lo_space_available_bytes"},
{heap->lo_space()->CommittedMemory(), "lo_space_commited_bytes"},
{static_cast<intptr_t>(heap->lo_space()->CommittedMemory()),
"lo_space_commited_bytes"},
};
for (size_t i = 0; i < arraysize(numbers); i++) {
......
......@@ -192,16 +192,14 @@ intptr_t Heap::OldGenerationCapacity() {
map_space_->Capacity() + lo_space_->SizeOfObjects();
}
intptr_t Heap::CommittedOldGenerationMemory() {
size_t Heap::CommittedOldGenerationMemory() {
if (!HasBeenSetUp()) return 0;
return old_space_->CommittedMemory() + code_space_->CommittedMemory() +
map_space_->CommittedMemory() + lo_space_->Size();
}
intptr_t Heap::CommittedMemory() {
size_t Heap::CommittedMemory() {
if (!HasBeenSetUp()) return 0;
return new_space_->CommittedMemory() + CommittedOldGenerationMemory();
......@@ -218,18 +216,17 @@ size_t Heap::CommittedPhysicalMemory() {
lo_space_->CommittedPhysicalMemory();
}
intptr_t Heap::CommittedMemoryExecutable() {
size_t Heap::CommittedMemoryExecutable() {
if (!HasBeenSetUp()) return 0;
return memory_allocator()->SizeExecutable();
return static_cast<size_t>(memory_allocator()->SizeExecutable());
}
void Heap::UpdateMaximumCommitted() {
if (!HasBeenSetUp()) return;
intptr_t current_committed_memory = CommittedMemory();
const size_t current_committed_memory = CommittedMemory();
if (current_committed_memory > maximum_committed_) {
maximum_committed_ = current_committed_memory;
}
......@@ -332,42 +329,42 @@ void Heap::PrintShortHeapStatistics() {
" KB"
", available: %6" V8PRIdPTR
" KB"
", committed: %6" V8PRIdPTR " KB\n",
", committed: %6zu KB\n",
new_space_->Size() / KB, new_space_->Available() / KB,
new_space_->CommittedMemory() / KB);
PrintIsolate(isolate_, "Old space, used: %6" V8PRIdPTR
" KB"
", available: %6" V8PRIdPTR
" KB"
", committed: %6" V8PRIdPTR " KB\n",
", committed: %6zu KB\n",
old_space_->SizeOfObjects() / KB, old_space_->Available() / KB,
old_space_->CommittedMemory() / KB);
PrintIsolate(isolate_, "Code space, used: %6" V8PRIdPTR
" KB"
", available: %6" V8PRIdPTR
" KB"
", committed: %6" V8PRIdPTR " KB\n",
", committed: %6zu KB\n",
code_space_->SizeOfObjects() / KB, code_space_->Available() / KB,
code_space_->CommittedMemory() / KB);
PrintIsolate(isolate_, "Map space, used: %6" V8PRIdPTR
" KB"
", available: %6" V8PRIdPTR
" KB"
", committed: %6" V8PRIdPTR " KB\n",
", committed: %6zu KB\n",
map_space_->SizeOfObjects() / KB, map_space_->Available() / KB,
map_space_->CommittedMemory() / KB);
PrintIsolate(isolate_, "Large object space, used: %6" V8PRIdPTR
" KB"
", available: %6" V8PRIdPTR
" KB"
", committed: %6" V8PRIdPTR " KB\n",
", committed: %6zu KB\n",
lo_space_->SizeOfObjects() / KB, lo_space_->Available() / KB,
lo_space_->CommittedMemory() / KB);
PrintIsolate(isolate_, "All spaces, used: %6" V8PRIdPTR
" KB"
", available: %6" V8PRIdPTR
" KB"
", committed: %6" V8PRIdPTR " KB\n",
", committed: %6zu KB\n",
this->SizeOfObjects() / KB, this->Available() / KB,
this->CommittedMemory() / KB);
PrintIsolate(isolate_, "External memory reported: %6" V8PRIdPTR " KB\n",
......@@ -1309,7 +1306,7 @@ bool Heap::PerformGarbageCollection(
EnsureFromSpaceIsCommitted();
int start_new_space_size = Heap::new_space()->SizeAsInt();
int start_new_space_size = static_cast<int>(Heap::new_space()->Size());
if (IsHighSurvivalRate()) {
// We speed up the incremental marker if it is running so that it
......@@ -5167,7 +5164,7 @@ bool Heap::ConfigureHeapDefault() { return ConfigureHeap(0, 0, 0, 0); }
void Heap::RecordStats(HeapStats* stats, bool take_snapshot) {
*stats->start_marker = HeapStats::kStartMarker;
*stats->end_marker = HeapStats::kEndMarker;
*stats->new_space_size = new_space_->SizeAsInt();
*stats->new_space_size = new_space_->Size();
*stats->new_space_capacity = new_space_->Capacity();
*stats->old_space_size = old_space_->SizeOfObjects();
*stats->old_space_capacity = old_space_->Capacity();
......
......@@ -1295,19 +1295,19 @@ class Heap {
intptr_t OldGenerationCapacity();
// Returns the amount of memory currently committed for the heap.
intptr_t CommittedMemory();
size_t CommittedMemory();
// Returns the amount of memory currently committed for the old space.
intptr_t CommittedOldGenerationMemory();
size_t CommittedOldGenerationMemory();
// Returns the amount of executable memory currently committed for the heap.
intptr_t CommittedMemoryExecutable();
size_t CommittedMemoryExecutable();
// Returns the amount of phyical memory currently committed for the heap.
size_t CommittedPhysicalMemory();
// Returns the maximum amount of memory ever committed for the heap.
intptr_t MaximumCommittedMemory() { return maximum_committed_; }
size_t MaximumCommittedMemory() { return maximum_committed_; }
// Updates the maximum committed memory for the heap. Should be called
// whenever a space grows.
......@@ -2088,7 +2088,7 @@ class Heap {
intptr_t initial_old_generation_size_;
bool old_generation_size_configured_;
intptr_t max_executable_size_;
intptr_t maximum_committed_;
size_t maximum_committed_;
// For keeping track of how much data has survived
// scavenge since last new space expansion.
......
......@@ -1319,7 +1319,7 @@ bool PagedSpace::Expand() {
Page* p = heap()->memory_allocator()->AllocatePage(size, this, executable());
if (p == nullptr) return false;
AccountCommitted(static_cast<intptr_t>(p->size()));
AccountCommitted(p->size());
// Pages created during bootstrapping may contain immortal immovable objects.
if (!heap()->deserialization_complete()) p->MarkNeverEvacuate();
......@@ -1426,7 +1426,7 @@ void PagedSpace::ReleasePage(Page* page) {
page->Unlink();
}
AccountUncommitted(static_cast<intptr_t>(page->size()));
AccountUncommitted(page->size());
accounting_stats_.ShrinkSpace(page->area_size());
heap()->memory_allocator()->Free<MemoryAllocator::kPreFreeAndQueue>(page);
}
......@@ -1556,7 +1556,7 @@ void NewSpace::Grow() {
void NewSpace::Shrink() {
int new_capacity = Max(InitialTotalCapacity(), 2 * SizeAsInt());
int new_capacity = Max(InitialTotalCapacity(), 2 * static_cast<int>(Size()));
int rounded_new_capacity = RoundUp(new_capacity, Page::kPageSize);
if (rounded_new_capacity < TotalCapacity() &&
to_space_.ShrinkTo(rounded_new_capacity)) {
......@@ -1987,7 +1987,7 @@ bool SemiSpace::GrowTo(int new_capacity) {
new_page->SetFlags(last_page->GetFlags(), Page::kCopyOnFlipFlagsMask);
last_page = new_page;
}
AccountCommitted(static_cast<intptr_t>(delta));
AccountCommitted(delta);
current_capacity_ = new_capacity;
return true;
}
......@@ -2024,7 +2024,7 @@ bool SemiSpace::ShrinkTo(int new_capacity) {
last_page);
delta_pages--;
}
AccountUncommitted(static_cast<intptr_t>(delta));
AccountUncommitted(delta);
heap()->memory_allocator()->unmapper()->FreeQueuedChunks();
}
current_capacity_ = new_capacity;
......@@ -3025,7 +3025,7 @@ AllocationResult LargeObjectSpace::AllocateRaw(int object_size,
DCHECK(page->area_size() >= object_size);
size_ += static_cast<int>(page->size());
AccountCommitted(static_cast<intptr_t>(page->size()));
AccountCommitted(page->size());
objects_size_ += object_size;
page_count_++;
page->set_next_page(first_page_);
......@@ -3162,7 +3162,7 @@ void LargeObjectSpace::FreeUnmarkedObjects() {
// Free the chunk.
size_ -= static_cast<int>(page->size());
AccountUncommitted(static_cast<intptr_t>(page->size()));
AccountUncommitted(page->size());
objects_size_ -= object->Size();
page_count_--;
......
......@@ -918,9 +918,9 @@ class Space : public Malloced {
// Return the total amount committed memory for this space, i.e., allocatable
// memory and page headers.
virtual intptr_t CommittedMemory() { return committed_; }
virtual size_t CommittedMemory() { return committed_; }
virtual intptr_t MaximumCommittedMemory() { return max_committed_; }
virtual size_t MaximumCommittedMemory() { return max_committed_; }
// Returns allocated size.
virtual intptr_t Size() = 0;
......@@ -945,18 +945,17 @@ class Space : public Malloced {
virtual std::unique_ptr<ObjectIterator> GetObjectIterator() = 0;
void AccountCommitted(intptr_t bytes) {
DCHECK_GE(bytes, 0);
void AccountCommitted(size_t bytes) {
DCHECK_GE(committed_ + bytes, committed_);
committed_ += bytes;
if (committed_ > max_committed_) {
max_committed_ = committed_;
}
}
void AccountUncommitted(intptr_t bytes) {
DCHECK_GE(bytes, 0);
void AccountUncommitted(size_t bytes) {
DCHECK_GE(committed_, committed_ - bytes);
committed_ -= bytes;
DCHECK_GE(committed_, 0);
}
#ifdef DEBUG
......@@ -973,8 +972,8 @@ class Space : public Malloced {
Executability executable_;
// Keeps track of committed memory in a space.
intptr_t committed_;
intptr_t max_committed_;
size_t committed_;
size_t max_committed_;
DISALLOW_COPY_AND_ASSIGN(Space);
};
......@@ -2461,11 +2460,6 @@ class NewSpace : public Space {
static_cast<intptr_t>(fragmentation_in_intermediate_generation_);
}
// The same, but returning an int. We have to have the one that returns
// intptr_t because it is inherited, but if we know we are dealing with the
// new space, which can't get as big as the other spaces then this is useful:
int SizeAsInt() { return static_cast<int>(Size()); }
// Return the allocatable capacity of a semispace.
intptr_t Capacity() {
SLOW_DCHECK(to_space_.current_capacity() == from_space_.current_capacity());
......@@ -2482,11 +2476,11 @@ class NewSpace : public Space {
// Committed memory for NewSpace is the committed memory of both semi-spaces
// combined.
intptr_t CommittedMemory() override {
size_t CommittedMemory() override {
return from_space_.CommittedMemory() + to_space_.CommittedMemory();
}
intptr_t MaximumCommittedMemory() override {
size_t MaximumCommittedMemory() override {
return from_space_.MaximumCommittedMemory() +
to_space_.MaximumCommittedMemory();
}
......
......@@ -515,8 +515,7 @@ TEST(SizeOfInitialHeap) {
page_count[i] = heap->paged_space(i)->CountTotalPages();
// Check that the initial heap is also below the limit.
CHECK_LT(static_cast<size_t>(heap->paged_space(i)->CommittedMemory()),
kMaxInitialSizePerSpace);
CHECK_LT(heap->paged_space(i)->CommittedMemory(), kMaxInitialSizePerSpace);
}
// Executing the empty script gets by with the same number of pages, i.e.,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment