#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;
}
TEST_F(GCInfoTableTest, InitialEmpty) { … }
TEST_F(GCInfoTableTest, ResizeToMaxIndex) { … }
TEST_F(GCInfoTableDeathTest, MoreThanMaxIndexInfos) { … }
TEST_F(GCInfoTableDeathTest, OldTableAreaIsReadOnly) { … }
namespace {
class ThreadRegisteringGCInfoObjects final : public v8::base::Thread { … };
}
TEST_F(GCInfoTableTest, MultiThreadedResizeToMaxIndex) { … }
namespace {
class GCInfoTraitTest : public testing::TestWithPlatform { … };
class BasicType final { … };
class OtherBasicType final { … };
}
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
static_assert …;
#endif
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
static_assert …;
#endif
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
static_assert …;
#endif
}
}
}