cppgc-js: Make use of simple unmarker when young gen is enabled

Young generation collection requires that full GCs unmark before
starting marking.

Bug: v8:12324
Change-Id: Id6cc218057252cbf0664326126f34b07ac8ea247
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3229570
Auto-Submit: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Anton Bikineev <bikineev@chromium.org>
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77445}
This commit is contained in:
Michael Lippautz 2021-10-18 19:58:41 +02:00 committed by V8 LUCI CQ
parent 43633af0e3
commit dfbd9edb87
4 changed files with 39 additions and 15 deletions

View File

@ -5504,6 +5504,7 @@ v8_source_set("cppgc_base") {
"src/heap/cppgc/sweeper.cc",
"src/heap/cppgc/sweeper.h",
"src/heap/cppgc/task-handle.h",
"src/heap/cppgc/unmarker.h",
# TODO(v8:11952): Remove the testing header here once depending on both,
# //v8:v8 and //v8:v8_for_testing does not result in ODR violations.

View File

@ -37,6 +37,7 @@
#include "src/heap/cppgc/raw-heap.h"
#include "src/heap/cppgc/stats-collector.h"
#include "src/heap/cppgc/sweeper.h"
#include "src/heap/cppgc/unmarker.h"
#include "src/heap/embedder-tracing.h"
#include "src/heap/gc-tracer.h"
#include "src/heap/marking-worklist.h"
@ -417,6 +418,10 @@ bool ShouldReduceMemory(CppHeap::TraceFlags flags) {
void CppHeap::TracePrologue(TraceFlags flags) {
CHECK(!sweeper_.IsSweepingInProgress());
#if defined(CPPGC_YOUNG_GENERATION)
cppgc::internal::SequentialUnmarker unmarker(raw_heap());
#endif // defined(CPPGC_YOUNG_GENERATION)
current_flags_ = flags;
const UnifiedHeapMarker::MarkingConfig marking_config{
UnifiedHeapMarker::MarkingConfig::CollectionType::kMajor,

View File

@ -15,6 +15,7 @@
#include "src/heap/cppgc/prefinalizer-handler.h"
#include "src/heap/cppgc/stats-collector.h"
#include "src/heap/cppgc/sweeper.h"
#include "src/heap/cppgc/unmarker.h"
namespace cppgc {
@ -61,19 +62,6 @@ namespace internal {
namespace {
class Unmarker final : private HeapVisitor<Unmarker> {
friend class HeapVisitor<Unmarker>;
public:
explicit Unmarker(RawHeap& heap) { Traverse(heap); }
private:
bool VisitHeapObjectHeader(HeapObjectHeader& header) {
if (header.IsMarked()) header.Unmark();
return true;
}
};
void CheckConfig(Heap::Config config, Heap::MarkingType marking_support,
Heap::SweepingType sweeping_support) {
CHECK_WITH_MSG(
@ -160,7 +148,7 @@ void Heap::StartGarbageCollection(Config config) {
#if defined(CPPGC_YOUNG_GENERATION)
if (config.collection_type == Config::CollectionType::kMajor)
Unmarker unmarker(raw_heap());
SequentialUnmarker unmarker(raw_heap());
#endif
const Marker::MarkingConfig marking_config{

30
src/heap/cppgc/unmarker.h Normal file
View File

@ -0,0 +1,30 @@
// Copyright 2021 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_HEAP_CPPGC_UNMARKER_H_
#define V8_HEAP_CPPGC_UNMARKER_H_
#include "src/heap/cppgc/heap-object-header.h"
#include "src/heap/cppgc/heap-visitor.h"
namespace cppgc {
namespace internal {
class SequentialUnmarker final : private HeapVisitor<SequentialUnmarker> {
friend class HeapVisitor<SequentialUnmarker>;
public:
explicit SequentialUnmarker(RawHeap& heap) { Traverse(heap); }
private:
bool VisitHeapObjectHeader(HeapObjectHeader& header) {
if (header.IsMarked()) header.Unmark();
return true;
}
};
} // namespace internal
} // namespace cppgc
#endif // V8_HEAP_CPPGC_UNMARKER_H_