diff --git a/src/heap/heap.cc b/src/heap/heap.cc index f329929535..22ac69295f 100644 --- a/src/heap/heap.cc +++ b/src/heap/heap.cc @@ -5414,8 +5414,10 @@ Heap::IncrementalMarkingLimit Heap::IncrementalMarkingLimitReached() { max_marking_limit_reached_ = std::max(max_marking_limit_reached_, current_percent); } - } else if (current_percent >= stress_marking_percentage_) { - stress_marking_percentage_ = NextStressMarkingLimit(); + } else if (current_percent >= + stress_marking_percentage_.load(std::memory_order_relaxed)) { + stress_marking_percentage_.store(NextStressMarkingLimit(), + std::memory_order_relaxed); return IncrementalMarkingLimit::kHardLimit; } } diff --git a/src/heap/heap.h b/src/heap/heap.h index cd1e4fa4a3..ceb6e9d05c 100644 --- a/src/heap/heap.h +++ b/src/heap/heap.h @@ -2290,10 +2290,10 @@ class Heap { // Starts marking when stress_marking_percentage_% of the marking start limit // is reached. - int stress_marking_percentage_ = 0; + std::atomic stress_marking_percentage_{0}; - // Observer that causes more frequent checks for reached incremental marking - // limit. + // Observer that causes more frequent checks for reached incremental + // marking limit. AllocationObserver* stress_marking_observer_ = nullptr; // Observer that can cause early scavenge start.