Commit ca3e146e authored by Wez's avatar Wez Committed by Commit Bot

Rename PromotedSpaceSizeOfObjects() to OldGenerationSizeOfObjects().

The Promoted* prefix was used to refer both to the total number of old
generation objects, and to the delta of objects moved from the new to
old generations.

PromotedTotalSize() is also renamed, to reflect the actual calculation
it performs

Bug: chromium:837583
Change-Id: Id27a0661618257ef64eb469a83bb49c0e8ce6923
Reviewed-on: https://chromium-review.googlesource.com/1042314
Commit-Queue: Wez <wez@chromium.org>
Reviewed-by: 's avatarHannes Payer <hpayer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52986}
parent 56e8b099
......@@ -1399,7 +1399,7 @@ bool Heap::CollectGarbage(AllocationSpace space,
if (collector == MARK_COMPACTOR) {
size_t committed_memory_after = CommittedOldGenerationMemory();
size_t used_memory_after = PromotedSpaceSizeOfObjects();
size_t used_memory_after = OldGenerationSizeOfObjects();
MemoryReducer::Event event;
event.type = MemoryReducer::kMarkCompact;
event.time_ms = MonotonicallyIncreasingTimeInMs();
......@@ -1727,7 +1727,7 @@ bool Heap::PerformGarbageCollection(
// GC.
old_generation_allocation_counter_at_last_gc_ +=
static_cast<size_t>(promoted_objects_size_);
old_generation_size_at_last_gc_ = PromotedSpaceSizeOfObjects();
old_generation_size_at_last_gc_ = OldGenerationSizeOfObjects();
break;
case MINOR_MARK_COMPACTOR:
MinorMarkCompact();
......@@ -1784,7 +1784,7 @@ bool Heap::PerformGarbageCollection(
double gc_speed = tracer()->CombinedMarkCompactSpeedInBytesPerMillisecond();
double mutator_speed =
tracer()->CurrentOldGenerationAllocationThroughputInBytesPerMillisecond();
size_t old_gen_size = PromotedSpaceSizeOfObjects();
size_t old_gen_size = OldGenerationSizeOfObjects();
if (collector == MARK_COMPACTOR) {
// Register the amount of external allocated memory.
external_memory_at_last_mark_compact_ = external_memory_;
......@@ -3032,7 +3032,7 @@ void Heap::CheckIneffectiveMarkCompact(size_t old_generation_size,
}
bool Heap::HasHighFragmentation() {
size_t used = PromotedSpaceSizeOfObjects();
size_t used = OldGenerationSizeOfObjects();
size_t committed = CommittedOldGenerationMemory();
return HasHighFragmentation(used, committed);
}
......@@ -4206,7 +4206,7 @@ void Heap::RecordStats(HeapStats* stats, bool take_snapshot) {
}
}
size_t Heap::PromotedSpaceSizeOfObjects() {
size_t Heap::OldGenerationSizeOfObjects() {
PagedSpaces spaces(this, PagedSpaces::SpacesSpecifier::kAllPagedSpaces);
size_t total = 0;
for (PagedSpace* space = spaces.next(); space != nullptr;
......@@ -4439,7 +4439,7 @@ Heap::IncrementalMarkingLimit Heap::IncrementalMarkingLimitReached() {
if (FLAG_stress_incremental_marking) {
return IncrementalMarkingLimit::kHardLimit;
}
if (PromotedSpaceSizeOfObjects() <=
if (OldGenerationSizeOfObjects() <=
IncrementalMarking::kActivationThreshold) {
// Incremental marking is disabled or it is too early to start.
return IncrementalMarkingLimit::kNoLimit;
......@@ -4455,7 +4455,9 @@ Heap::IncrementalMarkingLimit Heap::IncrementalMarkingLimitReached() {
double gained_since_last_gc =
PromotedSinceLastGC() +
(external_memory_ - external_memory_at_last_mark_compact_);
double size_before_gc = PromotedTotalSize() - gained_since_last_gc;
double size_before_gc =
OldGenerationObjectsAndPromotedExternalMemorySize() -
gained_since_last_gc;
double bytes_to_limit = old_generation_allocation_limit_ - size_before_gc;
if (bytes_to_limit > 0) {
double current_percent = (gained_since_last_gc / bytes_to_limit) * 100.0;
......
......@@ -1517,8 +1517,8 @@ class Heap {
survived_since_last_expansion_ += survived;
}
inline uint64_t PromotedTotalSize() {
return PromotedSpaceSizeOfObjects() + PromotedExternalMemorySize();
inline uint64_t OldGenerationObjectsAndPromotedExternalMemorySize() {
return OldGenerationSizeOfObjects() + PromotedExternalMemorySize();
}
inline void UpdateNewSpaceAllocationCounter();
......@@ -1547,18 +1547,18 @@ class Heap {
}
size_t PromotedSinceLastGC() {
size_t old_generation_size = PromotedSpaceSizeOfObjects();
size_t old_generation_size = OldGenerationSizeOfObjects();
DCHECK_GE(old_generation_size, old_generation_size_at_last_gc_);
return old_generation_size - old_generation_size_at_last_gc_;
}
// This is called by the sweeper when it discovers more free space
// as expected at the end of the last GC.
// than expected at the end of the preceding GC.
void NotifyRefinedOldGenerationSize(size_t decreased_bytes) {
if (old_generation_size_at_last_gc_ != 0) {
// PromotedSpaceSizeOfObjects() is now smaller by |decreased_bytes|.
// Adjust old_generation_size_at_last_gc_ too so that PromotedSinceLastGC
// stay monotonically non-decreasing function.
// OldGenerationSizeOfObjects() is now smaller by |decreased_bytes|.
// Adjust old_generation_size_at_last_gc_ too, so that PromotedSinceLastGC
// continues to increase monotonically, rather than decreasing here.
DCHECK_GE(old_generation_size_at_last_gc_, decreased_bytes);
old_generation_size_at_last_gc_ -= decreased_bytes;
}
......@@ -1566,8 +1566,9 @@ class Heap {
int gc_count() const { return gc_count_; }
// Returns the size of objects residing in non new spaces.
size_t PromotedSpaceSizeOfObjects();
// Returns the size of objects residing in non-new spaces.
// Excludes external memory held by those objects.
size_t OldGenerationSizeOfObjects();
// ===========================================================================
// Prologue/epilogue callback methods.========================================
......@@ -2041,9 +2042,12 @@ class Heap {
// ===========================================================================
inline size_t OldGenerationSpaceAvailable() {
if (old_generation_allocation_limit_ <= PromotedTotalSize()) return 0;
if (old_generation_allocation_limit_ <=
OldGenerationObjectsAndPromotedExternalMemorySize())
return 0;
return old_generation_allocation_limit_ -
static_cast<size_t>(PromotedTotalSize());
static_cast<size_t>(
OldGenerationObjectsAndPromotedExternalMemorySize());
}
// We allow incremental marking to overshoot the allocation limit for
......@@ -2053,8 +2057,11 @@ class Heap {
// This guards against too eager finalization in small heaps.
// The number is chosen based on v8.browsing_mobile on Nexus 7v2.
size_t kMarginForSmallHeaps = 32u * MB;
if (old_generation_allocation_limit_ >= PromotedTotalSize()) return false;
uint64_t overshoot = PromotedTotalSize() - old_generation_allocation_limit_;
if (old_generation_allocation_limit_ >=
OldGenerationObjectsAndPromotedExternalMemorySize())
return false;
uint64_t overshoot = OldGenerationObjectsAndPromotedExternalMemorySize() -
old_generation_allocation_limit_;
// Overshoot margin is 50% of allocation limit or half-way to the max heap
// with special handling of small heaps.
uint64_t margin =
......
......@@ -324,7 +324,7 @@ void IncrementalMarking::Deactivate() {
void IncrementalMarking::Start(GarbageCollectionReason gc_reason) {
if (FLAG_trace_incremental_marking) {
int old_generation_size_mb =
static_cast<int>(heap()->PromotedSpaceSizeOfObjects() / MB);
static_cast<int>(heap()->OldGenerationSizeOfObjects() / MB);
int old_generation_limit_mb =
static_cast<int>(heap()->old_generation_allocation_limit() / MB);
heap()->isolate()->PrintWithTimestamp(
......@@ -350,7 +350,7 @@ void IncrementalMarking::Start(GarbageCollectionReason gc_reason) {
heap_->tracer()->NotifyIncrementalMarkingStart();
start_time_ms_ = heap()->MonotonicallyIncreasingTimeInMs();
initial_old_generation_size_ = heap_->PromotedSpaceSizeOfObjects();
initial_old_generation_size_ = heap_->OldGenerationSizeOfObjects();
old_generation_allocation_counter_ = heap_->OldGenerationAllocationCounter();
bytes_allocated_ = 0;
bytes_marked_ahead_of_schedule_ = 0;
......@@ -811,7 +811,7 @@ void IncrementalMarking::Stop() {
if (IsStopped()) return;
if (FLAG_trace_incremental_marking) {
int old_generation_size_mb =
static_cast<int>(heap()->PromotedSpaceSizeOfObjects() / MB);
static_cast<int>(heap()->OldGenerationSizeOfObjects() / MB);
int old_generation_limit_mb =
static_cast<int>(heap()->old_generation_allocation_limit() / MB);
heap()->isolate()->PrintWithTimestamp(
......@@ -960,7 +960,7 @@ size_t IncrementalMarking::StepSizeToMakeProgress() {
size_t oom_slack = heap()->new_space()->Capacity() + 64 * MB;
if (!heap()->CanExpandOldGeneration(oom_slack)) {
return heap()->PromotedSpaceSizeOfObjects() / kTargetStepCountAtOOM;
return heap()->OldGenerationSizeOfObjects() / kTargetStepCountAtOOM;
}
size_t step_size = Max(initial_old_generation_size_ / kTargetStepCount,
......
......@@ -5943,7 +5943,7 @@ UNINITIALIZED_TEST(OutOfMemoryIneffectiveGC) {
heap->CollectAllGarbage(Heap::kNoGCFlags, GarbageCollectionReason::kTesting);
{
HandleScope scope(i_isolate);
while (heap->PromotedSpaceSizeOfObjects() <
while (heap->OldGenerationSizeOfObjects() <
heap->MaxOldGenerationSize() * 0.9) {
factory->NewFixedArray(100, TENURED);
}
......
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