Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Kotas <jkotas@microsoft.com>2015-12-08 09:52:15 +0300
committerJan Kotas <jkotas@microsoft.com>2015-12-08 09:52:15 +0300
commit7be6983a6510ef00de78f4c1c8bf884a89e7c82a (patch)
tree5b17d08e6a343fde60d5ed9b8e9d579e3b7dd60b /src/Native
parentadd07f848fa3611427d946b4db4d2c4164a85357 (diff)
Remove redundant code in gcrhscan.cpp
- Add gc\gcscan.cpp to the build and remove code that was redundant with it from runtime\gcrhscan.cpp - Move the entire stack root scanning to the EE side of GCToEEInterface
Diffstat (limited to 'src/Native')
-rw-r--r--src/Native/Runtime/CMakeLists.txt1
-rw-r--r--src/Native/Runtime/gcrhenv.cpp15
-rw-r--r--src/Native/Runtime/gcrhscan.cpp260
-rw-r--r--src/Native/gc/env/gcenv.base.h11
-rw-r--r--src/Native/gc/env/gcenv.unix.cpp8
-rw-r--r--src/Native/gc/gc.cpp40
-rw-r--r--src/Native/gc/gcscan.cpp71
-rw-r--r--src/Native/gc/gcscan.h9
-rw-r--r--src/Native/gc/sample/GCSample.cpp8
-rw-r--r--src/Native/gc/sample/gcenv.cpp15
10 files changed, 61 insertions, 377 deletions
diff --git a/src/Native/Runtime/CMakeLists.txt b/src/Native/Runtime/CMakeLists.txt
index 82427af24..f56b839fc 100644
--- a/src/Native/Runtime/CMakeLists.txt
+++ b/src/Native/Runtime/CMakeLists.txt
@@ -40,6 +40,7 @@ set(COMMON_RUNTIME_SOURCES
../gc/gccommon.cpp
../gc/gceewks.cpp
../gc/gcwks.cpp
+ ../gc/gcscan.cpp
../gc/handletable.cpp
../gc/handletablecache.cpp
../gc/handletablecore.cpp
diff --git a/src/Native/Runtime/gcrhenv.cpp b/src/Native/Runtime/gcrhenv.cpp
index 8b85bd305..dab53d690 100644
--- a/src/Native/Runtime/gcrhenv.cpp
+++ b/src/Native/Runtime/gcrhenv.cpp
@@ -829,15 +829,6 @@ void GCToEEInterface::RestartEE(bool /*bFinishedGC*/)
FireEtwGCRestartEEEnd_V1(GetClrInstanceId());
}
-void GCToEEInterface::ScanStackRoots(Thread * /*pThread*/, promote_func* /*fn*/, ScanContext* /*sc*/)
-{
- // TODO: Implement - Scan stack roots on given thread
-}
-
-void GCToEEInterface::ScanStaticGCRefsOpportunistically(promote_func* /*fn*/, ScanContext* /*sc*/)
-{
-}
-
void GCToEEInterface::GcStartWork(int condemned, int /*max_gen*/)
{
// Invoke any registered callouts for the start of the collection.
@@ -884,12 +875,6 @@ void GCToEEInterface::AttachCurrentThread()
ThreadStore::AttachCurrentThread(false);
}
-Thread * GCToEEInterface::GetThreadList(Thread * /*pThread*/)
-{
- ASSERT(!"Intentionally not implemented"); // not used on this runtime
- return nullptr;
-}
-
void GCToEEInterface::SetGCSpecial(Thread * pThread)
{
pThread->SetGCSpecial(true);
diff --git a/src/Native/Runtime/gcrhscan.cpp b/src/Native/Runtime/gcrhscan.cpp
index 2a8475ec0..89ff8b69d 100644
--- a/src/Native/Runtime/gcrhscan.cpp
+++ b/src/Native/Runtime/gcrhscan.cpp
@@ -9,9 +9,6 @@
#include "gc.h"
#include "objecthandle.h"
-#include "RestrictedCallouts.h"
-
-
#include "PalRedhawkCommon.h"
#include "gcrhinterface.h"
@@ -29,83 +26,18 @@
#include "threadstore.h"
-// todo: remove this hack (brain-dead logging).
-#define PalPrintf __noop
-
-//#define CATCH_GC //catches exception during GC
-#ifdef DACCESS_COMPILE
-SVAL_IMPL_INIT(LONG, CNameSpace, m_GcStructuresInvalidCnt, 1);
-#else //DACCESS_COMPILE
-VOLATILE(LONG) CNameSpace::m_GcStructuresInvalidCnt = 1;
-#endif //DACCESS_COMPILE
-
-bool CNameSpace::GetGcRuntimeStructuresValid ()
-{
- _ASSERTE ((LONG)m_GcStructuresInvalidCnt >= 0);
- return (LONG)m_GcStructuresInvalidCnt == 0;
-}
-
#ifndef DACCESS_COMPILE
-VOID CNameSpace::GcStartDoWork()
-{
- PalPrintf("CNameSpace::GcStartDoWork\n");
-}
-
-/*
- * Scan for dead weak pointers
- */
-
-VOID CNameSpace::GcWeakPtrScan( EnumGcRefCallbackFunc* fn, int condemned, int max_gen, EnumGcRefScanContext* sc )
-{
- PalPrintf("CNameSpace::GcWeakPtrScan\n");
- Ref_CheckReachable(condemned, max_gen, (uintptr_t)sc);
- Ref_ScanDependentHandlesForClearing(condemned, max_gen, sc, fn);
-}
-
-static void CALLBACK CheckPromoted(_UNCHECKED_OBJECTREF *pObjRef, uintptr_t * /*pExtraInfo*/, uintptr_t /*lp1*/, uintptr_t /*lp2*/)
-{
- LOG((LF_GC, LL_INFO100000, LOG_HANDLE_OBJECT_CLASS("Checking referent of Weak-", pObjRef, "to ", *pObjRef)));
-
- Object **pRef = (Object **)pObjRef;
- if (!GCHeap::GetGCHeap()->IsPromoted(*pRef))
- {
- LOG((LF_GC, LL_INFO100, LOG_HANDLE_OBJECT_CLASS("Severing Weak-", pObjRef, "to unreachable ", *pObjRef)));
-
- *pRef = NULL;
- }
- else
- {
- LOG((LF_GC, LL_INFO1000000, "reachable " LOG_OBJECT_CLASS(*pObjRef)));
- }
-}
-
-VOID CNameSpace::GcWeakPtrScanBySingleThread( int /*condemned*/, int /*max_gen*/, EnumGcRefScanContext* sc )
-{
- PalPrintf("CNameSpace::GcWeakPtrScanBySingleThread\n");
-#ifdef VERIFY_HEAP
- SyncBlockCache::GetSyncBlockCache()->GCWeakPtrScan(&CheckPromoted, (uintptr_t)sc, 0);
-#endif // VERIFY_HEAP
-}
-
-VOID CNameSpace::GcShortWeakPtrScan(EnumGcRefCallbackFunc* /*fn*/, int condemned, int max_gen, EnumGcRefScanContext* sc)
-{
- PalPrintf("CNameSpace::GcShortWeakPtrScan\n");
- Ref_CheckAlive(condemned, max_gen, (uintptr_t)sc);
-}
-
-
void EnumAllStaticGCRefs(EnumGcRefCallbackFunc * fn, EnumGcRefScanContext * sc)
{
GetRuntimeInstance()->EnumAllStaticGCRefs(fn, sc);
}
-
/*
* Scan all stack roots in this 'namespace'
*/
-VOID CNameSpace::GcScanRoots(EnumGcRefCallbackFunc * fn, int condemned, int max_gen, EnumGcRefScanContext * sc)
+VOID GCToEEInterface::GcScanRoots(EnumGcRefCallbackFunc * fn, int condemned, int max_gen, EnumGcRefScanContext * sc)
{
PalPrintf("CNameSpace::GcScanRoots\n");
@@ -156,105 +88,7 @@ VOID CNameSpace::GcScanRoots(EnumGcRefCallbackFunc * fn, int condemned, int max
}
}
-/*
- * Scan all handle roots in this 'namespace'
- */
-
-
-VOID CNameSpace::GcScanHandles (EnumGcRefCallbackFunc* fn, int condemned, int max_gen, EnumGcRefScanContext* sc)
-{
- PalPrintf("CNameSpace::GcScanHandles\n");
-
- STRESS_LOG1(LF_GC|LF_GCROOTS, LL_INFO10, "GcScanHandles (Promotion Phase = %d)\n", sc->promotion);
- if (sc->promotion)
- {
- Ref_TracePinningRoots(condemned, max_gen, sc, fn);
- Ref_TraceNormalRoots(condemned, max_gen, sc, fn);
- }
- else
- {
- Ref_UpdatePointers(condemned, max_gen, sc, fn);
- Ref_UpdatePinnedPointers(condemned, max_gen, sc, fn);
- Ref_ScanDependentHandlesForRelocation(condemned, max_gen, sc, fn);
- }
-}
-
-#if defined(GC_PROFILING) || defined(FEATURE_EVENT_TRACE)
-
-/*
- * Scan all handle roots in this 'namespace' for profiling
- */
-
-VOID CNameSpace::GcScanHandlesForProfilerAndETW (int max_gen, EnumGcRefScanContext* sc)
-{
- LOG((LF_GC|LF_GCROOTS, LL_INFO10, "Profiler Root Scan Phase, Handles\n"));
- Ref_ScanPointersForProfilerAndETW(max_gen, (uintptr_t)sc);
-}
-
-/*
- * Scan dependent handles in this 'namespace' for profiling
- */
-void CNameSpace::GcScanDependentHandlesForProfilerAndETW (int max_gen, ProfilingScanContext* sc)
-{
- LIMITED_METHOD_CONTRACT;
-
- LOG((LF_GC|LF_GCROOTS, LL_INFO10, "Profiler Root Scan Phase, DependentHandles\n"));
- Ref_ScanDependentHandlesForProfilerAndETW(max_gen, sc);
-}
-
-#endif // defined(GC_PROFILING) || defined(FEATURE_EVENT_TRACE)
-
-void CNameSpace::GcRuntimeStructuresValid (BOOL bValid)
-{
- if (!bValid)
- {
- LONG result;
- result = FastInterlockIncrement(&m_GcStructuresInvalidCnt);
- _ASSERTE (result > 0);
- }
- else
- {
- LONG result;
- result = FastInterlockDecrement(&m_GcStructuresInvalidCnt);
- _ASSERTE (result >= 0);
- }
-}
-
-void CNameSpace::GcDemote (int condemned, int max_gen, EnumGcRefScanContext* sc)
-{
- PalPrintf("CNameSpace::GcDemote\n");
- Ref_RejuvenateHandles (condemned, max_gen, (uintptr_t)sc);
-#ifdef VERIFY_HEAP
- if (!GCHeap::IsServerHeap() || sc->thread_number == 0)
- SyncBlockCache::GetSyncBlockCache()->GCDone(TRUE, max_gen);
-#endif // VERIFY_HEAP
-}
-
-void CNameSpace::GcPromotionsGranted (int condemned, int max_gen, EnumGcRefScanContext* sc)
-{
- PalPrintf("CNameSpace::GcPromotionsGranted\n");
- Ref_AgeHandles(condemned, max_gen, (uintptr_t)sc);
-#ifdef VERIFY_HEAP
- if (!GCHeap::IsServerHeap() || sc->thread_number == 0)
- SyncBlockCache::GetSyncBlockCache()->GCDone(FALSE, max_gen);
-#endif // VERIFY_HEAP
-}
-
-
-void CNameSpace::GcFixAllocContexts (void* arg, void *heap)
-{
- PalPrintf("CNameSpace::GcFixAllocContexts\n");
- if (GCHeap::UseAllocationContexts())
- {
- FOREACH_THREAD(thread)
- {
- GCHeap::GetGCHeap()->FixAllocContext(thread->GetAllocContext(), FALSE, arg, heap);
- }
- END_FOREACH_THREAD
- }
-}
-
-void CNameSpace::GcEnumAllocContexts (enum_alloc_context_func* fn)
+void GCToEEInterface::GcEnumAllocContexts (enum_alloc_context_func* fn, void* param)
{
PalPrintf("CNameSpace::GcEnumAllocContexts\n");
@@ -262,26 +96,12 @@ void CNameSpace::GcEnumAllocContexts (enum_alloc_context_func* fn)
{
FOREACH_THREAD(thread)
{
- (*fn) (thread->GetAllocContext());
+ (*fn) (thread->GetAllocContext(), param);
}
END_FOREACH_THREAD
}
}
-size_t CNameSpace::AskForMoreReservedMemory (size_t old_size, size_t need_size)
-{
- PalPrintf("CNameSpace::AskForMoreReservedMemory\n");
-
- return old_size + need_size;
-}
-
-void CNameSpace::VerifyHandleTable(int condemned, int max_gen, EnumGcRefScanContext *sc)
-{
- PalPrintf("CNameSpace::VerifyHandleTable\n");
-
- Ref_VerifyHandleTable(condemned, max_gen, sc);
-}
-
#endif //!DACCESS_COMPILE
void PromoteCarefully(PTR_PTR_Object obj, UInt32 flags, EnumGcRefCallbackFunc * fnGcEnumRef, EnumGcRefScanContext * pSc)
@@ -350,77 +170,3 @@ void GcEnumObjectsConservatively(PTR_PTR_Object ppLowerBound, PTR_PTR_Object ppU
}
}
}
-
-#ifndef DACCESS_COMPILE
-
-//
-// Dependent handle promotion scan support
-//
-
-// This method is called first during the mark phase. It's job is to set up the context for further scanning
-// (remembering the scan parameters the GC gives us and initializing some state variables we use to determine
-// whether further scans will be required or not).
-//
-// This scan is not guaranteed to return complete results due to the GC context in which we are called. In
-// particular it is possible, due to either a mark stack overflow or unsynchronized operation in server GC
-// mode, that not all reachable objects will be reported as promoted yet. However, the operations we perform
-// will still be correct and this scan allows us to spot a common optimization where no dependent handles are
-// due for retirement in this particular GC. This is an important optimization to take advantage of since
-// synchronizing the GC to calculate complete results is a costly operation.
-void CNameSpace::GcDhInitialScan(EnumGcRefCallbackFunc* fn, int condemned, int max_gen, EnumGcRefScanContext* sc)
-{
- // We allocate space for dependent handle scanning context during Ref_Initialize. Under server GC there
- // are actually as many contexts as heaps (and CPUs). Ref_GetDependentHandleContext() retrieves the
- // correct context for the current GC thread based on the ScanContext passed to us by the GC.
- DhContext *pDhContext = Ref_GetDependentHandleContext(sc);
-
- // Record GC callback parameters in the DH context so that the GC doesn't continually have to pass the
- // same data to each call.
- pDhContext->m_pfnPromoteFunction = fn;
- pDhContext->m_iCondemned = condemned;
- pDhContext->m_iMaxGen = max_gen;
- pDhContext->m_pScanContext = sc;
-
- // Look for dependent handle whose primary has been promoted but whose secondary has not. Promote the
- // secondary in those cases. Additionally this scan sets the m_fUnpromotedPrimaries and m_fPromoted state
- // flags in the DH context. The m_fUnpromotedPrimaries flag is the most interesting here: if this flag is
- // false after the scan then it doesn't matter how many object promotions might currently be missing since
- // there are no secondary objects that are currently unpromoted anyway. This is the (hopefully common)
- // circumstance under which we don't have to perform any costly additional re-scans.
- Ref_ScanDependentHandlesForPromotion(pDhContext);
-}
-
-// This method is called after GcDhInitialScan and before each subsequent scan (GcDhReScan below). It
-// determines whether any handles are left that have unpromoted secondaries.
-bool CNameSpace::GcDhUnpromotedHandlesExist(EnumGcRefScanContext* sc)
-{
- // Locate our dependent handle context based on the GC context.
- DhContext *pDhContext = Ref_GetDependentHandleContext(sc);
-
- return pDhContext->m_fUnpromotedPrimaries;
-}
-
-// Perform a re-scan of dependent handles, promoting secondaries associated with newly promoted primaries as
-// above. We may still need to call this multiple times since promotion of a secondary late in the table could
-// promote a primary earlier in the table. Also, GC graph promotions are not guaranteed to be complete by the
-// time the promotion callback returns (the mark stack can overflow). As a result the GC might have to call
-// this method in a loop. The scan records state that let's us know when to terminate (no further handles to
-// be promoted or no promotions in the last scan). Returns true if at least one object was promoted as a
-// result of the scan.
-bool CNameSpace::GcDhReScan(EnumGcRefScanContext* sc)
-{
- // Locate our dependent handle context based on the GC context.
- DhContext *pDhContext = Ref_GetDependentHandleContext(sc);
-
- return Ref_ScanDependentHandlesForPromotion(pDhContext);
-}
-
-//
-// Sized refs support (not supported on Redhawk)
-//
-
-void CNameSpace::GcScanSizedRefs(EnumGcRefCallbackFunc* /*fn*/, int /*condemned*/, int /*max_gen*/, EnumGcRefScanContext* /*sc*/)
-{
-}
-
-#endif // !DACCESS_COMPILE
diff --git a/src/Native/gc/env/gcenv.base.h b/src/Native/gc/env/gcenv.base.h
index 57fbb0460..5b8f5f7dd 100644
--- a/src/Native/gc/env/gcenv.base.h
+++ b/src/Native/gc/env/gcenv.base.h
@@ -602,6 +602,8 @@ typedef void promote_func(PTR_PTR_Object, ScanContext*, uint32_t);
typedef void (CALLBACK *HANDLESCANPROC)(PTR_UNCHECKED_OBJECTREF pref, uintptr_t *pExtraInfo, uintptr_t param1, uintptr_t param2);
+typedef void enum_alloc_context_func(alloc_context*, void*);
+
class GCToEEInterface
{
public:
@@ -620,10 +622,7 @@ public:
//
// The stack 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
@@ -655,12 +654,12 @@ public:
static void EnablePreemptiveGC(Thread * pThread);
static void DisablePreemptiveGC(Thread * pThread);
static void SetGCSpecial(Thread * pThread);
- static alloc_context * GetAllocContext(Thread * pThread);
static bool CatchAtSafePoint(Thread * pThread);
+ static alloc_context * GetAllocContext(Thread * pThread);
// ThreadStore functions
static void AttachCurrentThread(); // does not acquire thread store lock
- static Thread * GetThreadList(Thread * pThread);
+ static void GcEnumAllocContexts (enum_alloc_context_func* fn, void* param);
};
class FinalizerThread
diff --git a/src/Native/gc/env/gcenv.unix.cpp b/src/Native/gc/env/gcenv.unix.cpp
index 8c99bc872..30ad1d714 100644
--- a/src/Native/gc/env/gcenv.unix.cpp
+++ b/src/Native/gc/env/gcenv.unix.cpp
@@ -385,13 +385,9 @@ void GCToEEInterface::RestartEE(bool bFinishedGC)
GCHeap::GetGCHeap()->SetGCInProgress(FALSE);
}
-void GCToEEInterface::ScanStackRoots(Thread * pThread, promote_func* fn, ScanContext* sc)
-{
- // TODO: Implement - Scan stack roots on given thread
-}
-
-void GCToEEInterface::ScanStaticGCRefsOpportunistically(promote_func* fn, ScanContext* sc)
+void GCToEEInterface::GcScanRoots(promote_func* fn, int condemned, int max_gen, ScanContext* sc)
{
+ // TODO: Implement - Scan stack roots
}
void GCToEEInterface::GcStartWork(int condemned, int max_gen)
diff --git a/src/Native/gc/gc.cpp b/src/Native/gc/gc.cpp
index aa7ac15e2..33025e62f 100644
--- a/src/Native/gc/gc.cpp
+++ b/src/Native/gc/gc.cpp
@@ -5764,7 +5764,7 @@ void gc_heap::fix_allocation_context (alloc_context* acontext, BOOL for_gc_p,
//used by the heap verification for concurrent gc.
//it nulls out the words set by fix_allocation_context for heap_verification
-void repair_allocation (alloc_context* acontext)
+void repair_allocation (alloc_context* acontext, void*)
{
uint8_t* point = acontext->alloc_ptr;
@@ -5777,7 +5777,7 @@ void repair_allocation (alloc_context* acontext)
}
}
-void void_allocation (alloc_context* acontext)
+void void_allocation (alloc_context* acontext, void*)
{
uint8_t* point = acontext->alloc_ptr;
@@ -5790,22 +5790,38 @@ void void_allocation (alloc_context* acontext)
}
}
-void gc_heap::fix_allocation_contexts (BOOL for_gc_p)
-{
- CNameSpace::GcFixAllocContexts ((void*)(size_t)for_gc_p, __this);
- fix_youngest_allocation_area (for_gc_p);
- fix_large_allocation_area (for_gc_p);
-}
-
void gc_heap::repair_allocation_contexts (BOOL repair_p)
{
- CNameSpace::GcEnumAllocContexts (repair_p ? repair_allocation : void_allocation);
+ GCToEEInterface::GcEnumAllocContexts (repair_p ? repair_allocation : void_allocation, NULL);
alloc_context* acontext = generation_alloc_context (youngest_generation);
if (repair_p)
- repair_allocation (acontext);
+ repair_allocation (acontext, NULL);
else
- void_allocation (acontext);
+ void_allocation (acontext, NULL);
+}
+
+struct fix_alloc_context_args
+{
+ BOOL for_gc_p;
+ void* heap;
+};
+
+void fix_alloc_context(alloc_context* acontext, void* param)
+{
+ fix_alloc_context_args* args = (fix_alloc_context_args*)param;
+ GCHeap::GetGCHeap()->FixAllocContext(acontext, FALSE, (void*)(size_t)(args->for_gc_p), args->heap);
+}
+
+void gc_heap::fix_allocation_contexts(BOOL for_gc_p)
+{
+ fix_alloc_context_args args;
+ args.for_gc_p = for_gc_p;
+ args.heap = __this;
+ GCToEEInterface::GcEnumAllocContexts(fix_alloc_context, &args);
+
+ fix_youngest_allocation_area(for_gc_p);
+ fix_large_allocation_area(for_gc_p);
}
void gc_heap::fix_older_allocation_area (generation* older_gen)
diff --git a/src/Native/gc/gcscan.cpp b/src/Native/gc/gcscan.cpp
index 0bf039702..036d60ee9 100644
--- a/src/Native/gc/gcscan.cpp
+++ b/src/Native/gc/gcscan.cpp
@@ -36,11 +36,16 @@ bool CNameSpace::GetGcRuntimeStructuresValid ()
}
#ifdef DACCESS_COMPILE
+
+#ifndef FEATURE_REDHAWK
void
CNameSpace::EnumMemoryRegions(CLRDataEnumMemoryFlags flags)
{
+ UNREFERENCED_PARAMETER(flags);
m_GcStructuresInvalidCnt.EnumMem();
}
+#endif
+
#else
//
@@ -119,7 +124,7 @@ void CNameSpace::GcWeakPtrScan( promote_func* fn, int condemned, int max_gen, Sc
Ref_ScanDependentHandlesForClearing(condemned, max_gen, sc, fn);
}
-static void CALLBACK CheckPromoted(_UNCHECKED_OBJECTREF *pObjRef, uintptr_t *pExtraInfo, uintptr_t lp1, uintptr_t lp2)
+static void CALLBACK CheckPromoted(_UNCHECKED_OBJECTREF *pObjRef, uintptr_t * /*pExtraInfo*/, uintptr_t /*lp1*/, uintptr_t /*lp2*/)
{
LIMITED_METHOD_CONTRACT;
@@ -140,6 +145,8 @@ static void CALLBACK CheckPromoted(_UNCHECKED_OBJECTREF *pObjRef, uintptr_t *pEx
void CNameSpace::GcWeakPtrScanBySingleThread( int condemned, int max_gen, ScanContext* sc )
{
+ UNREFERENCED_PARAMETER(condemned);
+ UNREFERENCED_PARAMETER(max_gen);
GCToEEInterface::SyncBlockCacheWeakPtrScan(&CheckPromoted, (uintptr_t)sc, 0);
}
@@ -151,6 +158,7 @@ void CNameSpace::GcScanSizedRefs(promote_func* fn, int condemned, int max_gen, S
void CNameSpace::GcShortWeakPtrScan(promote_func* fn, int condemned, int max_gen,
ScanContext* sc)
{
+ UNREFERENCED_PARAMETER(fn);
Ref_CheckAlive(condemned, max_gen, (uintptr_t)sc);
}
@@ -166,37 +174,7 @@ void CNameSpace::GcScanRoots(promote_func* fn, int condemned, int max_gen,
PAL_TRY
#endif // _DEBUG && CATCH_GC
{
- 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)
- {
- GCToEEInterface::ScanStaticGCRefsOpportunistically(fn, sc);
- }
- }
-
- Thread* pThread = NULL;
- while ((pThread = GCToEEInterface::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
- GCToEEInterface::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());
- }
- }
+ GCToEEInterface::GcScanRoots(fn, condemned, max_gen, sc);
}
#if defined ( _DEBUG) && defined (CATCH_GC)
PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
@@ -318,35 +296,6 @@ void CNameSpace::GcPromotionsGranted (int condemned, int max_gen, ScanContext* s
}
-void CNameSpace::GcFixAllocContexts (void* arg, void *heap)
-{
- LIMITED_METHOD_CONTRACT;
-
- if (GCHeap::UseAllocationContexts())
- {
- Thread *thread = NULL;
- while ((thread = GCToEEInterface::GetThreadList(thread)) != NULL)
- {
- GCHeap::GetGCHeap()->FixAllocContext(GCToEEInterface::GetAllocContext(thread), FALSE, arg, heap);
- }
- }
-}
-
-void CNameSpace::GcEnumAllocContexts (enum_alloc_context_func* fn)
-{
- LIMITED_METHOD_CONTRACT;
-
- if (GCHeap::UseAllocationContexts())
- {
- Thread *thread = NULL;
- while ((thread = GCToEEInterface::GetThreadList(thread)) != NULL)
- {
- (*fn) (GCToEEInterface::GetAllocContext(thread));
- }
- }
-}
-
-
size_t CNameSpace::AskForMoreReservedMemory (size_t old_size, size_t need_size)
{
LIMITED_METHOD_CONTRACT;
diff --git a/src/Native/gc/gcscan.h b/src/Native/gc/gcscan.h
index 956622abb..0fddf3540 100644
--- a/src/Native/gc/gcscan.h
+++ b/src/Native/gc/gcscan.h
@@ -39,17 +39,12 @@ struct DhContext
// something like GCDomain....
// </TODO>
-typedef void enum_alloc_context_func(alloc_context*);
-
class CNameSpace
{
friend struct ::_DacGlobals;
public:
- // Called on gc start
- static void GcStartDoWork();
-
static void GcScanSizedRefs(promote_func* fn, int condemned, int max_gen, ScanContext* sc);
// Regular stack Roots
@@ -99,10 +94,6 @@ class CNameSpace
// post-promotions callback some roots were demoted
static void GcDemote (int condemned, int max_gen, ScanContext* sc);
-
- static void GcEnumAllocContexts (enum_alloc_context_func* fn);
-
- static void GcFixAllocContexts (void* arg, void *heap);
static size_t AskForMoreReservedMemory (size_t old_size, size_t need_size);
diff --git a/src/Native/gc/sample/GCSample.cpp b/src/Native/gc/sample/GCSample.cpp
index 7ae6c2d11..446956110 100644
--- a/src/Native/gc/sample/GCSample.cpp
+++ b/src/Native/gc/sample/GCSample.cpp
@@ -26,11 +26,11 @@
// static void SuspendEE(SUSPEND_REASON reason);
// static void RestartEE(bool bFinishedGC); //resume threads.
//
-// * Enumeration of threads that are running managed code:
-// static Thread * GetThreadList(Thread * pThread);
+// * Enumeration of thread-local allocators:
+// static void GcEnumAllocContexts (enum_alloc_context_func* fn, void* param);
//
-// * Scanning of stack roots of given thread:
-// static void ScanStackRoots(Thread * pThread, promote_func* fn, ScanContext* sc);
+// * Scanning of stack roots:
+// static void GcScanRoots(promote_func* fn, int condemned, int max_gen, ScanContext* sc);
//
// The sample has trivial implementation for these methods. It is single threaded, and there are no stack roots to
// be reported. There are number of other callbacks that GC calls to optionally allow the execution engine to do its
diff --git a/src/Native/gc/sample/gcenv.cpp b/src/Native/gc/sample/gcenv.cpp
index 48608e216..d213d6776 100644
--- a/src/Native/gc/sample/gcenv.cpp
+++ b/src/Native/gc/sample/gcenv.cpp
@@ -136,15 +136,11 @@ void GCToEEInterface::RestartEE(bool bFinishedGC)
GCHeap::GetGCHeap()->SetGCInProgress(FALSE);
}
-void GCToEEInterface::ScanStackRoots(Thread * pThread, promote_func* fn, ScanContext* sc)
+void GCToEEInterface::GcScanRoots(promote_func* fn, int condemned, int max_gen, ScanContext* sc)
{
// TODO: Implement - Scan stack roots on given thread
}
-void GCToEEInterface::ScanStaticGCRefsOpportunistically(promote_func* fn, ScanContext* sc)
-{
-}
-
void GCToEEInterface::GcStartWork(int condemned, int max_gen)
{
}
@@ -202,11 +198,16 @@ void GCToEEInterface::AttachCurrentThread()
ThreadStore::AttachCurrentThread();
}
-Thread * GCToEEInterface::GetThreadList(Thread * pThread)
+void GCToEEInterface::GcEnumAllocContexts (enum_alloc_context_func* fn, void* param)
{
- return ThreadStore::GetThreadList(pThread);
+ Thread * pThread = NULL;
+ while ((pThread = ThreadStore::GetThreadList(pThread)) != NULL)
+ {
+ fn(pThread->GetAllocContext(), param);
+ }
}
+
void FinalizerThread::EnableFinalization()
{
// Signal to finalizer thread that there are objects to finalize