UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
VVMMarkStack.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#if WITH_VERSE_VM || defined(__INTELLISENSE__)
6
7#include "UObject/Object.h"
9#include "VVMHeap.h"
10#include <Containers/Array.h>
11
12namespace UE::GC
13{
15}
16
17namespace Verse
18{
19struct VCell;
20
21struct FMarkStack
22{
23 FMarkStack() = default;
24
25 // It's illegal to destroy a mark stack that has anything in it.
27
28 bool IsEmpty() const
29 {
30 return Stack.IsEmpty();
31 }
32
33 size_t Num() const
34 {
35 return Stack.Num();
36 }
37
38 VCell* Pop()
39 {
40 if (IsEmpty())
41 {
42 return nullptr;
43 }
44 else
45 {
46 return Stack.Pop(EAllowShrinking::No);
47 }
48 }
49
50 bool TryMarkNonNull(const VCell* Cell)
51 {
52 if (!FHeap::IsMarked(Cell))
53 {
55 return true;
56 }
57 return false;
58 }
59
60 void MarkNonNull(const VCell* Cell)
61 {
62 if (!FHeap::IsMarked(Cell))
63 {
65 }
66 }
67
68 void FencedMarkNonNull(const VCell* Cell)
69 {
70 if (!FHeap::IsMarked(Cell))
71 {
73 }
74 }
75
76 void Mark(const VCell* Cell)
77 {
78 if (Cell)
79 {
81 }
82 }
83
84 void MarkAuxNonNull(const void* Aux)
85 {
86 if (!FHeap::IsMarked(Aux))
87 {
89 }
90 }
91
92 void FencedMarkAuxNonNull(const void* Aux)
93 {
94 if (!FHeap::IsMarked(Aux))
95 {
97 }
98 }
99
100 void MarkAux(const void* Aux)
101 {
102 if (Aux)
103 {
105 }
106 }
107
108 void MarkNonNull(const UObject* Object)
109 {
110 if (ensure(UE::GC::GIsFrankenGCCollecting))
111 {
112 Object->VerseMarkAsReachable();
113 }
114 }
115
116 void Mark(const UObject* Object)
117 {
118 if (Object)
119 {
121 }
122 }
123
124 void Append(FMarkStack&& Other)
125 {
126 Stack.Append(MoveTemp(Other.Stack));
127 }
128
129 void ReportNativeBytes(size_t Bytes)
130 {
131 FHeap::ReportMarkedNativeBytes(Bytes);
132 }
133
134private:
135 template <std::memory_order MemoryOrder>
136 void MarkSlowImpl(const VCell* Cell);
137
138 COREUOBJECT_API void MarkSlow(const VCell* Cell);
140
141 template <std::memory_order MemoryOrder>
142 void MarkAuxSlowImpl(const void* Aux);
143
144 COREUOBJECT_API void MarkAuxSlow(const void* Aux);
145 COREUOBJECT_API void FencedMarkAuxSlow(const void* Aux);
146
147 TArray<VCell*> Stack;
148};
149
150} // namespace Verse
151#endif // WITH_VERSE_VM
#define ensure( InExpression)
Definition AssertionMacros.h:464
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
@ Num
Definition MetalRHIPrivate.h:234
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
Definition Array.h:670
Definition Object.h:95
Definition GCObjectReferencer.cpp:27
Definition Archive.h:36