summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Gröber <dxld@darkboxed.org>2019-07-16 15:03:13 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-02-17 11:21:11 -0500
commit937feda39e0cc79cd5d23d36f5a81155d992b9f9 (patch)
treec4b590f2e883da5c8b511c27ca835642fe51be38
parent30c01e4227e99e10e50b05075ec071cf7950ae78 (diff)
downloadhaskell-937feda39e0cc79cd5d23d36f5a81155d992b9f9.tar.gz
rts: TraverseHeap: Make "flip" bit flip into it's own function
-rw-r--r--rts/RetainerProfile.c2
-rw-r--r--rts/TraverseHeap.c25
-rw-r--r--rts/TraverseHeap.h9
3 files changed, 25 insertions, 11 deletions
diff --git a/rts/RetainerProfile.c b/rts/RetainerProfile.c
index 81b41b8207..0db1cd2a18 100644
--- a/rts/RetainerProfile.c
+++ b/rts/RetainerProfile.c
@@ -381,6 +381,8 @@ computeRetainerSet( traverseState *ts )
StgWeak *weak;
uint32_t g, n;
+ traverseInvalidateClosureData(ts);
+
markCapabilities(retainRoot, (void*)ts); // for scheduler roots
// This function is called after a major GC, when key, value, and finalizer
diff --git a/rts/TraverseHeap.c b/rts/TraverseHeap.c
index 281bf4edc2..7f5278d878 100644
--- a/rts/TraverseHeap.c
+++ b/rts/TraverseHeap.c
@@ -1162,7 +1162,6 @@ resetMutableObjects(traverseState* ts)
for (n = 0; n < n_capabilities; n++) {
for (bd = capabilities[n]->mut_lists[g]; bd != NULL; bd = bd->link) {
for (ml = bd->start; ml < bd->free; ml++) {
-
traverseMaybeInitClosureData(ts, (StgClosure *)*ml);
}
}
@@ -1172,9 +1171,7 @@ resetMutableObjects(traverseState* ts)
/**
* Traverse all closures on the traversal work-stack, calling 'visit_cb' on each
- * closure. See 'visitClosure_cb' for details. This function flips the 'flip'
- * bit and hence every closure's profiling data will be reset to zero upon
- * visiting. See Note [Profiling heap traversal visited bit].
+ * closure. See 'visitClosure_cb' for details.
*/
void
traverseWorkStack(traverseState *ts, visitClosure_cb visit_cb)
@@ -1186,9 +1183,6 @@ traverseWorkStack(traverseState *ts, visitClosure_cb visit_cb)
stackElement *sep;
bool other_children;
- // Now we flip the flip bit.
- ts->flip = ts->flip ^ 1;
-
// c = Current closure (possibly tagged)
// cp = Current closure's Parent (NOT tagged)
// data = current closures' associated data (NOT tagged)
@@ -1199,7 +1193,6 @@ loop:
if (c == NULL) {
debug("maxStackSize= %d\n", ts->maxStackSize);
- resetMutableObjects(ts);
return;
}
@@ -1401,6 +1394,22 @@ inner_loop:
}
/**
+ * This function flips the 'flip' bit and hence every closure's profiling data
+ * will be reset to zero upon visiting. See Note [Profiling heap traversal
+ * visited bit].
+ */
+void
+traverseInvalidateClosureData(traverseState* ts)
+{
+ // First make sure any unvisited mutable objects are valid so they're
+ // invalidated by the flip below
+ resetMutableObjects(ts);
+
+ // Then flip the flip bit, invalidating all closures.
+ ts->flip = ts->flip ^ 1;
+}
+
+/**
* Traverse all static objects for which we compute retainer sets,
* and reset their rs fields to NULL, which is accomplished by
* invoking traverseMaybeInitClosureData(). This function must be called
diff --git a/rts/TraverseHeap.h b/rts/TraverseHeap.h
index b0ecbd2a02..e24b0aae87 100644
--- a/rts/TraverseHeap.h
+++ b/rts/TraverseHeap.h
@@ -56,9 +56,11 @@ typedef struct traverseState_ {
* variable, 'flip' and "flip" this variable when we want to invalidate all
* objects.
*
- * When the visited bit is equal to the value of 'flip' the closure data
- * is valid otherwise not (see isTravDataValid). We then invert the value of
- * 'flip' after each each profiling run (see traverseWorkStack).
+ * When the visited bit is equal to the value of 'flip' the closure data is
+ * valid otherwise not (see isTravDataValid). Both the value of the closure
+ * and global 'flip' value start out as zero, so all closures are considered
+ * valid. Before every traversal we invert the value of 'flip' (see
+ * traverseInvalidateClosureData) invalidating all closures.
*
* There are some complications with this approach, namely: static objects
* and mutable data. There we do just go over all existing objects to reset
@@ -162,6 +164,7 @@ bool isTravDataValid(const traverseState *ts, const StgClosure *c);
void traverseWorkStack(traverseState *ts, visitClosure_cb visit_cb);
void traversePushRoot(traverseState *ts, StgClosure *c, StgClosure *cp, stackData data);
bool traverseMaybeInitClosureData(const traverseState* ts, StgClosure *c);
+void traverseInvalidateClosureData(traverseState* ts);
void initializeTraverseStack(traverseState *ts);
void closeTraverseStack(traverseState *ts);