chromium/third_party/blink/renderer/platform/heap/test/incremental_marking_test.cc

// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <initializer_list>

#include "base/functional/bind.h"
#include "base/test/scoped_feature_list.h"
#include "build/buildflag.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/renderer/platform/bindings/script_forbidden_scope.h"
#include "third_party/blink/renderer/platform/heap/collection_support/heap_deque.h"
#include "third_party/blink/renderer/platform/heap/collection_support/heap_hash_counted_set.h"
#include "third_party/blink/renderer/platform/heap/collection_support/heap_hash_map.h"
#include "third_party/blink/renderer/platform/heap/collection_support/heap_hash_set.h"
#include "third_party/blink/renderer/platform/heap/collection_support/heap_linked_hash_set.h"
#include "third_party/blink/renderer/platform/heap/collection_support/heap_vector.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/heap/heap_buildflags.h"
#include "third_party/blink/renderer/platform/heap/heap_test_objects.h"
#include "third_party/blink/renderer/platform/heap/heap_test_utilities.h"
#include "third_party/blink/renderer/platform/heap/member.h"
#include "third_party/blink/renderer/platform/heap/persistent.h"
#include "third_party/blink/renderer/platform/heap/thread_state.h"
#include "third_party/blink/renderer/platform/heap/trace_traits.h"
#include "third_party/blink/renderer/platform/heap/visitor.h"
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"

namespace blink {

class IncrementalMarkingTest : public TestSupportingGC {};

namespace incremental_marking_test {

// =============================================================================
// HeapVector support. =========================================================
// =============================================================================

namespace {

// HeapVector allows for insertion of container objects that can be traced but
// are themselves non-garbage collected.
class NonGarbageCollectedContainer {};

class NonGarbageCollectedContainerRoot {};

}  // namespace

TEST_F(IncrementalMarkingTest, HeapVectorPushBackMember) {}

TEST_F(IncrementalMarkingTest, HeapVectorPushBackNonGCedContainer) {}

TEST_F(IncrementalMarkingTest, HeapVectorPushBackStdPair) {}

TEST_F(IncrementalMarkingTest, HeapVectorEmplaceBackMember) {}

TEST_F(IncrementalMarkingTest, HeapVectorEmplaceBackNonGCedContainer) {}

TEST_F(IncrementalMarkingTest, HeapVectorEmplaceBackStdPair) {}

TEST_F(IncrementalMarkingTest, HeapVectorCopyMember) {}

TEST_F(IncrementalMarkingTest, HeapVectorCopyMemberInCtor) {}

TEST_F(IncrementalMarkingTest, HeapVectorCopyNonGCedContainer) {}

TEST_F(IncrementalMarkingTest, HeapVectorCopyNonGCedContainerInCtor) {}

TEST_F(IncrementalMarkingTest, HeapVectorCopyStdPair) {}

TEST_F(IncrementalMarkingTest, HeapVectorCopyStdPairInCtor) {}

TEST_F(IncrementalMarkingTest, HeapVectorMoveMember) {}

TEST_F(IncrementalMarkingTest, HeapVectorMoveMemberInCtor) {}

TEST_F(IncrementalMarkingTest, HeapVectorMoveNonGCedContainer) {}

TEST_F(IncrementalMarkingTest, HeapVectorMoveNonGCedContainerInCtor) {}

TEST_F(IncrementalMarkingTest, HeapVectorMoveStdPair) {}

TEST_F(IncrementalMarkingTest, HeapVectorMoveStdPairInCtor) {}

TEST_F(IncrementalMarkingTest, HeapVectorSwapMember) {}

TEST_F(IncrementalMarkingTest, HeapVectorSwapNonGCedContainer) {}

TEST_F(IncrementalMarkingTest, HeapVectorSwapStdPair) {}

TEST_F(IncrementalMarkingTest, HeapVectorSubscriptOperator) {}

TEST_F(IncrementalMarkingTest, HeapVectorEagerTracingStopsAtMember) {}

// =============================================================================
// HeapDeque support. ==========================================================
// =============================================================================

TEST_F(IncrementalMarkingTest, HeapDequePushBackMember) {}

TEST_F(IncrementalMarkingTest, HeapDequePushFrontMember) {}

TEST_F(IncrementalMarkingTest, HeapDequeEmplaceBackMember) {}

TEST_F(IncrementalMarkingTest, HeapDequeEmplaceFrontMember) {}

TEST_F(IncrementalMarkingTest, HeapDequeCopyMember) {}

TEST_F(IncrementalMarkingTest, HeapDequeCopyMemberInCtor) {}

TEST_F(IncrementalMarkingTest, HeapDequeMoveMember) {}

TEST_F(IncrementalMarkingTest, HeapDequeMoveMemberInCtor) {}

TEST_F(IncrementalMarkingTest, HeapDequeSwapMember) {}

// =============================================================================
// HeapHashSet support. ========================================================
// =============================================================================

namespace {

template <typename Container>
void Insert() {}

template <typename Container>
void Copy() {}

template <typename Container>
void Move() {}

template <typename Container>
void Swap() {}

}  // namespace

TEST_F(IncrementalMarkingTest, HeapHashSetInsert) {}

TEST_F(IncrementalMarkingTest, HeapHashSetCopy) {}

TEST_F(IncrementalMarkingTest, HeapHashSetMove) {}

TEST_F(IncrementalMarkingTest, HeapHashSetSwap) {}

// =============================================================================
// HeapLinkedHashSet support. ==================================================
// =============================================================================

TEST_F(IncrementalMarkingTest, HeapLinkedHashSetInsert) {}

TEST_F(IncrementalMarkingTest, HeapLinkedHashSetCopy) {}

TEST_F(IncrementalMarkingTest, HeapLinkedHashSetMove) {}

TEST_F(IncrementalMarkingTest, HeapLinkedHashSetSwap) {}

// =============================================================================
// HeapHashCountedSet support. =================================================
// =============================================================================

// HeapHashCountedSet does not support copy or move.

TEST_F(IncrementalMarkingTest, HeapHashCountedSetInsert) {}

TEST_F(IncrementalMarkingTest, HeapHashCountedSetSwap) {}

// =============================================================================
// HeapHashMap support. ========================================================
// =============================================================================

TEST_F(IncrementalMarkingTest, HeapHashMapInsertMember) {}

TEST_F(IncrementalMarkingTest, HeapHashMapInsertWeakMember) {}

TEST_F(IncrementalMarkingTest, HeapHashMapInsertMemberWeakMember) {}

TEST_F(IncrementalMarkingTest, HeapHashMapInsertWeakMemberMember) {}

TEST_F(IncrementalMarkingTest, HeapHashMapSetMember) {}

TEST_F(IncrementalMarkingTest, HeapHashMapSetMemberUpdateValue) {}

TEST_F(IncrementalMarkingTest, HeapHashMapIteratorChangeKey) {}

TEST_F(IncrementalMarkingTest, HeapHashMapIteratorChangeValue) {}

TEST_F(IncrementalMarkingTest, HeapHashMapCopyMemberMember) {}

TEST_F(IncrementalMarkingTest, HeapHashMapCopyWeakMemberWeakMember) {}

TEST_F(IncrementalMarkingTest, HeapHashMapCopyMemberWeakMember) {}

TEST_F(IncrementalMarkingTest, HeapHashMapCopyWeakMemberMember) {}

TEST_F(IncrementalMarkingTest, HeapHashMapMoveMember) {}

TEST_F(IncrementalMarkingTest, HeapHashMapMoveWeakMember) {}

TEST_F(IncrementalMarkingTest, HeapHashMapMoveMemberWeakMember) {}

TEST_F(IncrementalMarkingTest, HeapHashMapMoveWeakMemberMember) {}

TEST_F(IncrementalMarkingTest, HeapHashMapSwapMemberMember) {}

TEST_F(IncrementalMarkingTest, HeapHashMapSwapWeakMemberWeakMember) {}

TEST_F(IncrementalMarkingTest, HeapHashMapSwapMemberWeakMember) {}

TEST_F(IncrementalMarkingTest, HeapHashMapSwapWeakMemberMember) {}

TEST_F(IncrementalMarkingTest, HeapHashMapCopyKeysToVectorMember) {}

TEST_F(IncrementalMarkingTest, HeapHashMapCopyValuesToVectorMember) {}

// =============================================================================
// Tests that execute complete incremental garbage collections. ================
// =============================================================================

TEST_F(IncrementalMarkingTest, TestDriver) {}

TEST_F(IncrementalMarkingTest, DropBackingStore) {}

TEST_F(IncrementalMarkingTest, NoBackingFreeDuringIncrementalMarking) {}

TEST_F(IncrementalMarkingTest, DropReferenceWithHeapCompaction) {}

namespace {

class ObjectWithWeakMember : public GarbageCollected<ObjectWithWeakMember> {};

}  // namespace

TEST_F(IncrementalMarkingTest, WeakMember) {}

TEST_F(IncrementalMarkingTest, MemberSwap) {}

namespace {

template <typename T>
class ObjectHolder : public GarbageCollected<ObjectHolder<T>> {};

}  // namespace

TEST_F(IncrementalMarkingTest, StepDuringObjectConstruction) {}

TEST_F(IncrementalMarkingTest, StepDuringMixinObjectConstruction) {}

TEST_F(IncrementalMarkingTest, IncrementalMarkingShrinkingBackingCompaction) {}

TEST_F(IncrementalMarkingTest,
       InPayloadWriteBarrierRegistersInvalidSlotForCompaction) {}

TEST_F(IncrementalMarkingTest, AdjustMarkedBytesOnMarkedBackingStore) {}

TEST_F(IncrementalMarkingTest, HeapCompactWithStaleSlotInNestedContainer) {}

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

size_t Destructed::n_destructed =;

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

TEST_F(IncrementalMarkingTest, LinkedHashSetMovingCallback) {}

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

size_t DestructedAndTraced::n_destructed =;
size_t DestructedAndTraced::n_traced =;

// Flaky <https://crbug.com/1351511>.
#if BUILDFLAG(IS_LINUX)
#define MAYBE_ConservativeGCOfWeakContainer
#else
#define MAYBE_ConservativeGCOfWeakContainer
#endif
TEST_F(IncrementalMarkingTest, MAYBE_ConservativeGCOfWeakContainer) {}

TEST_F(IncrementalMarkingTest,
       WriteBarrierOfWeakContainersStrongifiesBackingStore) {}

TEST_F(IncrementalMarkingTest, NestedVectorsWithInlineCapacityOnStack) {}

}  // namespace incremental_marking_test
}  // namespace blink