include POH in diagnostic APIs like walk_survivors. (#34567)
authorVladimir Sadov <vsadov@microsoft.com>
Thu, 9 Apr 2020 16:52:48 +0000 (09:52 -0700)
committerGitHub <noreply@github.com>
Thu, 9 Apr 2020 16:52:48 +0000 (16:52 +0000)
* include POH in diagnostic APIs like walk_survivors.

* PR feedback

src/coreclr/src/gc/env/gcenv.ee.h
src/coreclr/src/gc/gc.cpp
src/coreclr/src/gc/gcenv.ee.standalone.inl
src/coreclr/src/gc/gcimpl.h
src/coreclr/src/gc/gcinterface.ee.h
src/coreclr/src/gc/gcinterface.h
src/coreclr/src/gc/gcpriv.h
src/coreclr/src/gc/sample/gcenv.ee.cpp
src/coreclr/src/vm/gcenv.ee.cpp
src/coreclr/src/vm/gcenv.ee.h

index b56240d..ab0fe80 100644 (file)
@@ -64,7 +64,7 @@ public:
     static void DiagGCEnd(size_t index, int gen, int reason, bool fConcurrent);
     static void DiagWalkFReachableObjects(void* gcContext);
     static void DiagWalkSurvivors(void* gcContext, bool fCompacting);
-    static void DiagWalkLOHSurvivors(void* gcContext);
+    static void DiagWalkUOHSurvivors(void* gcContext, int gen);
     static void DiagWalkBGCSurvivors(void* gcContext);
     static void StompWriteBarrier(WriteBarrierParameters* args);
 
index fb844e7..50460c3 100644 (file)
@@ -23959,10 +23959,11 @@ void gc_heap::plan_phase (int condemned_gen_number)
         if (!loh_compacted_p)
 #endif //FEATURE_LOH_COMPACTION
         {
-            GCToEEInterface::DiagWalkLOHSurvivors(__this);
+            GCToEEInterface::DiagWalkUOHSurvivors(__this, loh_generation);
             sweep_uoh_objects (loh_generation);
         }
 
+        GCToEEInterface::DiagWalkUOHSurvivors(__this, poh_generation);
         sweep_uoh_objects (poh_generation);
     }
     else
@@ -25794,8 +25795,6 @@ void gc_heap::walk_survivors (record_surv_fn fn, void* context, walk_surv_type t
     else if (type == walk_for_bgc)
         walk_survivors_for_bgc (context, fn);
 #endif //BACKGROUND_GC && FEATURE_EVENT_TRACE
-    else if (type == walk_for_loh)
-        walk_survivors_for_loh (context, fn);
     else
         assert (!"unknown type!");
 }
@@ -33562,7 +33561,7 @@ void reset_memory (uint8_t* o, size_t sizeo)
     }
 }
 
-BOOL gc_heap::large_object_marked (uint8_t* o, BOOL clearp)
+BOOL gc_heap::uoh_object_marked (uint8_t* o, BOOL clearp)
 {
     BOOL m = FALSE;
     // It shouldn't be necessary to do these comparisons because this is only used for blocking
@@ -33600,9 +33599,9 @@ void gc_heap::walk_survivors_relocation (void* profiling_context, record_surv_fn
 #endif //FEATURE_LOH_COMPACTION
 }
 
-void gc_heap::walk_survivors_for_loh (void* profiling_context, record_surv_fn fn)
+void gc_heap::walk_survivors_for_uoh (void* profiling_context, record_surv_fn fn, int gen_number)
 {
-    generation* gen        = large_object_generation;
+    generation* gen        = generation_of (gen_number);
     heap_segment* seg      = heap_segment_rw (generation_start_segment (gen));;
 
     PREFIX_ASSUME(seg != NULL);
@@ -33621,7 +33620,7 @@ void gc_heap::walk_survivors_for_loh (void* profiling_context, record_surv_fn fn
             else
                 o = heap_segment_mem (seg);
         }
-        if (large_object_marked(o, FALSE))
+        if (uoh_object_marked(o, FALSE))
         {
             plug_start = o;
 
@@ -33633,7 +33632,7 @@ void gc_heap::walk_survivors_for_loh (void* profiling_context, record_surv_fn fn
                 {
                     break;
                 }
-                m = large_object_marked (o, FALSE);
+                m = uoh_object_marked (o, FALSE);
             }
 
             plug_end = o;
@@ -33642,7 +33641,7 @@ void gc_heap::walk_survivors_for_loh (void* profiling_context, record_surv_fn fn
         }
         else
         {
-            while (o < heap_segment_allocated (seg) && !large_object_marked(o, FALSE))
+            while (o < heap_segment_allocated (seg) && !uoh_object_marked(o, FALSE))
             {
                 o = o + AlignQword (size (o));
             }
@@ -34504,7 +34503,7 @@ void gc_heap::sweep_uoh_objects (int gen_num)
                              (size_t)heap_segment_allocated (seg)));
             }
         }
-        if (large_object_marked(o, TRUE))
+        if (uoh_object_marked(o, TRUE))
         {
             plug_start = o;
             //everything between plug_end and plug_start is free
@@ -34518,14 +34517,14 @@ void gc_heap::sweep_uoh_objects (int gen_num)
                 {
                     break;
                 }
-                m = large_object_marked (o, TRUE);
+                m = uoh_object_marked (o, TRUE);
             }
             plug_end = o;
             dprintf (3, ("plug [%Ix, %Ix[", (size_t)plug_start, (size_t)plug_end));
         }
         else
         {
-            while (o < heap_segment_allocated (seg) && !large_object_marked(o, FALSE))
+            while (o < heap_segment_allocated (seg) && !uoh_object_marked(o, FALSE))
             {
                 o = o + AlignQword (size (o));
             }
@@ -39430,10 +39429,18 @@ void GCHeap::DiagWalkObject2 (Object* obj, walk_fn2 fn, void* context)
     }
 }
 
-void GCHeap::DiagWalkSurvivorsWithType (void* gc_context, record_surv_fn fn, void* diag_context, walk_surv_type type)
+void GCHeap::DiagWalkSurvivorsWithType (void* gc_context, record_surv_fn fn, void* diag_context, walk_surv_type type, int gen_number)
 {
     gc_heap* hp = (gc_heap*)gc_context;
-    hp->walk_survivors (fn, diag_context, type);
+
+    if (type == walk_for_uoh)
+    {
+        hp->walk_survivors_for_uoh (diag_context, fn, gen_number);
+    }
+    else
+    {
+        hp->walk_survivors (fn, diag_context, type);
+    }
 }
 
 void GCHeap::DiagWalkHeap (walk_fn fn, void* context, int gen_number, bool walk_large_object_heap_p)
index be318dc..7ed523e 100644 (file)
@@ -161,10 +161,10 @@ inline void GCToEEInterface::DiagWalkSurvivors(void* gcContext, bool fCompacting
     g_theGCToCLR->DiagWalkSurvivors(gcContext, fCompacting);
 }
 
-inline void GCToEEInterface::DiagWalkLOHSurvivors(void* gcContext)
+inline void GCToEEInterface::DiagWalkUOHSurvivors(void* gcContext, int gen)
 {
     assert(g_theGCToCLR != nullptr);
-    g_theGCToCLR->DiagWalkLOHSurvivors(gcContext);
+    g_theGCToCLR->DiagWalkUOHSurvivors(gcContext, gen);
 }
 
 inline void GCToEEInterface::DiagWalkBGCSurvivors(void* gcContext)
index eba7b90..8cd15fe 100644 (file)
@@ -287,7 +287,7 @@ protected:
 
     virtual void DiagDescrGenerations (gen_walk_fn fn, void *context);
 
-    virtual void DiagWalkSurvivorsWithType (void* gc_context, record_surv_fn fn, void* diag_context, walk_surv_type type);
+    virtual void DiagWalkSurvivorsWithType (void* gc_context, record_surv_fn fn, void* diag_context, walk_surv_type type, int gen_number=-1);
 
     virtual void DiagWalkFinalizeQueue (void* gc_context, fq_walk_fn fn);
 
index b4507a5..4d8cb61 100644 (file)
@@ -302,10 +302,10 @@ public:
     virtual
     void DiagWalkSurvivors(void* gcContext, bool fCompacting) = 0;
 
-    // During a full GC after we discover what objects to survive on LOH,
+    // During a full GC after we discover what objects to survive on UOH,
     // gives the diagnostics code a chance to run.
     virtual
-    void DiagWalkLOHSurvivors(void* gcContext) = 0;
+    void DiagWalkUOHSurvivors(void* gcContext, int gen) = 0;
 
     // At the end of a background GC, gives the diagnostics code a chance to run.
     virtual
index de6456d..122106c 100644 (file)
@@ -47,7 +47,7 @@ typedef enum
 {
     walk_for_gc = 1,
     walk_for_bgc = 2,
-    walk_for_loh = 3
+    walk_for_uoh = 3
 } walk_surv_type;
 
 // Different operations that can be done by GCToEEInterface::StompWriteBarrier
@@ -819,7 +819,8 @@ public:
     virtual void DiagWalkHeap(walk_fn fn, void* context, int gen_number, bool walk_large_object_heap_p) = 0;
 
     // Walks the survivors and get the relocation information if objects have moved.
-    virtual void DiagWalkSurvivorsWithType(void* gc_context, record_surv_fn fn, void* diag_context, walk_surv_type type) = 0;
+    // gen_number is used when type == walk_for_uoh, otherwise ignored
+    virtual void DiagWalkSurvivorsWithType(void* gc_context, record_surv_fn fn, void* diag_context, walk_surv_type type, int gen_number=-1) = 0;
 
     // Walks the finalization queue.
     virtual void DiagWalkFinalizeQueue(void* gc_context, fq_walk_fn fn) = 0;
index e04abda..05feeb8 100644 (file)
@@ -1416,7 +1416,7 @@ protected:
     PER_HEAP
     void walk_survivors_relocation (void* profiling_context, record_surv_fn fn);
     PER_HEAP
-    void walk_survivors_for_loh (void* profiling_context, record_surv_fn fn);
+    void walk_survivors_for_uoh (void* profiling_context, record_surv_fn fn, int gen_number);
 
     PER_HEAP
     int generation_to_condemn (int n,
@@ -1922,7 +1922,7 @@ protected:
 #endif //MARK_ARRAY
 
     PER_HEAP
-    BOOL large_object_marked (uint8_t* o, BOOL clearp);
+    BOOL uoh_object_marked (uint8_t* o, BOOL clearp);
 
 #ifdef BACKGROUND_GC
     PER_HEAP
index 8f69509..9dad62e 100644 (file)
@@ -246,7 +246,7 @@ void GCToEEInterface::DiagWalkSurvivors(void* gcContext, bool fCompacting)
 {
 }
 
-void GCToEEInterface::DiagWalkLOHSurvivors(void* gcContext)
+void GCToEEInterface::DiagWalkUOHSurvivors(void* gcContext, int gen)
 {
 }
 
index 53566be..42a07c2 100644 (file)
@@ -763,14 +763,14 @@ void GCToEEInterface::DiagWalkSurvivors(void* gcContext, bool fCompacting)
 #endif //GC_PROFILING || FEATURE_EVENT_TRACE
 }
 
-void GCToEEInterface::DiagWalkLOHSurvivors(void* gcContext)
+void GCToEEInterface::DiagWalkUOHSurvivors(void* gcContext, int gen)
 {
 #if defined(GC_PROFILING) || defined(FEATURE_EVENT_TRACE)
     if (ShouldTrackSurvivorsForProfilerOrEtw())
     {
         size_t context = 0;
         ETW::GCLog::BeginMovedReferences(&context);
-        GCHeapUtilities::GetGCHeap()->DiagWalkSurvivorsWithType(gcContext, &WalkMovedReferences, (void*)context, walk_for_loh);
+        GCHeapUtilities::GetGCHeap()->DiagWalkSurvivorsWithType(gcContext, &WalkMovedReferences, (void*)context, walk_for_uoh, gen);
         ETW::GCLog::EndMovedReferences(context);
     }
 #endif //GC_PROFILING || FEATURE_EVENT_TRACE
index de6ad5a..deec876 100644 (file)
@@ -56,7 +56,7 @@ public:
     void DiagGCEnd(size_t index, int gen, int reason, bool fConcurrent);
     void DiagWalkFReachableObjects(void* gcContext);
     void DiagWalkSurvivors(void* gcContext, bool fCompacting);
-    void DiagWalkLOHSurvivors(void* gcContext);
+    void DiagWalkUOHSurvivors(void* gcContext, int gen);
     void DiagWalkBGCSurvivors(void* gcContext);
     void StompWriteBarrier(WriteBarrierParameters* args);