#include "src/heap/cppgc/heap.h"
#include <algorithm>
#include <iterator>
#include <numeric>
#include "include/cppgc/allocation.h"
#include "include/cppgc/cross-thread-persistent.h"
#include "include/cppgc/heap-consistency.h"
#include "include/cppgc/heap-state.h"
#include "include/cppgc/persistent.h"
#include "include/cppgc/prefinalizer.h"
#include "src/heap/cppgc/globals.h"
#include "test/unittests/heap/cppgc/tests.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace cppgc {
namespace internal {
namespace {
class GCHeapTest : public testing::TestWithHeap { … };
class GCHeapDeathTest : public GCHeapTest { … };
class Foo : public GarbageCollected<Foo> { … };
size_t Foo::destructor_callcount;
template <size_t Size>
class GCed : public GarbageCollected<GCed<Size>> { … };
}
TEST_F(GCHeapTest, PreciseGCReclaimsObjectOnStack) { … }
namespace {
const void* ConservativeGCReturningObject(cppgc::Heap* heap,
const void* object) { … }
}
TEST_F(GCHeapTest, ConservativeGCRetainsObjectOnStack) { … }
namespace {
class GCedWithFinalizer final : public GarbageCollected<GCedWithFinalizer> { … };
size_t GCedWithFinalizer::destructor_counter = …;
class LargeObjectGCDuringCtor final
: public GarbageCollected<LargeObjectGCDuringCtor> { … };
}
TEST_F(GCHeapTest, ConservativeGCFromLargeObjectCtorFindsObject) { … }
TEST_F(GCHeapTest, ObjectPayloadSize) { … }
TEST_F(GCHeapTest, AllocateWithAdditionalBytes) { … }
TEST_F(GCHeapTest, AllocatedSizeDependOnAdditionalBytes) { … }
TEST_F(GCHeapTest, Epoch) { … }
TEST_F(GCHeapTest, NoGarbageCollectionScope) { … }
TEST_F(GCHeapTest, IsGarbageCollectionAllowed) { … }
TEST_F(GCHeapTest, IsMarking) { … }
TEST_F(GCHeapTest, IsSweeping) { … }
namespace {
class GCedExpectSweepingOnOwningThread final
: public GarbageCollected<GCedExpectSweepingOnOwningThread> { … };
}
TEST_F(GCHeapTest, IsSweepingOnOwningThread) { … }
namespace {
class ExpectAtomicPause final : public GarbageCollected<ExpectAtomicPause> { … };
}
TEST_F(GCHeapTest, IsInAtomicPause) { … }
TEST_F(GCHeapTest, TerminateEmptyHeap) { … }
TEST_F(GCHeapTest, TerminateClearsPersistent) { … }
TEST_F(GCHeapTest, TerminateInvokesDestructor) { … }
namespace {
template <template <typename> class PersistentType>
class Cloner final : public GarbageCollected<Cloner<PersistentType>> { … };
template <template <typename> class PersistentType>
PersistentType<Cloner<PersistentType>> Cloner<PersistentType>::new_instance_;
template <template <typename> class PersistentType>
size_t Cloner<PersistentType>::destructor_count;
}
template <template <typename> class PersistentType>
void TerminateReclaimsNewState(std::shared_ptr<Platform> platform) { … }
TEST_F(GCHeapTest, TerminateReclaimsNewState) { … }
TEST_F(GCHeapDeathTest, TerminateProhibitsAllocation) { … }
template <template <typename> class PersistentType>
void LargeChainOfNewStates(cppgc::Heap& heap) { … }
TEST_F(GCHeapDeathTest, LargeChainOfNewStatesPersistent) { … }
TEST_F(GCHeapDeathTest, LargeChainOfNewStatesCrossThreadPersistent) { … }
}
}