Fix build breaks after GC update
authorJan Kotas <jkotas@microsoft.com>
Wed, 9 Dec 2015 01:14:16 +0000 (17:14 -0800)
committerJan Kotas <jkotas@microsoft.com>
Wed, 9 Dec 2015 01:14:16 +0000 (17:14 -0800)
src/vm/gcenv.cpp
src/vm/gcenv.h

index 5188e42..99880b5 100644 (file)
@@ -466,23 +466,11 @@ VOID GCToEEInterface::AfterGcScanRoots (int condemned, int max_gen,
 #endif // FEATURE_COMINTEROP
 }
 
-void GCToEEInterface::ScanStaticGCRefsOpportunistically(promote_func* fn, ScanContext* sc)
-{
-    CONTRACTL
-    {
-        NOTHROW;
-        GC_NOTRIGGER;
-    }
-    CONTRACTL_END;
-
-    SystemDomain::EnumAllStaticGCRefs(fn, sc);
-}
-
 /*
  * Scan all stack roots
  */
  
-VOID GCToEEInterface::ScanStackRoots(Thread * pThread, promote_func* fn, ScanContext* sc)
+static void ScanStackRoots(Thread * pThread, promote_func* fn, ScanContext* sc)
 {
     GCCONTEXT   gcctx;
 
@@ -557,6 +545,40 @@ VOID GCToEEInterface::ScanStackRoots(Thread * pThread, promote_func* fn, ScanCon
     }
 }
 
+void GCToEEInterface::GcScanRoots(promote_func* fn, int condemned, int max_gen, ScanContext* sc)
+{
+    STRESS_LOG1(LF_GCROOTS, LL_INFO10, "GCScan: Promotion Phase = %d\n", sc->promotion);
+
+    // In server GC, we should be competing for marking the statics
+    if (GCHeap::MarkShouldCompeteForStatics())
+    {
+        if (condemned == max_gen && sc->promotion)
+        {
+            SystemDomain::EnumAllStaticGCRefs(fn, sc);
+        }
+    }
+
+    Thread* pThread = NULL;
+    while ((pThread = ThreadStore::GetThreadList(pThread)) != NULL)
+    {
+        STRESS_LOG2(LF_GC | LF_GCROOTS, LL_INFO100, "{ Starting scan of Thread %p ID = %x\n", pThread, pThread->GetThreadId());
+
+        if (GCHeap::GetGCHeap()->IsThreadUsingAllocationContextHeap(
+            GCToEEInterface::GetAllocContext(pThread), sc->thread_number))
+        {
+            sc->thread_under_crawl = pThread;
+#ifdef FEATURE_EVENT_TRACE
+            sc->dwEtwRootKind = kEtwGCRootKindStack;
+#endif // FEATURE_EVENT_TRACE
+            ScanStackRoots(pThread, fn, sc);
+#ifdef FEATURE_EVENT_TRACE
+            sc->dwEtwRootKind = kEtwGCRootKindOther;
+#endif // FEATURE_EVENT_TRACE
+        }
+        STRESS_LOG2(LF_GC | LF_GCROOTS, LL_INFO100, "Ending scan of Thread %p ID = 0x%x }\n", pThread, pThread->GetThreadId());
+    }
+}
+
 void GCToEEInterface::GcStartWork (int condemned, int max_gen)
 {
     CONTRACTL
@@ -689,8 +711,18 @@ bool GCToEEInterface::CatchAtSafePoint(Thread * pThread)
     return !!pThread->CatchAtSafePoint();
 }
 
-Thread * GCToEEInterface::GetThreadList(Thread * pThread)
+void GCToEEInterface::GcEnumAllocContexts(enum_alloc_context_func* fn, void* param)
 {
-    WRAPPER_NO_CONTRACT;
-    return ThreadStore::GetThreadList(pThread);
+    CONTRACTL
+    {
+        NOTHROW;
+        GC_NOTRIGGER;
+    }
+    CONTRACTL_END;
+
+    Thread * pThread = NULL;
+    while ((pThread = ThreadStore::GetThreadList(pThread)) != NULL)
+    {
+        fn(pThread->GetAllocContext(), param);
+    }
 }
index 93d4185..73e6585 100644 (file)
@@ -51,6 +51,8 @@ class CrawlFrame;
 
 typedef void promote_func(PTR_PTR_Object, ScanContext*, uint32_t);
 
+typedef void enum_alloc_context_func(alloc_context*, void*);
+
 typedef struct
 {
     promote_func*  f;
@@ -77,10 +79,7 @@ public:
     // 
     // The GC roots enumeration callback
     //
-    static void ScanStackRoots(Thread * pThread, promote_func* fn, ScanContext* sc);
-
-    // Optional static GC refs scanning for better parallelization of server GC marking
-    static void ScanStaticGCRefsOpportunistically(promote_func* fn, ScanContext* sc);
+    static void GcScanRoots(promote_func* fn, int condemned, int max_gen, ScanContext* sc);
 
     // 
     // Callbacks issues during GC that the execution engine can do its own bookeeping
@@ -130,7 +129,7 @@ public:
     static alloc_context * GetAllocContext(Thread * pThread);
     static bool CatchAtSafePoint(Thread * pThread);
 
-    static Thread * GetThreadList(Thread * pThread);
+    static void GcEnumAllocContexts(enum_alloc_context_func* fn, void* param);
 };
 
 #define GCMemoryStatus MEMORYSTATUSEX