rts: retainer: Abstract maxStackSize for generic traversal
authorDaniel Gröber <dxld@darkboxed.org>
Mon, 24 Jun 2019 19:32:56 +0000 (21:32 +0200)
committerDaniel Gröber <dxld@darkboxed.org>
Sun, 22 Sep 2019 13:18:10 +0000 (15:18 +0200)
rts/RetainerProfile.c
rts/TraverseHeap.h

index 9e9f246..3fa025d 100644 (file)
@@ -244,6 +244,9 @@ initializeTraverseStack( traverseState *ts )
     ts->firstStack->link = NULL;
     ts->firstStack->u.back = NULL;
 
+    ts->stackSize = 0;
+    ts->maxStackSize = 0;
+
     newStackBlock(ts, ts->firstStack);
 }
 
@@ -260,6 +263,12 @@ closeTraverseStack( traverseState *ts )
     ts->firstStack = NULL;
 }
 
+int
+getTraverseStackMaxSize(traverseState *ts)
+{
+    return ts->maxStackSize;
+}
+
 /* -----------------------------------------------------------------------------
  * Returns true if the whole stack is empty.
  * -------------------------------------------------------------------------- */
@@ -1798,8 +1807,6 @@ retainerProfile(void)
   // Now we flips flip.
   flip = flip ^ 1;
 
-  g_retainerTraverseState.stackSize = 0;
-  g_retainerTraverseState.maxStackSize = 0;
   numObjectVisited = 0;
   timesAnyObjectVisited = 0;
 
@@ -1819,7 +1826,7 @@ retainerProfile(void)
 
   stat_endRP(
     retainerGeneration - 1,   // retainerGeneration has just been incremented!
-    g_retainerTraverseState.maxStackSize,
+    getTraverseStackMaxSize(&g_retainerTraverseState),
     (double)timesAnyObjectVisited / numObjectVisited);
 }
 
index 5a19697..3b90065 100644 (file)
@@ -112,6 +112,7 @@ void traverseMaybeInitClosureData(StgClosure *c);
 
 void initializeTraverseStack(traverseState *ts);
 void closeTraverseStack(traverseState *ts);
+int getTraverseStackMaxSize(traverseState *ts);
 
 W_ traverseWorkStackBlocks(traverseState *ts);