Commit 7e981924 authored by Dominik Inführ's avatar Dominik Inführ Committed by V8 LUCI CQ

[heap] Remove StepResult used for incremental marking

FastForwardSchedule() was the only operation left which need the
StepResult. However, we can also invoke that method from
AdvanceOnAllocation(). That way we can remove all uses of StepResult.

Bug: v8:12775
Change-Id: If91d76906f0f75342abce1456ea7d4a6fe089bee
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3843142
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82639}
parent a3e62593
......@@ -450,11 +450,11 @@ void IncrementalMarking::UpdateMarkedBytesAfterScavenge(
bytes_marked_ -= std::min(bytes_marked_, dead_bytes_in_new_space);
}
StepResult IncrementalMarking::EmbedderStep(double expected_duration_ms,
double* duration_ms) {
void IncrementalMarking::EmbedderStep(double expected_duration_ms,
double* duration_ms) {
if (!ShouldDoEmbedderStep()) {
*duration_ms = 0.0;
return StepResult::kNoImmediateWork;
return;
}
constexpr size_t kObjectsToProcessBeforeDeadlineCheck = 500;
......@@ -485,14 +485,10 @@ StepResult IncrementalMarking::EmbedderStep(double expected_duration_ms,
// |deadline - heap_->MonotonicallyIncreasingTimeInMs()| could be negative,
// which means |local_tracer| won't do any actual tracing, so there is no
// need to check for |deadline <= heap_->MonotonicallyIncreasingTimeInMs()|.
bool remote_tracing_done =
local_tracer->Trace(deadline - heap_->MonotonicallyIncreasingTimeInMs());
local_tracer->Trace(deadline - heap_->MonotonicallyIncreasingTimeInMs());
double current = heap_->MonotonicallyIncreasingTimeInMs();
local_tracer->SetEmbedderWorklistEmpty(empty_worklist);
*duration_ms = current - start;
return (empty_worklist && remote_tracing_done)
? StepResult::kNoImmediateWork
: StepResult::kMoreWorkRemaining;
}
bool IncrementalMarking::Stop() {
......@@ -692,8 +688,10 @@ void IncrementalMarking::AdvanceOnAllocation() {
Step(kMaxStepSizeInMs, StepOrigin::kV8);
if (IsComplete()) {
// Marking cannot be finalized here. Schedule a completion task instead.
// TODO(v8:12775): Try to remove.
FastForwardSchedule();
// Marking cannot be finalized here. Schedule a completion task instead.
if (!ShouldWaitForTask()) {
// When task isn't run soon enough, fall back to stack guard to force
// completion.
......@@ -854,10 +852,6 @@ void IncrementalMarking::Step(double max_step_size_in_ms,
// processed on their own. For small graphs, helping is not necessary.
std::tie(v8_bytes_processed, std::ignore) =
collector_->ProcessMarkingWorklist(bytes_to_process);
StepResult v8_result = local_marking_worklists()->IsEmpty()
? StepResult::kNoImmediateWork
: StepResult::kMoreWorkRemaining;
StepResult embedder_result = StepResult::kNoImmediateWork;
if (heap_->local_embedder_heap_tracer()->InUse()) {
embedder_deadline =
std::min(max_step_size_in_ms,
......@@ -865,16 +859,10 @@ void IncrementalMarking::Step(double max_step_size_in_ms,
// TODO(chromium:1056170): Replace embedder_deadline with bytes_to_process
// after migrating blink to the cppgc library and after v8 can directly
// push objects to Oilpan.
embedder_result = EmbedderStep(embedder_deadline, &embedder_duration);
EmbedderStep(embedder_deadline, &embedder_duration);
}
bytes_marked_ += v8_bytes_processed;
if (v8_result == StepResult::kNoImmediateWork &&
embedder_result == StepResult::kNoImmediateWork) {
// TODO(v8:12775): Try to remove.
FastForwardSchedule();
}
if (FLAG_concurrent_marking) {
local_marking_worklists()->ShareWork();
heap_->concurrent_marking()->RescheduleJobIfNeeded();
......
......@@ -35,11 +35,6 @@ enum class StepOrigin {
kTask
};
enum class StepResult {
kNoImmediateWork,
kMoreWorkRemaining,
};
class V8_EXPORT_PRIVATE IncrementalMarking final {
public:
class V8_NODISCARD PauseBlackAllocationScope {
......@@ -179,7 +174,7 @@ class V8_EXPORT_PRIVATE IncrementalMarking final {
void StartMarking();
bool ShouldDoEmbedderStep();
StepResult EmbedderStep(double expected_duration_ms, double* duration_ms);
void EmbedderStep(double expected_duration_ms, double* duration_ms);
void StartBlackAllocation();
void PauseBlackAllocation();
......
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