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. |
13 | extern 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. |
20 | inline void GCToEEInterface::SuspendEE(SUSPEND_REASON reason) |
21 | { |
22 | assert(g_theGCToCLR != nullptr); |
23 | g_theGCToCLR->SuspendEE(reason); |
24 | } |
25 | |
26 | inline void GCToEEInterface::RestartEE(bool bFinishedGC) |
27 | { |
28 | assert(g_theGCToCLR != nullptr); |
29 | g_theGCToCLR->RestartEE(bFinishedGC); |
30 | } |
31 | |
32 | inline 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 | |
38 | inline void GCToEEInterface::GcStartWork(int condemned, int max_gen) |
39 | { |
40 | assert(g_theGCToCLR != nullptr); |
41 | g_theGCToCLR->GcStartWork(condemned, max_gen); |
42 | } |
43 | |
44 | inline 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 | |
50 | inline void GCToEEInterface::GcBeforeBGCSweepWork() |
51 | { |
52 | assert(g_theGCToCLR != nullptr); |
53 | g_theGCToCLR->GcBeforeBGCSweepWork(); |
54 | } |
55 | |
56 | inline void GCToEEInterface::GcDone(int condemned) |
57 | { |
58 | assert(g_theGCToCLR != nullptr); |
59 | g_theGCToCLR->GcDone(condemned); |
60 | } |
61 | |
62 | inline bool GCToEEInterface::RefCountedHandleCallbacks(Object * pObject) |
63 | { |
64 | assert(g_theGCToCLR != nullptr); |
65 | return g_theGCToCLR->RefCountedHandleCallbacks(pObject); |
66 | } |
67 | |
68 | inline 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 | |
74 | inline void GCToEEInterface::SyncBlockCacheDemote(int max_gen) |
75 | { |
76 | assert(g_theGCToCLR != nullptr); |
77 | g_theGCToCLR->SyncBlockCacheDemote(max_gen); |
78 | } |
79 | |
80 | inline void GCToEEInterface::SyncBlockCachePromotionsGranted(int max_gen) |
81 | { |
82 | assert(g_theGCToCLR != nullptr); |
83 | g_theGCToCLR->SyncBlockCachePromotionsGranted(max_gen); |
84 | } |
85 | |
86 | inline uint32_t GCToEEInterface::GetActiveSyncBlockCount() |
87 | { |
88 | assert(g_theGCToCLR != nullptr); |
89 | return g_theGCToCLR->GetActiveSyncBlockCount(); |
90 | } |
91 | |
92 | inline bool GCToEEInterface::IsPreemptiveGCDisabled() |
93 | { |
94 | assert(g_theGCToCLR != nullptr); |
95 | return g_theGCToCLR->IsPreemptiveGCDisabled(); |
96 | } |
97 | |
98 | inline bool GCToEEInterface::EnablePreemptiveGC() |
99 | { |
100 | assert(g_theGCToCLR != nullptr); |
101 | return g_theGCToCLR->EnablePreemptiveGC(); |
102 | } |
103 | |
104 | inline void GCToEEInterface::DisablePreemptiveGC() |
105 | { |
106 | assert(g_theGCToCLR != nullptr); |
107 | g_theGCToCLR->DisablePreemptiveGC(); |
108 | } |
109 | |
110 | inline Thread* GCToEEInterface::GetThread() |
111 | { |
112 | assert(g_theGCToCLR != nullptr); |
113 | return g_theGCToCLR->GetThread(); |
114 | } |
115 | |
116 | inline gc_alloc_context * GCToEEInterface::GetAllocContext() |
117 | { |
118 | assert(g_theGCToCLR != nullptr); |
119 | return g_theGCToCLR->GetAllocContext(); |
120 | } |
121 | |
122 | inline void GCToEEInterface::GcEnumAllocContexts(enum_alloc_context_func* fn, void* param) |
123 | { |
124 | assert(g_theGCToCLR != nullptr); |
125 | g_theGCToCLR->GcEnumAllocContexts(fn, param); |
126 | } |
127 | |
128 | inline uint8_t *GCToEEInterface::GetLoaderAllocatorObjectForGC(Object* pObject) |
129 | { |
130 | assert(g_theGCToCLR != nullptr); |
131 | return g_theGCToCLR->GetLoaderAllocatorObjectForGC(pObject); |
132 | } |
133 | |
134 | inline void GCToEEInterface::DiagGCStart(int gen, bool isInduced) |
135 | { |
136 | assert(g_theGCToCLR != nullptr); |
137 | g_theGCToCLR->DiagGCStart(gen, isInduced); |
138 | } |
139 | |
140 | inline void GCToEEInterface::DiagUpdateGenerationBounds() |
141 | { |
142 | assert(g_theGCToCLR != nullptr); |
143 | g_theGCToCLR->DiagUpdateGenerationBounds(); |
144 | } |
145 | |
146 | inline 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 | |
152 | inline void GCToEEInterface::DiagWalkFReachableObjects(void* gcContext) |
153 | { |
154 | assert(g_theGCToCLR != nullptr); |
155 | g_theGCToCLR->DiagWalkFReachableObjects(gcContext); |
156 | } |
157 | |
158 | inline void GCToEEInterface::DiagWalkSurvivors(void* gcContext) |
159 | { |
160 | assert(g_theGCToCLR != nullptr); |
161 | g_theGCToCLR->DiagWalkSurvivors(gcContext); |
162 | } |
163 | |
164 | inline void GCToEEInterface::DiagWalkLOHSurvivors(void* gcContext) |
165 | { |
166 | assert(g_theGCToCLR != nullptr); |
167 | g_theGCToCLR->DiagWalkLOHSurvivors(gcContext); |
168 | } |
169 | |
170 | inline void GCToEEInterface::DiagWalkBGCSurvivors(void* gcContext) |
171 | { |
172 | assert(g_theGCToCLR != nullptr); |
173 | return g_theGCToCLR->DiagWalkBGCSurvivors(gcContext); |
174 | } |
175 | |
176 | inline void GCToEEInterface::StompWriteBarrier(WriteBarrierParameters* args) |
177 | { |
178 | assert(g_theGCToCLR != nullptr); |
179 | g_theGCToCLR->StompWriteBarrier(args); |
180 | } |
181 | |
182 | inline void GCToEEInterface::EnableFinalization(bool foundFinalizers) |
183 | { |
184 | assert(g_theGCToCLR != nullptr); |
185 | g_theGCToCLR->EnableFinalization(foundFinalizers); |
186 | } |
187 | |
188 | inline void GCToEEInterface::HandleFatalError(unsigned int exitCode) |
189 | { |
190 | assert(g_theGCToCLR != nullptr); |
191 | g_theGCToCLR->HandleFatalError(exitCode); |
192 | } |
193 | |
194 | inline bool GCToEEInterface::ShouldFinalizeObjectForUnload(void* pDomain, Object* obj) |
195 | { |
196 | assert(g_theGCToCLR != nullptr); |
197 | return g_theGCToCLR->ShouldFinalizeObjectForUnload(pDomain, obj); |
198 | } |
199 | |
200 | inline bool GCToEEInterface::EagerFinalized(Object* obj) |
201 | { |
202 | assert(g_theGCToCLR != nullptr); |
203 | return g_theGCToCLR->EagerFinalized(obj); |
204 | } |
205 | |
206 | inline MethodTable* GCToEEInterface::GetFreeObjectMethodTable() |
207 | { |
208 | assert(g_theGCToCLR != nullptr); |
209 | return g_theGCToCLR->GetFreeObjectMethodTable(); |
210 | } |
211 | |
212 | inline bool GCToEEInterface::GetBooleanConfigValue(const char* key, bool* value) |
213 | { |
214 | assert(g_theGCToCLR != nullptr); |
215 | return g_theGCToCLR->GetBooleanConfigValue(key, value); |
216 | } |
217 | |
218 | inline bool GCToEEInterface::GetIntConfigValue(const char* key, int64_t* value) |
219 | { |
220 | assert(g_theGCToCLR != nullptr); |
221 | return g_theGCToCLR->GetIntConfigValue(key, value); |
222 | } |
223 | |
224 | inline bool GCToEEInterface::GetStringConfigValue(const char* key, const char** value) |
225 | { |
226 | assert(g_theGCToCLR != nullptr); |
227 | return g_theGCToCLR->GetStringConfigValue(key, value); |
228 | } |
229 | |
230 | inline void GCToEEInterface::FreeStringConfigValue(const char* value) |
231 | { |
232 | assert(g_theGCToCLR != nullptr); |
233 | g_theGCToCLR->FreeStringConfigValue(value); |
234 | } |
235 | |
236 | inline bool GCToEEInterface::IsGCThread() |
237 | { |
238 | assert(g_theGCToCLR != nullptr); |
239 | return g_theGCToCLR->IsGCThread(); |
240 | } |
241 | |
242 | inline bool GCToEEInterface::WasCurrentThreadCreatedByGC() |
243 | { |
244 | assert(g_theGCToCLR != nullptr); |
245 | return g_theGCToCLR->WasCurrentThreadCreatedByGC(); |
246 | } |
247 | |
248 | inline 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 | |
254 | inline 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 | |
260 | inline 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 | |
266 | inline IGCToCLREventSink* GCToEEInterface::EventSink() |
267 | { |
268 | assert(g_theGCToCLR != nullptr); |
269 | return g_theGCToCLR->EventSink(); |
270 | } |
271 | |
272 | inline uint32_t GCToEEInterface::GetDefaultDomainIndex() |
273 | { |
274 | assert(g_theGCToCLR != nullptr); |
275 | return g_theGCToCLR->GetDefaultDomainIndex(); |
276 | } |
277 | |
278 | inline void *GCToEEInterface::GetAppDomainAtIndex(uint32_t appDomainIndex) |
279 | { |
280 | assert(g_theGCToCLR != nullptr); |
281 | return g_theGCToCLR->GetAppDomainAtIndex(appDomainIndex); |
282 | } |
283 | |
284 | inline bool GCToEEInterface::AppDomainCanAccessHandleTable(uint32_t appDomainID) |
285 | { |
286 | assert(g_theGCToCLR != nullptr); |
287 | return g_theGCToCLR->AppDomainCanAccessHandleTable(appDomainID); |
288 | } |
289 | |
290 | inline uint32_t GCToEEInterface::GetIndexOfAppDomainBeingUnloaded() |
291 | { |
292 | assert(g_theGCToCLR != nullptr); |
293 | return g_theGCToCLR->GetIndexOfAppDomainBeingUnloaded(); |
294 | } |
295 | |
296 | inline uint32_t GCToEEInterface::GetTotalNumSizedRefHandles() |
297 | { |
298 | assert(g_theGCToCLR != nullptr); |
299 | return g_theGCToCLR->GetTotalNumSizedRefHandles(); |
300 | } |
301 | |
302 | inline bool GCToEEInterface::AppDomainIsRudeUnload(void *appDomain) |
303 | { |
304 | assert(g_theGCToCLR != nullptr); |
305 | return g_theGCToCLR->AppDomainIsRudeUnload(appDomain); |
306 | } |
307 | |
308 | inline bool GCToEEInterface::AnalyzeSurvivorsRequested(int condemnedGeneration) |
309 | { |
310 | assert(g_theGCToCLR != nullptr); |
311 | return g_theGCToCLR->AnalyzeSurvivorsRequested(condemnedGeneration); |
312 | } |
313 | |
314 | inline void GCToEEInterface::AnalyzeSurvivorsFinished(int condemnedGeneration) |
315 | { |
316 | assert(g_theGCToCLR != nullptr); |
317 | g_theGCToCLR->AnalyzeSurvivorsFinished(condemnedGeneration); |
318 | } |
319 | |
320 | inline void GCToEEInterface::VerifySyncTableEntry() |
321 | { |
322 | assert(g_theGCToCLR != nullptr); |
323 | g_theGCToCLR->VerifySyncTableEntry(); |
324 | } |
325 | |
326 | #endif // __GCTOENV_EE_STANDALONE_INL__ |
327 | |