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

#include <type_traits>

#include "include/cppgc/platform.h"
#include "src/base/page-allocator.h"
#include "src/base/platform/platform.h"
#include "src/heap/cppgc/gc-info-table.h"
#include "src/heap/cppgc/platform.h"
#include "test/unittests/heap/cppgc/tests.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace cppgc {
namespace internal {

namespace {

constexpr GCInfo GetEmptyGCInfo() {}

class GCInfoTableTest : public ::testing::Test {};

GCInfoTableDeathTest;

}  // namespace

TEST_F(GCInfoTableTest, InitialEmpty) {}

TEST_F(GCInfoTableTest, ResizeToMaxIndex) {}

TEST_F(GCInfoTableDeathTest, MoreThanMaxIndexInfos) {}

TEST_F(GCInfoTableDeathTest, OldTableAreaIsReadOnly) {}

namespace {

class ThreadRegisteringGCInfoObjects final : public v8::base::Thread {};

}  // namespace

TEST_F(GCInfoTableTest, MultiThreadedResizeToMaxIndex) {}

// Tests using the global table and GCInfoTrait.

namespace {

class GCInfoTraitTest : public testing::TestWithPlatform {};

class BasicType final {};
class OtherBasicType final {};

}  // namespace

TEST_F(GCInfoTraitTest, IndexInBounds) {}

TEST_F(GCInfoTraitTest, TraitReturnsSameIndexForSameType) {}

TEST_F(GCInfoTraitTest, TraitReturnsDifferentIndexForDifferentTypes) {}

namespace {

struct Dummy {};

class BaseWithVirtualDestructor
    : public GarbageCollected<BaseWithVirtualDestructor> {};

class ChildOfBaseWithVirtualDestructor : public BaseWithVirtualDestructor {};

static_assert;
static_assert;
#ifdef CPPGC_SUPPORTS_OBJECT_NAMES
static_assert(std::is_same<typename internal::GCInfoFolding<
                               ChildOfBaseWithVirtualDestructor,
                               ChildOfBaseWithVirtualDestructor::
                                   ParentMostGarbageCollectedType>::ResultType,
                           ChildOfBaseWithVirtualDestructor>::value,
              "No folding to preserve object names");
#else   // !CPPGC_SUPPORTS_OBJECT_NAMES
static_assert;
#endif  // !CPPGC_SUPPORTS_OBJECT_NAMES

class TriviallyDestructibleBase
    : public GarbageCollected<TriviallyDestructibleBase> {};

class ChildOfTriviallyDestructibleBase : public TriviallyDestructibleBase {};

static_assert;
static_assert;
#ifdef CPPGC_SUPPORTS_OBJECT_NAMES
static_assert(std::is_same<typename internal::GCInfoFolding<
                               ChildOfTriviallyDestructibleBase,
                               ChildOfTriviallyDestructibleBase::
                                   ParentMostGarbageCollectedType>::ResultType,
                           ChildOfTriviallyDestructibleBase>::value,
              "No folding to preserve object names");
#else   // !CPPGC_SUPPORTS_OBJECT_NAMES
static_assert;
#endif  // !CPPGC_SUPPORTS_OBJECT_NAMES

class TypeWithCustomFinalizationMethodAtBase
    : public GarbageCollected<TypeWithCustomFinalizationMethodAtBase> {};

class ChildOfTypeWithCustomFinalizationMethodAtBase
    : public TypeWithCustomFinalizationMethodAtBase {};

static_assert;
static_assert;
#ifdef CPPGC_SUPPORTS_OBJECT_NAMES
static_assert(
    std::is_same<typename internal::GCInfoFolding<
                     ChildOfTypeWithCustomFinalizationMethodAtBase,
                     ChildOfTypeWithCustomFinalizationMethodAtBase::
                         ParentMostGarbageCollectedType>::ResultType,
                 ChildOfTypeWithCustomFinalizationMethodAtBase>::value,
    "No folding to preserve object names");
#else   // !CPPGC_SUPPORTS_OBJECT_NAMES
static_assert;
#endif  // !CPPGC_SUPPORTS_OBJECT_NAMES

}  // namespace

}  // namespace internal
}  // namespace cppgc