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

#include "include/cppgc/allocation.h"
#include "include/cppgc/member.h"
#include "include/cppgc/persistent.h"
#include "include/cppgc/source-location.h"
#include "src/heap/cppgc/globals.h"
#include "src/heap/cppgc/heap-object-header.h"
#include "src/heap/cppgc/marker.h"
#include "src/heap/cppgc/marking-state.h"
#include "test/unittests/heap/cppgc/tests.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace cppgc {
namespace internal {

namespace {

class MarkingVisitorTest : public testing::TestWithHeap {};

class GCed : public GarbageCollected<GCed> {};

class Mixin : public GarbageCollectedMixin {};
class GCedWithMixin : public GarbageCollected<GCedWithMixin>, public Mixin {};

class TestMarkingVisitor : public MutatorMarkingVisitor {};

class TestRootMarkingVisitor : public RootMarkingVisitor {};

}  // namespace

TEST_F(MarkingVisitorTest, MarkedBytesAreInitiallyZero) {}

// Strong references are marked.

TEST_F(MarkingVisitorTest, MarkMember) {}

TEST_F(MarkingVisitorTest, MarkMemberMixin) {}

TEST_F(MarkingVisitorTest, MarkPersistent) {}

TEST_F(MarkingVisitorTest, MarkPersistentMixin) {}

// Weak references are not marked.

TEST_F(MarkingVisitorTest, DontMarkWeakMember) {}

TEST_F(MarkingVisitorTest, DontMarkWeakMemberMixin) {}

TEST_F(MarkingVisitorTest, DontMarkWeakPersistent) {}

TEST_F(MarkingVisitorTest, DontMarkWeakPersistentMixin) {}

// In construction objects are not marked.

namespace {

class GCedWithInConstructionCallback
    : public GarbageCollected<GCedWithInConstructionCallback> {};

class MixinWithInConstructionCallback : public GarbageCollectedMixin {};
class GCedWithMixinWithInConstructionCallback
    : public GarbageCollected<GCedWithMixinWithInConstructionCallback>,
      public MixinWithInConstructionCallback {};

}  // namespace

TEST_F(MarkingVisitorTest, MarkMemberInConstruction) {}

TEST_F(MarkingVisitorTest, MarkMemberMixinInConstruction) {}

TEST_F(MarkingVisitorTest, DontMarkWeakMemberInConstruction) {}

TEST_F(MarkingVisitorTest, DontMarkWeakMemberMixinInConstruction) {}

TEST_F(MarkingVisitorTest, MarkPersistentInConstruction) {}

TEST_F(MarkingVisitorTest, MarkPersistentMixinInConstruction) {}

TEST_F(MarkingVisitorTest, StrongTracingMarksWeakMember) {}

namespace {

struct GCedWithDestructor : GarbageCollected<GCedWithDestructor> {};

size_t GCedWithDestructor::g_finalized =;

struct GCedWithInConstructionCallbackWithMember : GCedWithDestructor {};

struct ConservativeTracerTest : public testing::TestWithHeap {};

}  // namespace

TEST_F(ConservativeTracerTest, TraceConservativelyInConstructionObject) {}

TEST_F(ConservativeTracerTest, TraceConservativelyStack) {}

}  // namespace internal
}  // namespace cppgc