#include "src/heap/cppgc/visitor.h"
#include "include/cppgc/allocation.h"
#include "include/cppgc/garbage-collected.h"
#include "include/cppgc/member.h"
#include "include/cppgc/trace-trait.h"
#include "src/base/macros.h"
#include "src/heap/cppgc/heap.h"
#include "src/heap/cppgc/liveness-broker.h"
#include "src/heap/cppgc/object-allocator.h"
#include "test/unittests/heap/cppgc/tests.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace cppgc {
namespace internal {
namespace {
class TraceTraitTest : public testing::TestSupportingAllocationOnly { … };
class VisitorTest : public testing::TestSupportingAllocationOnly { … };
class GCed : public GarbageCollected<GCed> { … };
size_t GCed::trace_callcount;
class GCedMixin : public GarbageCollectedMixin { … };
size_t GCedMixin::trace_callcount;
class OtherPayload { … };
class GCedMixinApplication : public GCed,
public OtherPayload,
public GCedMixin { … };
}
TEST_F(TraceTraitTest, GetObjectStartGCed) { … }
TEST_F(TraceTraitTest, GetObjectStartGCedMixin) { … }
TEST_F(TraceTraitTest, TraceGCed) { … }
TEST_F(TraceTraitTest, TraceGCedMixin) { … }
TEST_F(TraceTraitTest, TraceGCedThroughTraceDescriptor) { … }
TEST_F(TraceTraitTest, TraceGCedMixinThroughTraceDescriptor) { … }
namespace {
class MixinInstanceWithoutTrace
: public GarbageCollected<MixinInstanceWithoutTrace>,
public GCedMixin { … };
}
TEST_F(TraceTraitTest, MixinInstanceWithoutTrace) { … }
namespace {
class DispatchingVisitor : public VisitorBase { … };
class CheckingVisitor final : public DispatchingVisitor { … };
}
TEST_F(VisitorTest, DispatchTraceGCed) { … }
TEST_F(VisitorTest, DispatchTraceGCedMixin) { … }
TEST_F(VisitorTest, DispatchTraceWeakGCed) { … }
TEST_F(VisitorTest, DispatchTraceWeakGCedMixin) { … }
namespace {
class WeakCallbackVisitor final : public VisitorBase { … };
struct WeakCallbackDispatcher { … };
size_t WeakCallbackDispatcher::callback_callcount;
const void* WeakCallbackDispatcher::callback_param;
class GCedWithCustomWeakCallback final
: public GarbageCollected<GCedWithCustomWeakCallback> { … };
}
TEST_F(VisitorTest, DispatchRegisterWeakCallback) { … }
TEST_F(VisitorTest, DispatchRegisterWeakCallbackMethod) { … }
namespace {
class Composite final { … };
size_t Composite::callback_callcount;
class GCedWithComposite final : public GarbageCollected<GCedWithComposite> { … };
class VirtualBase { … };
class CompositeWithVtable : public VirtualBase { … };
size_t CompositeWithVtable::callback_callcount;
class GCedWithCompositeWithVtable final
: public GarbageCollected<GCedWithCompositeWithVtable> { … };
}
TEST_F(VisitorTest, DispatchToCompositeObject) { … }
TEST_F(VisitorTest, DispatchToCompositeObjectWithVtable) { … }
namespace {
inline void hash_combine(std::size_t& seed) { … }
template <typename T, typename... Rest>
void hash_combine(size_t& seed, const T& v, Rest... rest) { … }
class HashingVisitor final : public DispatchingVisitor { … };
template <template <class> class MemberType, typename GCType>
class GCedWithMultipleMember final
: public GarbageCollected<GCedWithMultipleMember<MemberType, GCType>> { … };
template <class GCType>
void DispatchMultipleMemberTest(AllocationHandle& handle) { … }
}
TEST_F(VisitorTest, DispatchToMultipleMember) { … }
TEST_F(VisitorTest, DispatchToMultipleUncompressedMember) { … }
namespace {
class GCedWithMultipleComposite final
: public GarbageCollected<GCedWithMultipleComposite> { … };
class GCedWithMultipleCompositeUninitializedVtable final
: public GarbageCollected<GCedWithMultipleCompositeUninitializedVtable> { … };
}
TEST_F(VisitorTest, DispatchToMultipleCompositeObjects) { … }
TEST_F(VisitorTest, DispatchMultipleInlinedObjectsWithClearedVtable) { … }
}
}