chromium/v8/test/unittests/heap/cppgc/heap-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 "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>> {};

}  // namespace

TEST_F(GCHeapTest, PreciseGCReclaimsObjectOnStack) {}

namespace {

const void* ConservativeGCReturningObject(cppgc::Heap* heap,
                                          const void* object) {}

}  // namespace

TEST_F(GCHeapTest, ConservativeGCRetainsObjectOnStack) {}

namespace {

class GCedWithFinalizer final : public GarbageCollected<GCedWithFinalizer> {};
// static
size_t GCedWithFinalizer::destructor_counter =;

class LargeObjectGCDuringCtor final
    : public GarbageCollected<LargeObjectGCDuringCtor> {};

}  // namespace

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> {};

}  // namespace

TEST_F(GCHeapTest, IsSweepingOnOwningThread) {}

namespace {

class ExpectAtomicPause final : public GarbageCollected<ExpectAtomicPause> {};

}  // namespace

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>> {};

// static
template <template <typename> class PersistentType>
PersistentType<Cloner<PersistentType>> Cloner<PersistentType>::new_instance_;
// static
template <template <typename> class PersistentType>
size_t Cloner<PersistentType>::destructor_count;

}  // namespace

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) {}

}  // namespace internal
}  // namespace cppgc