Commit 0fecb303 authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

cppgc: Fix reporting of marked bytes in the atomic pause

The atomic pause would not report any marked bytes which in turn would
mean that the used bytes counter would stay at 0 for testing GCs that
always use atomic marking.

Bug: chromium:1056170
Change-Id: Ie35d9b3bc88766c4ef56271f05d944f4835ba431
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2704662
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarOmer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72850}
parent 15891111
......@@ -23,10 +23,9 @@ void IncrementalMarkingSchedule::NotifyIncrementalMarkingStart() {
incremental_marking_start_time_ = v8::base::TimeTicks::Now();
}
void IncrementalMarkingSchedule::UpdateIncrementalMarkedBytes(
void IncrementalMarkingSchedule::UpdateMutatorThreadMarkedBytes(
size_t overall_marked_bytes) {
DCHECK(!incremental_marking_start_time_.IsNull());
incrementally_marked_bytes_ = overall_marked_bytes;
mutator_thread_marked_bytes_ = overall_marked_bytes;
}
void IncrementalMarkingSchedule::AddConcurrentlyMarkedBytes(
......@@ -36,7 +35,7 @@ void IncrementalMarkingSchedule::AddConcurrentlyMarkedBytes(
}
size_t IncrementalMarkingSchedule::GetOverallMarkedBytes() const {
return incrementally_marked_bytes_ + GetConcurrentlyMarkedBytes();
return mutator_thread_marked_bytes_ + GetConcurrentlyMarkedBytes();
}
size_t IncrementalMarkingSchedule::GetConcurrentlyMarkedBytes() const {
......
......@@ -23,7 +23,7 @@ class V8_EXPORT_PRIVATE IncrementalMarkingSchedule {
void NotifyIncrementalMarkingStart();
void UpdateIncrementalMarkedBytes(size_t);
void UpdateMutatorThreadMarkedBytes(size_t);
void AddConcurrentlyMarkedBytes(size_t);
size_t GetOverallMarkedBytes() const;
......@@ -42,7 +42,7 @@ class V8_EXPORT_PRIVATE IncrementalMarkingSchedule {
v8::base::TimeTicks incremental_marking_start_time_;
size_t incrementally_marked_bytes_ = 0;
size_t mutator_thread_marked_bytes_ = 0;
std::atomic_size_t concurrently_marked_bytes_{0};
// Using -1 as sentinel to denote
......
......@@ -376,8 +376,7 @@ bool MarkerBase::AdvanceMarkingWithLimits(v8::base::TimeDelta max_duration,
size_t marked_bytes_limit) {
bool is_done = false;
if (!main_marking_disabled_for_testing_) {
const bool with_schedule = marked_bytes_limit == 0;
if (with_schedule) {
if (marked_bytes_limit == 0) {
marked_bytes_limit = mutator_marking_state_.marked_bytes() +
GetNextIncrementalStepDuration(schedule_, heap_);
}
......@@ -387,10 +386,8 @@ bool MarkerBase::AdvanceMarkingWithLimits(v8::base::TimeDelta max_duration,
max_duration.InMillisecondsF());
is_done = ProcessWorklistsWithDeadline(
marked_bytes_limit, v8::base::TimeTicks::Now() + max_duration);
if (with_schedule) {
schedule_.UpdateIncrementalMarkedBytes(
mutator_marking_state_.marked_bytes());
}
schedule_.UpdateMutatorThreadMarkedBytes(
mutator_marking_state_.marked_bytes());
}
mutator_marking_state_.Publish();
if (!is_done) {
......
......@@ -38,7 +38,7 @@ TEST_F(IncrementalMarkingScheduleTest, NoTimePassedReturnsMinimumDuration) {
IncrementalMarkingSchedule schedule;
schedule.NotifyIncrementalMarkingStart();
// Add incrementally marked bytes to tell oracle this is not the first step.
schedule.UpdateIncrementalMarkedBytes(
schedule.UpdateMutatorThreadMarkedBytes(
IncrementalMarkingSchedule::kMinimumMarkedBytesPerIncrementalStep);
schedule.SetElapsedTimeForTesting(0);
EXPECT_EQ(IncrementalMarkingSchedule::kMinimumMarkedBytesPerIncrementalStep,
......@@ -50,7 +50,7 @@ TEST_F(IncrementalMarkingScheduleTest, OracleDoesntExccedMaximumStepDuration) {
schedule.NotifyIncrementalMarkingStart();
// Add incrementally marked bytes to tell oracle this is not the first step.
static constexpr size_t kMarkedBytes = 1;
schedule.UpdateIncrementalMarkedBytes(kMarkedBytes);
schedule.UpdateMutatorThreadMarkedBytes(kMarkedBytes);
schedule.SetElapsedTimeForTesting(
IncrementalMarkingSchedule::kEstimatedMarkingTimeMs);
EXPECT_EQ(kObjectSize - kMarkedBytes,
......@@ -61,7 +61,7 @@ TEST_F(IncrementalMarkingScheduleTest, AheadOfScheduleReturnsMinimumDuration) {
IncrementalMarkingSchedule schedule;
schedule.NotifyIncrementalMarkingStart();
// Add incrementally marked bytes to tell oracle this is not the first step.
schedule.UpdateIncrementalMarkedBytes(
schedule.UpdateMutatorThreadMarkedBytes(
IncrementalMarkingSchedule::kMinimumMarkedBytesPerIncrementalStep);
schedule.AddConcurrentlyMarkedBytes(0.6 * kObjectSize);
schedule.SetElapsedTimeForTesting(
......@@ -73,7 +73,7 @@ TEST_F(IncrementalMarkingScheduleTest, AheadOfScheduleReturnsMinimumDuration) {
TEST_F(IncrementalMarkingScheduleTest, BehindScheduleReturnsCorrectDuration) {
IncrementalMarkingSchedule schedule;
schedule.NotifyIncrementalMarkingStart();
schedule.UpdateIncrementalMarkedBytes(0.1 * kObjectSize);
schedule.UpdateMutatorThreadMarkedBytes(0.1 * kObjectSize);
schedule.AddConcurrentlyMarkedBytes(0.25 * kObjectSize);
schedule.SetElapsedTimeForTesting(
0.5 * IncrementalMarkingSchedule::kEstimatedMarkingTimeMs);
......
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