Add GetLoaderAllocatorObjectForGC to IGCToCLR (#17443)
[platform/upstream/coreclr.git] / src / gc / gcenv.ee.standalone.inl
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(AppDomain* pDomain, Object* obj)
195 {
196     assert(g_theGCToCLR != nullptr);
197     return g_theGCToCLR->ShouldFinalizeObjectForUnload(pDomain, obj);
198 }
199
200 inline bool GCToEEInterface::ForceFullGCToBeBlocking()
201 {
202     assert(g_theGCToCLR != nullptr);
203     return g_theGCToCLR->ForceFullGCToBeBlocking();
204 }
205
206 inline bool GCToEEInterface::EagerFinalized(Object* obj)
207 {
208     assert(g_theGCToCLR != nullptr);
209     return g_theGCToCLR->EagerFinalized(obj);
210 }
211
212 inline MethodTable* GCToEEInterface::GetFreeObjectMethodTable()
213 {
214     assert(g_theGCToCLR != nullptr);
215     return g_theGCToCLR->GetFreeObjectMethodTable();
216 }
217
218 inline bool GCToEEInterface::GetBooleanConfigValue(const char* key, bool* value)
219 {
220     assert(g_theGCToCLR != nullptr);
221     return g_theGCToCLR->GetBooleanConfigValue(key, value);
222 }
223
224 inline bool GCToEEInterface::GetIntConfigValue(const char* key, int64_t* value)
225 {
226     assert(g_theGCToCLR != nullptr);
227     return g_theGCToCLR->GetIntConfigValue(key, value);
228 }
229
230 inline bool GCToEEInterface::GetStringConfigValue(const char* key, const char** value)
231 {
232     assert(g_theGCToCLR != nullptr);
233     return g_theGCToCLR->GetStringConfigValue(key, value);
234 }
235
236 inline void GCToEEInterface::FreeStringConfigValue(const char* value)
237 {
238     assert(g_theGCToCLR != nullptr);
239     g_theGCToCLR->FreeStringConfigValue(value);
240 }
241
242 inline bool GCToEEInterface::IsGCThread()
243 {
244     assert(g_theGCToCLR != nullptr);
245     return g_theGCToCLR->IsGCThread();
246 }
247
248 inline bool GCToEEInterface::WasCurrentThreadCreatedByGC()
249 {
250     assert(g_theGCToCLR != nullptr);
251     return g_theGCToCLR->WasCurrentThreadCreatedByGC();
252 }
253
254 inline bool GCToEEInterface::CreateThread(void (*threadStart)(void*), void* arg, bool is_suspendable, const char* name)
255 {
256     assert(g_theGCToCLR != nullptr);
257     return g_theGCToCLR->CreateThread(threadStart, arg, is_suspendable, name);
258 }
259
260 inline void GCToEEInterface::WalkAsyncPinnedForPromotion(Object* object, ScanContext* sc, promote_func* callback)
261 {
262     assert(g_theGCToCLR != nullptr);
263     return g_theGCToCLR->WalkAsyncPinnedForPromotion(object, sc, callback);
264 }
265
266 inline void GCToEEInterface::WalkAsyncPinned(Object* object, void* context, void(*callback)(Object*, Object*, void*))
267 {
268     assert(g_theGCToCLR != nullptr);
269     return g_theGCToCLR->WalkAsyncPinned(object, context, callback);
270 }
271
272 inline IGCToCLREventSink* GCToEEInterface::EventSink()
273 {
274     assert(g_theGCToCLR != nullptr);
275     return g_theGCToCLR->EventSink();
276 }
277
278 #endif // __GCTOENV_EE_STANDALONE_INL__