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 // Interface between the GC and EE
10 #include "gcinterface.h"
15 static void SuspendEE(SUSPEND_REASON reason);
16 static void RestartEE(bool bFinishedGC); //resume threads.
19 // The GC roots enumeration callback
21 static void GcScanRoots(promote_func* fn, int condemned, int max_gen, ScanContext* sc);
24 // Callbacks issues during GC that the execution engine can do its own bookeeping
27 // start of GC call back - single threaded
28 static void GcStartWork(int condemned, int max_gen);
30 //EE can perform post stack scanning action, while the
31 // user threads are still suspended
32 static void AfterGcScanRoots(int condemned, int max_gen, ScanContext* sc);
34 // Called before BGC starts sweeping, the heap is walkable
35 static void GcBeforeBGCSweepWork();
38 static void GcDone(int condemned);
40 // Promote refcounted handle callback
41 static bool RefCountedHandleCallbacks(Object * pObject);
43 // Sync block cache management
44 static void SyncBlockCacheWeakPtrScan(HANDLESCANPROC scanProc, uintptr_t lp1, uintptr_t lp2);
45 static void SyncBlockCacheDemote(int max_gen);
46 static void SyncBlockCachePromotionsGranted(int max_gen);
47 static uint32_t GetActiveSyncBlockCount();
50 static bool IsPreemptiveGCDisabled();
51 static bool EnablePreemptiveGC();
52 static void DisablePreemptiveGC();
53 static Thread* GetThread();
55 static gc_alloc_context * GetAllocContext();
57 static void GcEnumAllocContexts(enum_alloc_context_func* fn, void* param);
58 // Diagnostics methods.
59 static void DiagGCStart(int gen, bool isInduced);
60 static void DiagUpdateGenerationBounds();
61 static void DiagGCEnd(size_t index, int gen, int reason, bool fConcurrent);
62 static void DiagWalkFReachableObjects(void* gcContext);
63 static void DiagWalkSurvivors(void* gcContext);
64 static void DiagWalkLOHSurvivors(void* gcContext);
65 static void DiagWalkBGCSurvivors(void* gcContext);
66 static void StompWriteBarrier(WriteBarrierParameters* args);
68 static void EnableFinalization(bool foundFinalizers);
70 static void HandleFatalError(unsigned int exitCode);
71 static bool ShouldFinalizeObjectForUnload(AppDomain* pDomain, Object* obj);
72 static bool ForceFullGCToBeBlocking();
73 static bool EagerFinalized(Object* obj);
74 static MethodTable* GetFreeObjectMethodTable();
75 static bool GetBooleanConfigValue(const char* key, bool* value);
76 static bool GetIntConfigValue(const char* key, int64_t* value);
77 static bool GetStringConfigValue(const char* key, const char** value);
78 static void FreeStringConfigValue(const char* key);
79 static bool IsGCThread();
80 static bool WasCurrentThreadCreatedByGC();
81 static bool CreateThread(void (*threadStart)(void*), void* arg, bool is_suspendable, const char* name);
82 static void WalkAsyncPinnedForPromotion(Object* object, ScanContext* sc, promote_func* callback);
83 static void WalkAsyncPinned(Object* object, void* context, void(*callback)(Object*, Object*, void*));
84 static IGCToCLREventSink* EventSink();
87 #endif // __GCENV_EE_H__