Commit bd89a2eb authored by hpayer's avatar hpayer Committed by Commit bot

Respect accumulative old generation memory limit in all spaces.

Before the max_old_space_size was set for each space, which is not intuitive and not what we want. There is still a miss match between capacity and actual committed memory which should be cleaned up in a follow up cl.

BUG=

Review URL: https://codereview.chromium.org/979783002

Cr-Commit-Position: refs/heads/master@{#26985}
parent ce785b56
...@@ -177,16 +177,23 @@ intptr_t Heap::Capacity() { ...@@ -177,16 +177,23 @@ intptr_t Heap::Capacity() {
} }
intptr_t Heap::CommittedMemory() { intptr_t Heap::CommittedOldGenerationMemory() {
if (!HasBeenSetUp()) return 0; if (!HasBeenSetUp()) return 0;
return new_space_.CommittedMemory() + old_pointer_space_->CommittedMemory() + return old_pointer_space_->CommittedMemory() +
old_data_space_->CommittedMemory() + code_space_->CommittedMemory() + old_data_space_->CommittedMemory() + code_space_->CommittedMemory() +
map_space_->CommittedMemory() + cell_space_->CommittedMemory() + map_space_->CommittedMemory() + cell_space_->CommittedMemory() +
property_cell_space_->CommittedMemory() + lo_space_->Size(); property_cell_space_->CommittedMemory() + lo_space_->Size();
} }
intptr_t Heap::CommittedMemory() {
if (!HasBeenSetUp()) return 0;
return new_space_.CommittedMemory() + CommittedOldGenerationMemory();
}
size_t Heap::CommittedPhysicalMemory() { size_t Heap::CommittedPhysicalMemory() {
if (!HasBeenSetUp()) return 0; if (!HasBeenSetUp()) return 0;
......
...@@ -607,6 +607,9 @@ class Heap { ...@@ -607,6 +607,9 @@ class Heap {
// Returns the amount of memory currently committed for the heap. // Returns the amount of memory currently committed for the heap.
intptr_t CommittedMemory(); intptr_t CommittedMemory();
// Returns the amount of memory currently committed for the old space.
intptr_t CommittedOldGenerationMemory();
// Returns the amount of executable memory currently committed for the heap. // Returns the amount of executable memory currently committed for the heap.
intptr_t CommittedMemoryExecutable(); intptr_t CommittedMemoryExecutable();
...@@ -690,6 +693,12 @@ class Heap { ...@@ -690,6 +693,12 @@ class Heap {
return old_data_space_->allocation_limit_address(); return old_data_space_->allocation_limit_address();
} }
// TODO(hpayer): There is still a missmatch between capacity and actual
// committed memory size.
bool CanExpandOldGeneration(int size) {
return (CommittedOldGenerationMemory() + size) < MaxOldGenerationSize();
}
// Returns a deep copy of the JavaScript object. // Returns a deep copy of the JavaScript object.
// Properties and elements are copied too. // Properties and elements are copied too.
// Optionally takes an AllocationSite to be appended in an AllocationMemento. // Optionally takes an AllocationSite to be appended in an AllocationMemento.
......
...@@ -1021,13 +1021,12 @@ Object* PagedSpace::FindObject(Address addr) { ...@@ -1021,13 +1021,12 @@ Object* PagedSpace::FindObject(Address addr) {
bool PagedSpace::CanExpand() { bool PagedSpace::CanExpand() {
DCHECK(max_capacity_ % AreaSize() == 0); DCHECK(max_capacity_ % AreaSize() == 0);
DCHECK(Capacity() <= heap()->MaxOldGenerationSize());
if (Capacity() == max_capacity_) return false; DCHECK(heap()->CommittedOldGenerationMemory() <=
heap()->MaxOldGenerationSize());
DCHECK(Capacity() < max_capacity_);
// Are we going to exceed capacity for this space? // Are we going to exceed capacity for this space?
if ((Capacity() + Page::kPageSize) > max_capacity_) return false; if (!heap()->CanExpandOldGeneration(Page::kPageSize)) return false;
return true; return true;
} }
...@@ -1049,7 +1048,9 @@ bool PagedSpace::Expand() { ...@@ -1049,7 +1048,9 @@ bool PagedSpace::Expand() {
// Pages created during bootstrapping may contain immortal immovable objects. // Pages created during bootstrapping may contain immortal immovable objects.
if (!heap()->deserialization_complete()) p->MarkNeverEvacuate(); if (!heap()->deserialization_complete()) p->MarkNeverEvacuate();
DCHECK(Capacity() <= max_capacity_); DCHECK(Capacity() <= heap()->MaxOldGenerationSize());
DCHECK(heap()->CommittedOldGenerationMemory() <=
heap()->MaxOldGenerationSize());
p->InsertAfter(anchor_.prev_page()); p->InsertAfter(anchor_.prev_page());
......
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