chromium/v8/test/unittests/heap/cppgc/marker-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 "src/heap/cppgc/marker.h"

#include <memory>

#include "include/cppgc/allocation.h"
#include "include/cppgc/ephemeron-pair.h"
#include "include/cppgc/internal/pointer-policies.h"
#include "include/cppgc/member.h"
#include "include/cppgc/persistent.h"
#include "include/cppgc/trace-trait.h"
#include "src/heap/cppgc/heap-object-header.h"
#include "src/heap/cppgc/marking-visitor.h"
#include "src/heap/cppgc/object-allocator.h"
#include "src/heap/cppgc/stats-collector.h"
#include "test/unittests/heap/cppgc/tests.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace cppgc {
namespace internal {

namespace {
class MarkerTest : public testing::TestWithHeap {};

class GCed : public GarbageCollected<GCed> {};

template <typename T>
V8_NOINLINE T access(volatile const T& t) {}

}  // namespace

TEST_F(MarkerTest, PersistentIsMarked) {}

TEST_F(MarkerTest, ReachableMemberIsMarked) {}

TEST_F(MarkerTest, UnreachableMemberIsNotMarked) {}

TEST_F(MarkerTest, ObjectReachableFromStackIsMarked) {}

TEST_F(MarkerTest, ObjectReachableOnlyFromStackIsNotMarkedIfStackIsEmpty) {}

TEST_F(MarkerTest, WeakReferenceToUnreachableObjectIsCleared) {}

TEST_F(MarkerTest, WeakReferenceToReachableObjectIsNotCleared) {}

TEST_F(MarkerTest, DeepHierarchyIsMarked) {}

TEST_F(MarkerTest, NestedObjectsOnStackAreMarked) {}

namespace {

class GCedWithCallback : public GarbageCollected<GCedWithCallback> {};

}  // namespace

TEST_F(MarkerTest, InConstructionObjectIsEventuallyMarkedEmptyStack) {}

TEST_F(MarkerTest, InConstructionObjectIsEventuallyMarkedNonEmptyStack) {}

namespace {

// Storage that can be used to hide a pointer from the GC. Only useful when
// dealing with the stack separately.
class GCObliviousObjectStorage final {};

V8_NOINLINE void RegisterInConstructionObject(
    AllocationHandle& allocation_handle, Visitor& v,
    GCObliviousObjectStorage& storage) {}

}  // namespace

TEST_F(MarkerTest,
       InConstructionObjectIsEventuallyMarkedDifferentNonEmptyStack) {}

TEST_F(MarkerTest, SentinelNotClearedOnWeakPersistentHandling) {}

namespace {

class SimpleObject final : public GarbageCollected<SimpleObject> {};

class ObjectWithEphemeronPair final
    : public GarbageCollected<ObjectWithEphemeronPair> {};

}  // namespace

TEST_F(MarkerTest, MarkerProcessesAllEphemeronPairs) {}

// Incremental Marking

class IncrementalMarkingTest : public testing::TestWithHeap {};

constexpr MarkingConfig IncrementalMarkingTest::IncrementalPreciseMarkingConfig;

TEST_F(IncrementalMarkingTest, RootIsMarkedAfterMarkingStarted) {}

TEST_F(IncrementalMarkingTest, MemberIsMarkedAfterMarkingSteps) {}

TEST_F(IncrementalMarkingTest,
       MemberWithWriteBarrierIsMarkedAfterMarkingSteps) {}

namespace {
class Holder : public GarbageCollected<Holder> {};
}  // namespace

TEST_F(IncrementalMarkingTest, IncrementalStepDuringAllocation) {}

TEST_F(IncrementalMarkingTest, MarkingRunsOutOfWorkEventually) {}

}  // namespace internal
}  // namespace cppgc