#include "include/cppgc/allocation.h"
#include "include/cppgc/visitor.h"
#include "src/heap/cppgc/globals.h"
#include "src/heap/cppgc/heap-object-header.h"
#include "test/unittests/heap/cppgc/tests.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace cppgc {
namespace internal {
namespace {
class CppgcAllocationTest : public testing::TestWithHeap { … };
struct GCed final : GarbageCollected<GCed> { … };
class HeapAllocatedArray final : public GarbageCollected<HeapAllocatedArray> { … };
}
TEST_F(CppgcAllocationTest, MakeGarbageCollectedPreservesPayload) { … }
TEST_F(CppgcAllocationTest, ReuseMemoryFromFreelist) { … }
namespace {
class CallbackInCtor final : public GarbageCollected<CallbackInCtor> { … };
}
TEST_F(CppgcAllocationTest,
ConservativeGCDuringAllocationDoesNotReclaimObject) { … }
#if defined(CPPGC_CAGED_HEAP)
namespace {
class LargeObjectCheckingPayloadForZeroMemory final
: public GarbageCollected<LargeObjectCheckingPayloadForZeroMemory> { … };
size_t LargeObjectCheckingPayloadForZeroMemory::destructor_calls = …;
}
TEST_F(CppgcAllocationTest, LargePagesAreZeroedOut) { … }
#endif
namespace {
constexpr size_t kDoubleWord = …;
constexpr size_t kWord = …;
class alignas(kDoubleWord) DoubleWordAligned final
: public GarbageCollected<DoubleWordAligned> { … };
class alignas(kDoubleWord) LargeDoubleWordAligned
: public GarbageCollected<LargeDoubleWordAligned> { … };
template <size_t Size>
class CustomPadding final : public GarbageCollected<CustomPadding<Size>> { … };
template <size_t Size>
class alignas(kDoubleWord) AlignedCustomPadding final
: public GarbageCollected<AlignedCustomPadding<Size>> { … };
}
TEST_F(CppgcAllocationTest, DoubleWordAlignedAllocation) { … }
TEST_F(CppgcAllocationTest, LargeDoubleWordAlignedAllocation) { … }
TEST_F(CppgcAllocationTest, AlignToDoubleWordFromUnaligned) { … }
TEST_F(CppgcAllocationTest, AlignToDoubleWordFromAligned) { … }
}
}