1// Licensed to the .NET Foundation under one or more agreements.
2// The .NET Foundation licenses this file to you under the MIT license.
3// See the LICENSE file in the project root for more information.
4
5#ifndef __GCTOENV_EE_STANDALONE_INL__
6#define __GCTOENV_EE_STANDALONE_INL__
7
8#include "gcinterface.h"
9#include "env/gcenv.ee.h"
10
11// The singular interface instance. All calls in GCToEEInterface
12// will be fowarded to this interface instance.
13extern IGCToCLR* g_theGCToCLR;
14
15// When we are building the GC in a standalone environment, we
16// will be dispatching virtually against g_theGCToCLR to call
17// into the EE. This class provides an identical API to the existing
18// GCToEEInterface, but only forwards the call onto the global
19// g_theGCToCLR instance.
20inline void GCToEEInterface::SuspendEE(SUSPEND_REASON reason)
21{
22 assert(g_theGCToCLR != nullptr);
23 g_theGCToCLR->SuspendEE(reason);
24}
25
26inline void GCToEEInterface::RestartEE(bool bFinishedGC)
27{
28 assert(g_theGCToCLR != nullptr);
29 g_theGCToCLR->RestartEE(bFinishedGC);
30}
31
32inline void GCToEEInterface::GcScanRoots(promote_func* fn, int condemned, int max_gen, ScanContext* sc)
33{
34 assert(g_theGCToCLR != nullptr);
35 g_theGCToCLR->GcScanRoots(fn, condemned, max_gen, sc);
36}
37
38inline void GCToEEInterface::GcStartWork(int condemned, int max_gen)
39{
40 assert(g_theGCToCLR != nullptr);
41 g_theGCToCLR->GcStartWork(condemned, max_gen);
42}
43
44inline void GCToEEInterface::AfterGcScanRoots(int condemned, int max_gen, ScanContext* sc)
45{
46 assert(g_theGCToCLR != nullptr);
47 g_theGCToCLR->AfterGcScanRoots(condemned, max_gen, sc);
48}
49
50inline void GCToEEInterface::GcBeforeBGCSweepWork()
51{
52 assert(g_theGCToCLR != nullptr);
53 g_theGCToCLR->GcBeforeBGCSweepWork();
54}
55
56inline void GCToEEInterface::GcDone(int condemned)
57{
58 assert(g_theGCToCLR != nullptr);
59 g_theGCToCLR->GcDone(condemned);
60}
61
62inline bool GCToEEInterface::RefCountedHandleCallbacks(Object * pObject)
63{
64 assert(g_theGCToCLR != nullptr);
65 return g_theGCToCLR->RefCountedHandleCallbacks(pObject);
66}
67
68inline void GCToEEInterface::SyncBlockCacheWeakPtrScan(HANDLESCANPROC scanProc, uintptr_t lp1, uintptr_t lp2)
69{
70 assert(g_theGCToCLR != nullptr);
71 g_theGCToCLR->SyncBlockCacheWeakPtrScan(scanProc, lp1, lp2);
72}
73
74inline void GCToEEInterface::SyncBlockCacheDemote(int max_gen)
75{
76 assert(g_theGCToCLR != nullptr);
77 g_theGCToCLR->SyncBlockCacheDemote(max_gen);
78}
79
80inline void GCToEEInterface::SyncBlockCachePromotionsGranted(int max_gen)
81{
82 assert(g_theGCToCLR != nullptr);
83 g_theGCToCLR->SyncBlockCachePromotionsGranted(max_gen);
84}
85
86inline uint32_t GCToEEInterface::GetActiveSyncBlockCount()
87{
88 assert(g_theGCToCLR != nullptr);
89 return g_theGCToCLR->GetActiveSyncBlockCount();
90}
91
92inline bool GCToEEInterface::IsPreemptiveGCDisabled()
93{
94 assert(g_theGCToCLR != nullptr);
95 return g_theGCToCLR->IsPreemptiveGCDisabled();
96}
97
98inline bool GCToEEInterface::EnablePreemptiveGC()
99{
100 assert(g_theGCToCLR != nullptr);
101 return g_theGCToCLR->EnablePreemptiveGC();
102}
103
104inline void GCToEEInterface::DisablePreemptiveGC()
105{
106 assert(g_theGCToCLR != nullptr);
107 g_theGCToCLR->DisablePreemptiveGC();
108}
109
110inline Thread* GCToEEInterface::GetThread()
111{
112 assert(g_theGCToCLR != nullptr);
113 return g_theGCToCLR->GetThread();
114}
115
116inline gc_alloc_context * GCToEEInterface::GetAllocContext()
117{
118 assert(g_theGCToCLR != nullptr);
119 return g_theGCToCLR->GetAllocContext();
120}
121
122inline void GCToEEInterface::GcEnumAllocContexts(enum_alloc_context_func* fn, void* param)
123{
124 assert(g_theGCToCLR != nullptr);
125 g_theGCToCLR->GcEnumAllocContexts(fn, param);
126}
127
128inline uint8_t *GCToEEInterface::GetLoaderAllocatorObjectForGC(Object* pObject)
129{
130 assert(g_theGCToCLR != nullptr);
131 return g_theGCToCLR->GetLoaderAllocatorObjectForGC(pObject);
132}
133
134inline void GCToEEInterface::DiagGCStart(int gen, bool isInduced)
135{
136 assert(g_theGCToCLR != nullptr);
137 g_theGCToCLR->DiagGCStart(gen, isInduced);
138}
139
140inline void GCToEEInterface::DiagUpdateGenerationBounds()
141{
142 assert(g_theGCToCLR != nullptr);
143 g_theGCToCLR->DiagUpdateGenerationBounds();
144}
145
146inline void GCToEEInterface::DiagGCEnd(size_t index, int gen, int reason, bool fConcurrent)
147{
148 assert(g_theGCToCLR != nullptr);
149 g_theGCToCLR->DiagGCEnd(index, gen, reason, fConcurrent);
150}
151
152inline void GCToEEInterface::DiagWalkFReachableObjects(void* gcContext)
153{
154 assert(g_theGCToCLR != nullptr);
155 g_theGCToCLR->DiagWalkFReachableObjects(gcContext);
156}
157
158inline void GCToEEInterface::DiagWalkSurvivors(void* gcContext)
159{
160 assert(g_theGCToCLR != nullptr);
161 g_theGCToCLR->DiagWalkSurvivors(gcContext);
162}
163
164inline void GCToEEInterface::DiagWalkLOHSurvivors(void* gcContext)
165{
166 assert(g_theGCToCLR != nullptr);
167 g_theGCToCLR->DiagWalkLOHSurvivors(gcContext);
168}
169
170inline void GCToEEInterface::DiagWalkBGCSurvivors(void* gcContext)
171{
172 assert(g_theGCToCLR != nullptr);
173 return g_theGCToCLR->DiagWalkBGCSurvivors(gcContext);
174}
175
176inline void GCToEEInterface::StompWriteBarrier(WriteBarrierParameters* args)
177{
178 assert(g_theGCToCLR != nullptr);
179 g_theGCToCLR->StompWriteBarrier(args);
180}
181
182inline void GCToEEInterface::EnableFinalization(bool foundFinalizers)
183{
184 assert(g_theGCToCLR != nullptr);
185 g_theGCToCLR->EnableFinalization(foundFinalizers);
186}
187
188inline void GCToEEInterface::HandleFatalError(unsigned int exitCode)
189{
190 assert(g_theGCToCLR != nullptr);
191 g_theGCToCLR->HandleFatalError(exitCode);
192}
193
194inline bool GCToEEInterface::ShouldFinalizeObjectForUnload(void* pDomain, Object* obj)
195{
196 assert(g_theGCToCLR != nullptr);
197 return g_theGCToCLR->ShouldFinalizeObjectForUnload(pDomain, obj);
198}
199
200inline bool GCToEEInterface::EagerFinalized(Object* obj)
201{
202 assert(g_theGCToCLR != nullptr);
203 return g_theGCToCLR->EagerFinalized(obj);
204}
205
206inline MethodTable* GCToEEInterface::GetFreeObjectMethodTable()
207{
208 assert(g_theGCToCLR != nullptr);
209 return g_theGCToCLR->GetFreeObjectMethodTable();
210}
211
212inline bool GCToEEInterface::GetBooleanConfigValue(const char* key, bool* value)
213{
214 assert(g_theGCToCLR != nullptr);
215 return g_theGCToCLR->GetBooleanConfigValue(key, value);
216}
217
218inline bool GCToEEInterface::GetIntConfigValue(const char* key, int64_t* value)
219{
220 assert(g_theGCToCLR != nullptr);
221 return g_theGCToCLR->GetIntConfigValue(key, value);
222}
223
224inline bool GCToEEInterface::GetStringConfigValue(const char* key, const char** value)
225{
226 assert(g_theGCToCLR != nullptr);
227 return g_theGCToCLR->GetStringConfigValue(key, value);
228}
229
230inline void GCToEEInterface::FreeStringConfigValue(const char* value)
231{
232 assert(g_theGCToCLR != nullptr);
233 g_theGCToCLR->FreeStringConfigValue(value);
234}
235
236inline bool GCToEEInterface::IsGCThread()
237{
238 assert(g_theGCToCLR != nullptr);
239 return g_theGCToCLR->IsGCThread();
240}
241
242inline bool GCToEEInterface::WasCurrentThreadCreatedByGC()
243{
244 assert(g_theGCToCLR != nullptr);
245 return g_theGCToCLR->WasCurrentThreadCreatedByGC();
246}
247
248inline bool GCToEEInterface::CreateThread(void (*threadStart)(void*), void* arg, bool is_suspendable, const char* name)
249{
250 assert(g_theGCToCLR != nullptr);
251 return g_theGCToCLR->CreateThread(threadStart, arg, is_suspendable, name);
252}
253
254inline void GCToEEInterface::WalkAsyncPinnedForPromotion(Object* object, ScanContext* sc, promote_func* callback)
255{
256 assert(g_theGCToCLR != nullptr);
257 return g_theGCToCLR->WalkAsyncPinnedForPromotion(object, sc, callback);
258}
259
260inline void GCToEEInterface::WalkAsyncPinned(Object* object, void* context, void(*callback)(Object*, Object*, void*))
261{
262 assert(g_theGCToCLR != nullptr);
263 return g_theGCToCLR->WalkAsyncPinned(object, context, callback);
264}
265
266inline IGCToCLREventSink* GCToEEInterface::EventSink()
267{
268 assert(g_theGCToCLR != nullptr);
269 return g_theGCToCLR->EventSink();
270}
271
272inline uint32_t GCToEEInterface::GetDefaultDomainIndex()
273{
274 assert(g_theGCToCLR != nullptr);
275 return g_theGCToCLR->GetDefaultDomainIndex();
276}
277
278inline void *GCToEEInterface::GetAppDomainAtIndex(uint32_t appDomainIndex)
279{
280 assert(g_theGCToCLR != nullptr);
281 return g_theGCToCLR->GetAppDomainAtIndex(appDomainIndex);
282}
283
284inline bool GCToEEInterface::AppDomainCanAccessHandleTable(uint32_t appDomainID)
285{
286 assert(g_theGCToCLR != nullptr);
287 return g_theGCToCLR->AppDomainCanAccessHandleTable(appDomainID);
288}
289
290inline uint32_t GCToEEInterface::GetIndexOfAppDomainBeingUnloaded()
291{
292 assert(g_theGCToCLR != nullptr);
293 return g_theGCToCLR->GetIndexOfAppDomainBeingUnloaded();
294}
295
296inline uint32_t GCToEEInterface::GetTotalNumSizedRefHandles()
297{
298 assert(g_theGCToCLR != nullptr);
299 return g_theGCToCLR->GetTotalNumSizedRefHandles();
300}
301
302inline bool GCToEEInterface::AppDomainIsRudeUnload(void *appDomain)
303{
304 assert(g_theGCToCLR != nullptr);
305 return g_theGCToCLR->AppDomainIsRudeUnload(appDomain);
306}
307
308inline bool GCToEEInterface::AnalyzeSurvivorsRequested(int condemnedGeneration)
309{
310 assert(g_theGCToCLR != nullptr);
311 return g_theGCToCLR->AnalyzeSurvivorsRequested(condemnedGeneration);
312}
313
314inline void GCToEEInterface::AnalyzeSurvivorsFinished(int condemnedGeneration)
315{
316 assert(g_theGCToCLR != nullptr);
317 g_theGCToCLR->AnalyzeSurvivorsFinished(condemnedGeneration);
318}
319
320inline void GCToEEInterface::VerifySyncTableEntry()
321{
322 assert(g_theGCToCLR != nullptr);
323 g_theGCToCLR->VerifySyncTableEntry();
324}
325
326#endif // __GCTOENV_EE_STANDALONE_INL__
327