chromium/v8/test/unittests/heap/cppgc/write-barrier-unittest.cc

// Copyright 2020 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.

#include "include/cppgc/internal/write-barrier.h"

#include <algorithm>
#include <initializer_list>
#include <vector>

#include "include/cppgc/heap-consistency.h"
#include "include/cppgc/internal/pointer-policies.h"
#include "src/base/logging.h"
#include "src/heap/cppgc/heap-object-header.h"
#include "src/heap/cppgc/marker.h"
#include "test/unittests/heap/cppgc/tests.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace cppgc {
namespace internal {

namespace {

class V8_NODISCARD IncrementalMarkingScope {};

constexpr MarkingConfig IncrementalMarkingScope::kIncrementalConfig;

class V8_NODISCARD ExpectWriteBarrierFires final
    : private IncrementalMarkingScope {};

class V8_NODISCARD ExpectNoWriteBarrierFires final
    : private IncrementalMarkingScope {};

class GCed : public GarbageCollected<GCed> {};

}  // namespace

class WriteBarrierTest : public testing::TestWithHeap {};

class NoWriteBarrierTest : public testing::TestWithHeap {};

// =============================================================================
// Basic support. ==============================================================
// =============================================================================

TEST_F(WriteBarrierTest, EnableDisableIncrementalMarking) {}

TEST_F(WriteBarrierTest, TriggersWhenMarkingIsOn) {}

TEST_F(NoWriteBarrierTest, BailoutWhenMarkingIsOff) {}

TEST_F(WriteBarrierTest, BailoutIfMarked) {}

TEST_F(WriteBarrierTest, MemberInitializingStoreNoBarrier) {}

TEST_F(WriteBarrierTest, MemberReferenceAssignMember) {}

TEST_F(WriteBarrierTest, MemberSetSentinelValueNoBarrier) {}

TEST_F(WriteBarrierTest, MemberCopySentinelValueNoBarrier) {}

// =============================================================================
// Mixin support. ==============================================================
// =============================================================================

namespace {

class Mixin : public GarbageCollectedMixin {};

class ClassWithVirtual {};

class Child : public GarbageCollected<Child>,
              public ClassWithVirtual,
              public Mixin {};

class ParentWithMixinPointer : public GarbageCollected<ParentWithMixinPointer> {};

}  // namespace

TEST_F(WriteBarrierTest, WriteBarrierOnUnmarkedMixinApplication) {}

TEST_F(WriteBarrierTest, NoWriteBarrierOnMarkedMixinApplication) {}

// =============================================================================
// Raw barriers. ===============================================================
// =============================================================================

WriteBarrierParams;
WriteBarrierType;
HeapConsistency;

TEST_F(NoWriteBarrierTest, WriteBarrierBailoutWhenMarkingIsOff) {}

TEST_F(WriteBarrierTest, DijkstraWriteBarrierTriggersWhenMarkingIsOn) {}

TEST_F(WriteBarrierTest, DijkstraWriteBarrierBailoutIfMarked) {}

namespace {

struct InlinedObject {};

class GCedWithInlinedArray : public GarbageCollected<GCedWithInlinedArray> {};

}  // namespace

TEST_F(WriteBarrierTest, DijkstraWriteBarrierRangeTriggersWhenMarkingIsOn) {}

TEST_F(WriteBarrierTest, DijkstraWriteBarrierRangeBailoutIfMarked) {}

TEST_F(WriteBarrierTest, SteeleWriteBarrierTriggersWhenMarkingIsOn) {}

TEST_F(WriteBarrierTest, SteeleWriteBarrierBailoutIfNotMarked) {}

}  // namespace internal
}  // namespace cppgc