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.
5 #ifndef __GCTOENV_EE_STANDALONE_INL__
6 #define __GCTOENV_EE_STANDALONE_INL__
8 #include "gcinterface.h"
9 #include "env/gcenv.ee.h"
11 // The singular interface instance. All calls in GCToEEInterface
12 // will be fowarded to this interface instance.
13 extern IGCToCLR* g_theGCToCLR;
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.
20 inline void GCToEEInterface::SuspendEE(SUSPEND_REASON reason)
22 assert(g_theGCToCLR != nullptr);
23 g_theGCToCLR->SuspendEE(reason);
26 inline void GCToEEInterface::RestartEE(bool bFinishedGC)
28 assert(g_theGCToCLR != nullptr);
29 g_theGCToCLR->RestartEE(bFinishedGC);
32 inline void GCToEEInterface::GcScanRoots(promote_func* fn, int condemned, int max_gen, ScanContext* sc)
34 assert(g_theGCToCLR != nullptr);
35 g_theGCToCLR->GcScanRoots(fn, condemned, max_gen, sc);
38 inline void GCToEEInterface::GcStartWork(int condemned, int max_gen)
40 assert(g_theGCToCLR != nullptr);
41 g_theGCToCLR->GcStartWork(condemned, max_gen);
44 inline void GCToEEInterface::AfterGcScanRoots(int condemned, int max_gen, ScanContext* sc)
46 assert(g_theGCToCLR != nullptr);
47 g_theGCToCLR->AfterGcScanRoots(condemned, max_gen, sc);
50 inline void GCToEEInterface::GcBeforeBGCSweepWork()
52 assert(g_theGCToCLR != nullptr);
53 g_theGCToCLR->GcBeforeBGCSweepWork();
56 inline void GCToEEInterface::GcDone(int condemned)
58 assert(g_theGCToCLR != nullptr);
59 g_theGCToCLR->GcDone(condemned);
62 inline bool GCToEEInterface::RefCountedHandleCallbacks(Object * pObject)
64 assert(g_theGCToCLR != nullptr);
65 return g_theGCToCLR->RefCountedHandleCallbacks(pObject);
68 inline void GCToEEInterface::SyncBlockCacheWeakPtrScan(HANDLESCANPROC scanProc, uintptr_t lp1, uintptr_t lp2)
70 assert(g_theGCToCLR != nullptr);
71 g_theGCToCLR->SyncBlockCacheWeakPtrScan(scanProc, lp1, lp2);
74 inline void GCToEEInterface::SyncBlockCacheDemote(int max_gen)
76 assert(g_theGCToCLR != nullptr);
77 g_theGCToCLR->SyncBlockCacheDemote(max_gen);
80 inline void GCToEEInterface::SyncBlockCachePromotionsGranted(int max_gen)
82 assert(g_theGCToCLR != nullptr);
83 g_theGCToCLR->SyncBlockCachePromotionsGranted(max_gen);
86 inline uint32_t GCToEEInterface::GetActiveSyncBlockCount()
88 assert(g_theGCToCLR != nullptr);
89 return g_theGCToCLR->GetActiveSyncBlockCount();
92 inline bool GCToEEInterface::IsPreemptiveGCDisabled()
94 assert(g_theGCToCLR != nullptr);
95 return g_theGCToCLR->IsPreemptiveGCDisabled();
98 inline bool GCToEEInterface::EnablePreemptiveGC()
100 assert(g_theGCToCLR != nullptr);
101 return g_theGCToCLR->EnablePreemptiveGC();
104 inline void GCToEEInterface::DisablePreemptiveGC()
106 assert(g_theGCToCLR != nullptr);
107 g_theGCToCLR->DisablePreemptiveGC();
110 inline Thread* GCToEEInterface::GetThread()
112 assert(g_theGCToCLR != nullptr);
113 return g_theGCToCLR->GetThread();
116 inline gc_alloc_context * GCToEEInterface::GetAllocContext()
118 assert(g_theGCToCLR != nullptr);
119 return g_theGCToCLR->GetAllocContext();
122 inline void GCToEEInterface::GcEnumAllocContexts(enum_alloc_context_func* fn, void* param)
124 assert(g_theGCToCLR != nullptr);
125 g_theGCToCLR->GcEnumAllocContexts(fn, param);
128 inline void GCToEEInterface::DiagGCStart(int gen, bool isInduced)
130 assert(g_theGCToCLR != nullptr);
131 g_theGCToCLR->DiagGCStart(gen, isInduced);
134 inline void GCToEEInterface::DiagUpdateGenerationBounds()
136 assert(g_theGCToCLR != nullptr);
137 g_theGCToCLR->DiagUpdateGenerationBounds();
140 inline void GCToEEInterface::DiagGCEnd(size_t index, int gen, int reason, bool fConcurrent)
142 assert(g_theGCToCLR != nullptr);
143 g_theGCToCLR->DiagGCEnd(index, gen, reason, fConcurrent);
146 inline void GCToEEInterface::DiagWalkFReachableObjects(void* gcContext)
148 assert(g_theGCToCLR != nullptr);
149 g_theGCToCLR->DiagWalkFReachableObjects(gcContext);
152 inline void GCToEEInterface::DiagWalkSurvivors(void* gcContext)
154 assert(g_theGCToCLR != nullptr);
155 g_theGCToCLR->DiagWalkSurvivors(gcContext);
158 inline void GCToEEInterface::DiagWalkLOHSurvivors(void* gcContext)
160 assert(g_theGCToCLR != nullptr);
161 g_theGCToCLR->DiagWalkLOHSurvivors(gcContext);
164 inline void GCToEEInterface::DiagWalkBGCSurvivors(void* gcContext)
166 assert(g_theGCToCLR != nullptr);
167 return g_theGCToCLR->DiagWalkBGCSurvivors(gcContext);
170 inline void GCToEEInterface::StompWriteBarrier(WriteBarrierParameters* args)
172 assert(g_theGCToCLR != nullptr);
173 g_theGCToCLR->StompWriteBarrier(args);
176 inline void GCToEEInterface::EnableFinalization(bool foundFinalizers)
178 assert(g_theGCToCLR != nullptr);
179 g_theGCToCLR->EnableFinalization(foundFinalizers);
182 inline void GCToEEInterface::HandleFatalError(unsigned int exitCode)
184 assert(g_theGCToCLR != nullptr);
185 g_theGCToCLR->HandleFatalError(exitCode);
188 inline bool GCToEEInterface::ShouldFinalizeObjectForUnload(AppDomain* pDomain, Object* obj)
190 assert(g_theGCToCLR != nullptr);
191 return g_theGCToCLR->ShouldFinalizeObjectForUnload(pDomain, obj);
194 inline bool GCToEEInterface::ForceFullGCToBeBlocking()
196 assert(g_theGCToCLR != nullptr);
197 return g_theGCToCLR->ForceFullGCToBeBlocking();
200 inline bool GCToEEInterface::EagerFinalized(Object* obj)
202 assert(g_theGCToCLR != nullptr);
203 return g_theGCToCLR->EagerFinalized(obj);
206 inline MethodTable* GCToEEInterface::GetFreeObjectMethodTable()
208 assert(g_theGCToCLR != nullptr);
209 return g_theGCToCLR->GetFreeObjectMethodTable();
212 inline bool GCToEEInterface::GetBooleanConfigValue(const char* key, bool* value)
214 assert(g_theGCToCLR != nullptr);
215 return g_theGCToCLR->GetBooleanConfigValue(key, value);
218 inline bool GCToEEInterface::GetIntConfigValue(const char* key, int64_t* value)
220 assert(g_theGCToCLR != nullptr);
221 return g_theGCToCLR->GetIntConfigValue(key, value);
224 inline bool GCToEEInterface::GetStringConfigValue(const char* key, const char** value)
226 assert(g_theGCToCLR != nullptr);
227 return g_theGCToCLR->GetStringConfigValue(key, value);
230 inline void GCToEEInterface::FreeStringConfigValue(const char* value)
232 assert(g_theGCToCLR != nullptr);
233 g_theGCToCLR->FreeStringConfigValue(value);
236 inline bool GCToEEInterface::IsGCThread()
238 assert(g_theGCToCLR != nullptr);
239 return g_theGCToCLR->IsGCThread();
242 inline bool GCToEEInterface::WasCurrentThreadCreatedByGC()
244 assert(g_theGCToCLR != nullptr);
245 return g_theGCToCLR->WasCurrentThreadCreatedByGC();
248 inline bool GCToEEInterface::CreateThread(void (*threadStart)(void*), void* arg, bool is_suspendable, const char* name)
250 assert(g_theGCToCLR != nullptr);
251 return g_theGCToCLR->CreateThread(threadStart, arg, is_suspendable, name);
254 inline void GCToEEInterface::WalkAsyncPinnedForPromotion(Object* object, ScanContext* sc, promote_func* callback)
256 assert(g_theGCToCLR != nullptr);
257 return g_theGCToCLR->WalkAsyncPinnedForPromotion(object, sc, callback);
260 inline void GCToEEInterface::WalkAsyncPinned(Object* object, void* context, void(*callback)(Object*, Object*, void*))
262 assert(g_theGCToCLR != nullptr);
263 return g_theGCToCLR->WalkAsyncPinned(object, context, callback);
266 inline IGCToCLREventSink* GCToEEInterface::EventSink()
268 assert(g_theGCToCLR != nullptr);
269 return g_theGCToCLR->EventSink();
272 #endif // __GCTOENV_EE_STANDALONE_INL__