Skip to content

Commit 00a5ee5

Browse files
authored
[local gc] move DacNotifyGCMarkEnd and AnalyzeSurvivorsRequested to GCToEEInterface (dotnet#19774)
1 parent 6e780ac commit 00a5ee5

File tree

8 files changed

+71
-39
lines changed

8 files changed

+71
-39
lines changed

src/gc/env/gcenv.ee.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ class GCToEEInterface
9292
static uint32_t GetIndexOfAppDomainBeingUnloaded();
9393
static uint32_t GetTotalNumSizedRefHandles();
9494
static bool AppDomainIsRudeUnload(void *appDomain);
95+
96+
static bool AnalyzeSurvivorsRequested(int condemnedGeneration);
97+
static void AnalyzeSurvivorsFinished(int condemnedGeneration);
9598
};
9699

97100
#endif // __GCENV_EE_H__

src/gc/gc.cpp

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -16293,42 +16293,6 @@ void gc_heap::update_collection_counts ()
1629316293
}
1629416294
}
1629516295

16296-
#ifdef HEAP_ANALYZE
16297-
inline
16298-
BOOL AnalyzeSurvivorsRequested(int condemnedGeneration)
16299-
{
16300-
#ifndef BUILD_AS_STANDALONE
16301-
// Is the list active?
16302-
GcNotifications gn(g_pGcNotificationTable);
16303-
if (gn.IsActive())
16304-
{
16305-
GcEvtArgs gea = { GC_MARK_END, { (1<<condemnedGeneration) } };
16306-
if (gn.GetNotification(gea) != 0)
16307-
{
16308-
return TRUE;
16309-
}
16310-
}
16311-
#endif // BUILD_AS_STANDALONE
16312-
return FALSE;
16313-
}
16314-
16315-
void DACNotifyGcMarkEnd(int condemnedGeneration)
16316-
{
16317-
#ifndef BUILD_AS_STANDALONE
16318-
// Is the list active?
16319-
GcNotifications gn(g_pGcNotificationTable);
16320-
if (gn.IsActive())
16321-
{
16322-
GcEvtArgs gea = { GC_MARK_END, { (1<<condemnedGeneration) } };
16323-
if (gn.GetNotification(gea) != 0)
16324-
{
16325-
DACNotify::DoGCNotification(gea);
16326-
}
16327-
}
16328-
#endif // BUILD_AS_STANDALONE
16329-
}
16330-
#endif // HEAP_ANALYZE
16331-
1633216296
BOOL gc_heap::expand_soh_with_minimal_gc()
1633316297
{
1633416298
if ((size_t)(heap_segment_reserved (ephemeral_heap_segment) - heap_segment_allocated (ephemeral_heap_segment)) >= soh_allocation_no_gc)
@@ -16709,7 +16673,7 @@ int gc_heap::garbage_collect (int n)
1670916673
#ifdef HEAP_ANALYZE
1671016674
// At this point we've decided what generation is condemned
1671116675
// See if we've been requested to analyze survivors after the mark phase
16712-
if (AnalyzeSurvivorsRequested(settings.condemned_generation))
16676+
if (GCToEEInterface::AnalyzeSurvivorsRequested(settings.condemned_generation))
1671316677
{
1671416678
heap_analyze_enabled = TRUE;
1671516679
}
@@ -19729,7 +19693,7 @@ void gc_heap::mark_phase (int condemned_gen_number, BOOL mark_only_p)
1972919693
{
1973019694
#ifdef HEAP_ANALYZE
1973119695
heap_analyze_enabled = FALSE;
19732-
DACNotifyGcMarkEnd(condemned_gen_number);
19696+
GCToEEInterface::AnalyzeSurvivorsFinished(condemned_gen_number);
1973319697
#endif // HEAP_ANALYZE
1973419698
GCToEEInterface::AfterGcScanRoots (condemned_gen_number, max_generation, &sc);
1973519699

src/gc/gcenv.ee.standalone.inl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,4 +311,16 @@ inline bool GCToEEInterface::AppDomainIsRudeUnload(void *appDomain)
311311
return g_theGCToCLR->AppDomainIsRudeUnload(appDomain);
312312
}
313313

314+
inline bool GCToEEInterface::AnalyzeSurvivorsRequested(int condemnedGeneration)
315+
{
316+
assert(g_theGCToCLR != nullptr);
317+
return g_theGCToCLR->AnalyzeSurvivorsRequested(condemnedGeneration);
318+
}
319+
320+
inline void GCToEEInterface::AnalyzeSurvivorsFinished(int condemnedGeneration)
321+
{
322+
assert(g_theGCToCLR != nullptr);
323+
g_theGCToCLR->AnalyzeSurvivorsFinished(condemnedGeneration);
324+
}
325+
314326
#endif // __GCTOENV_EE_STANDALONE_INL__

src/gc/gcinterface.ee.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,12 @@ class IGCToCLR {
427427

428428
virtual
429429
bool AppDomainIsRudeUnload(void *appDomain) = 0;
430+
431+
virtual
432+
bool AnalyzeSurvivorsRequested(int condemnedGeneration) = 0;
433+
434+
virtual
435+
void AnalyzeSurvivorsFinished(int condemnedGeneration) = 0;
430436
};
431437

432438
#endif // _GCINTERFACE_EE_H_

src/gc/sample/gcenv.ee.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,3 +371,13 @@ bool GCToEEInterface::AppDomainIsRudeUnload(void *appDomain)
371371
{
372372
return false;
373373
}
374+
375+
inline bool GCToEEInterface::AnalyzeSurvivorsRequested(int condemnedGeneration)
376+
{
377+
return false;
378+
}
379+
380+
inline void GCToEEInterface::AnalyzeSurvivorsFinished(int condemnedGeneration)
381+
{
382+
383+
}

src/vm/gcenv.ee.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,3 +1475,37 @@ bool GCToEEInterface::AppDomainIsRudeUnload(void *appDomain)
14751475
AppDomain *realPtr = static_cast<AppDomain *>(appDomain);
14761476
return realPtr->IsRudeUnload() != FALSE;
14771477
}
1478+
1479+
bool GCToEEInterface::AnalyzeSurvivorsRequested(int condemnedGeneration)
1480+
{
1481+
LIMITED_METHOD_CONTRACT;
1482+
1483+
// Is the list active?
1484+
GcNotifications gn(g_pGcNotificationTable);
1485+
if (gn.IsActive())
1486+
{
1487+
GcEvtArgs gea = { GC_MARK_END, { (1<<condemnedGeneration) } };
1488+
if (gn.GetNotification(gea) != 0)
1489+
{
1490+
return true;
1491+
}
1492+
}
1493+
1494+
return false;
1495+
}
1496+
1497+
void GCToEEInterface::AnalyzeSurvivorsFinished(int condemnedGeneration)
1498+
{
1499+
LIMITED_METHOD_CONTRACT;
1500+
1501+
// Is the list active?
1502+
GcNotifications gn(g_pGcNotificationTable);
1503+
if (gn.IsActive())
1504+
{
1505+
GcEvtArgs gea = { GC_MARK_END, { (1<<condemnedGeneration) } };
1506+
if (gn.GetNotification(gea) != 0)
1507+
{
1508+
DACNotify::DoGCNotification(gea);
1509+
}
1510+
}
1511+
}

src/vm/gcenv.ee.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ class GCToEEInterface : public IGCToCLR {
7070
uint32_t GetIndexOfAppDomainBeingUnloaded();
7171
uint32_t GetTotalNumSizedRefHandles();
7272
bool AppDomainIsRudeUnload(void *appDomain);
73+
74+
bool AnalyzeSurvivorsRequested(int condemnedGeneration);
75+
void AnalyzeSurvivorsFinished(int condemnedGeneration);
7376
};
7477

7578
} // namespace standalone

src/vm/util.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2964,7 +2964,7 @@ void DACNotify::DoGCNotification(const GcEvtArgs& args)
29642964
NOTHROW;
29652965
GC_NOTRIGGER;
29662966
SO_INTOLERANT;
2967-
MODE_PREEMPTIVE;
2967+
MODE_COOPERATIVE;
29682968
}
29692969
CONTRACTL_END;
29702970

0 commit comments

Comments
 (0)