Commit 937feda3 authored by Daniel Gröber (dxld)'s avatar Daniel Gröber (dxld) Committed by Marge Bot

rts: TraverseHeap: Make "flip" bit flip into it's own function

parent 30c01e42
......@@ -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
......
......@@ -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;
}
......@@ -1400,6 +1393,22 @@ inner_loop:
goto 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
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment