Commit 1f330e39 authored by Dominik Inführ's avatar Dominik Inführ Committed by Commit Bot

[heap] Increase gc_count_ in safepoint

Incrementing gc_count_ races with
Heap::IncrementalMarkingLimitReached(), which starts incremental marking
immediately on every second GC.

Bug: v8:10315
Change-Id: Ieb1126bb4ecc472afe5fdd023a601d753576752e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2346648Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69320}
parent aa50e53b
......@@ -423,7 +423,7 @@ GarbageCollector Heap::SelectGarbageCollector(AllocationSpace space,
return MARK_COMPACTOR;
}
if (FLAG_gc_global || (FLAG_stress_compaction && (gc_count_ & 1) != 0)) {
if (FLAG_gc_global || ShouldStressCompaction()) {
*reason = "GC in old space forced by flags";
return MARK_COMPACTOR;
}
......@@ -817,10 +817,6 @@ bool Heap::UncommitFromSpace() { return new_space_->UncommitFromSpace(); }
void Heap::GarbageCollectionPrologue() {
TRACE_GC(tracer(), GCTracer::Scope::HEAP_PROLOGUE);
{
AllowHeapAllocation for_the_first_part_of_prologue;
gc_count_++;
}
// Reset GC statistics.
promoted_objects_size_ = 0;
......@@ -852,6 +848,8 @@ void Heap::GarbageCollectionPrologue() {
}
void Heap::GarbageCollectionPrologueInSafepoint() {
gc_count_++;
UpdateNewSpaceAllocationCounter();
CheckNewSpaceExpansionCriteria();
}
......@@ -5042,8 +5040,7 @@ Heap::IncrementalMarkingLimit Heap::IncrementalMarkingLimitReached() {
// Incremental marking is disabled or it is too early to start.
return IncrementalMarkingLimit::kNoLimit;
}
if ((FLAG_stress_compaction && (gc_count_ & 1) != 0) ||
HighMemoryPressure()) {
if (ShouldStressCompaction() || HighMemoryPressure()) {
// If there is high memory pressure or stress testing is enabled, then
// start marking immediately.
return IncrementalMarkingLimit::kHardLimit;
......@@ -5110,6 +5107,10 @@ Heap::IncrementalMarkingLimit Heap::IncrementalMarkingLimitReached() {
return IncrementalMarkingLimit::kSoftLimit;
}
bool Heap::ShouldStressCompaction() const {
return FLAG_stress_compaction && (gc_count_ & 1) != 0;
}
void Heap::EnableInlineAllocation() {
if (!inline_allocation_disabled_) return;
inline_allocation_disabled_ = false;
......
......@@ -1867,6 +1867,8 @@ class Heap {
enum class IncrementalMarkingLimit { kNoLimit, kSoftLimit, kHardLimit };
IncrementalMarkingLimit IncrementalMarkingLimitReached();
bool ShouldStressCompaction() const;
bool UseGlobalMemoryScheduling() const {
return FLAG_global_gc_scheduling && local_embedder_heap_tracer();
}
......
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