Commit 10ccf570 authored by Omer Katz's avatar Omer Katz Committed by Commit Bot

heap: Apply deadline to ThreadHeap::FlushV8References

Bug: 1056575
Change-Id: I3df2c9af1ee19becf4164d06ad210e81f29a4fea
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2078911Reviewed-by: default avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#745089}
parent 5c7bccda
...@@ -360,6 +360,10 @@ bool ThreadHeap::AdvanceMarking(MarkingVisitor* visitor, ...@@ -360,6 +360,10 @@ bool ThreadHeap::AdvanceMarking(MarkingVisitor* visitor,
break; break;
} }
finished = FlushV8References(deadline);
if (!finished)
break;
finished = DrainWorklistWithDeadline( finished = DrainWorklistWithDeadline(
deadline, marking_worklist_.get(), deadline, marking_worklist_.get(),
[visitor](const MarkingItem& item) { [visitor](const MarkingItem& item) {
...@@ -391,8 +395,6 @@ bool ThreadHeap::AdvanceMarking(MarkingVisitor* visitor, ...@@ -391,8 +395,6 @@ bool ThreadHeap::AdvanceMarking(MarkingVisitor* visitor,
// Rerun loop if ephemeron processing queued more objects for tracing. // Rerun loop if ephemeron processing queued more objects for tracing.
} while (!marking_worklist_->IsLocalViewEmpty(WorklistTaskId::MutatorThread)); } while (!marking_worklist_->IsLocalViewEmpty(WorklistTaskId::MutatorThread));
FlushV8References();
return finished; return finished;
} }
...@@ -609,26 +611,26 @@ bool ThreadHeap::AdvanceConcurrentSweep(base::JobDelegate* job) { ...@@ -609,26 +611,26 @@ bool ThreadHeap::AdvanceConcurrentSweep(base::JobDelegate* job) {
// TODO(omerkatz): Temporary solution until concurrent marking is ready. see // TODO(omerkatz): Temporary solution until concurrent marking is ready. see
// https://crrev.com/c/1730054 for details. Eventually this will be removed. // https://crrev.com/c/1730054 for details. Eventually this will be removed.
void ThreadHeap::FlushV8References() { bool ThreadHeap::FlushV8References(base::TimeTicks deadline) {
if (!thread_state_->IsUnifiedGCMarkingInProgress()) if (!thread_state_->IsUnifiedGCMarkingInProgress())
return; return true;
DCHECK(base::FeatureList::IsEnabled( DCHECK(base::FeatureList::IsEnabled(
blink::features::kBlinkHeapConcurrentMarking) || blink::features::kBlinkHeapConcurrentMarking) ||
v8_references_worklist_->IsGlobalEmpty()); v8_references_worklist_->IsGlobalEmpty());
V8ReferencesWorklist::View v8_references(v8_references_worklist_.get(),
WorklistTaskId::MutatorThread);
V8Reference reference;
v8::EmbedderHeapTracer* controller = v8::EmbedderHeapTracer* controller =
reinterpret_cast<v8::EmbedderHeapTracer*>( reinterpret_cast<v8::EmbedderHeapTracer*>(
thread_state_->unified_heap_controller()); thread_state_->unified_heap_controller());
while (v8_references.Pop(&reference)) { return DrainWorklistWithDeadline(
if (reference->Get().IsEmpty()) deadline, v8_references_worklist_.get(),
continue; [controller](const V8Reference& reference) {
controller->RegisterEmbedderReference( if (!reference->Get().IsEmpty()) {
reference->template Cast<v8::Data>().Get()); controller->RegisterEmbedderReference(
} reference->template Cast<v8::Data>().Get());
}
},
WorklistTaskId::MutatorThread);
} }
ThreadHeap* ThreadHeap::main_thread_heap_ = nullptr; ThreadHeap* ThreadHeap::main_thread_heap_ = nullptr;
......
...@@ -406,7 +406,7 @@ class PLATFORM_EXPORT ThreadHeap { ...@@ -406,7 +406,7 @@ class PLATFORM_EXPORT ThreadHeap {
void InvokeEphemeronCallbacks(MarkingVisitor*); void InvokeEphemeronCallbacks(MarkingVisitor*);
void FlushV8References(); bool FlushV8References(base::TimeTicks);
ThreadState* thread_state_; ThreadState* thread_state_;
std::unique_ptr<ThreadHeapStatsCollector> heap_stats_collector_; std::unique_ptr<ThreadHeapStatsCollector> heap_stats_collector_;
......
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