cppgc: Enable concurrent marking/sweeping for unified heap

Bug: chromium:1056170
Change-Id: I010ab2ff2c55ce54b5dcc2df6fb7bbcd14b03e2a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2480568
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70599}
This commit is contained in:
Omer Katz 2020-10-16 20:38:52 +02:00 committed by Commit Bot
parent 67c0721d9a
commit 3b589d0b30
3 changed files with 11 additions and 2 deletions

View File

@ -169,10 +169,13 @@ void CppHeap::RegisterV8References(
}
void CppHeap::TracePrologue(TraceFlags flags) {
// Finish sweeping in case it is still running.
sweeper_.FinishIfRunning();
const UnifiedHeapMarker::MarkingConfig marking_config{
UnifiedHeapMarker::MarkingConfig::CollectionType::kMajor,
cppgc::Heap::StackState::kNoHeapPointers,
UnifiedHeapMarker::MarkingConfig::MarkingType::kIncremental};
UnifiedHeapMarker::MarkingConfig::MarkingType::kIncrementalAndConcurrent};
marker_ =
cppgc::internal::MarkerFactory::CreateAndStartMarking<UnifiedHeapMarker>(
*isolate_.heap(), AsBase(), platform_.get(), marking_config);
@ -210,7 +213,8 @@ void CppHeap::TraceEpilogue(TraceSummary* trace_summary) {
#endif
{
NoGCScope no_gc(*this);
sweeper().Start(cppgc::internal::Sweeper::Config::kAtomic);
sweeper().Start(
cppgc::internal::Sweeper::Config::kIncrementalAndConcurrent);
}
}

View File

@ -580,6 +580,9 @@ void CppGraphBuilderImpl::VisitRootForGraphBuilding(
}
void CppGraphBuilderImpl::Run() {
// Sweeping from a previous GC might still be running, in which case not all
// pages have been returned to spaces yet.
cpp_heap_.sweeper().FinishIfRunning();
// First pass: Figure out which objects should be included in the graph -- see
// class-level comment on CppGraphBuilder.
LiveObjectsForVisibilityIterator visitor(*this);

View File

@ -94,6 +94,8 @@ TEST_F(UnifiedHeapTest, FindingV8ToBlinkReference) {
EXPECT_EQ(0u, Wrappable::destructor_callcount);
ResetWrappableConnection(api_object);
CollectGarbage(OLD_SPACE);
// Calling CollectGarbage twice to force the first GC to finish sweeping.
CollectGarbage(OLD_SPACE);
EXPECT_EQ(1u, Wrappable::destructor_callcount);
}