From ccb958030d8e3afcef8ef905372f9586e5ada2a3 Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Tue, 9 Sep 2008 13:52:51 +0000 Subject: Separate pruning from marking of spark pools Fixes crash when using compacting GC in parallel programs --- rts/Sparks.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'rts/Sparks.c') diff --git a/rts/Sparks.c b/rts/Sparks.c index 1a839ab315..2e9e61ca62 100644 --- a/rts/Sparks.c +++ b/rts/Sparks.c @@ -168,8 +168,8 @@ newSpark (StgRegTable *reg, StgClosure *p) * spark pool and the spark pool only contains sparkable closures * -------------------------------------------------------------------------- */ -void -markSparkQueue (evac_fn evac, void *user, Capability *cap) +static void +pruneSparkQueue (Capability *cap) { StgClosure *spark, **sparkp, **to_sparkp; nat n, pruned_sparks; // stats only @@ -190,7 +190,6 @@ markSparkQueue (evac_fn evac, void *user, Capability *cap) ASSERT(*sparkp!=NULL); ASSERT(LOOKS_LIKE_CLOSURE_PTR(((StgClosure *)*sparkp))); // ToDo?: statistics gathering here (also for GUM!) - evac(user,sparkp); spark = *sparkp; if (!closure_SHOULD_SPARK(spark)) { pruned_sparks++; @@ -210,15 +209,22 @@ markSparkQueue (evac_fn evac, void *user, Capability *cap) PAR_TICKY_MARK_SPARK_QUEUE_END(n); - debugTrace(DEBUG_sched, - "marked %d sparks, pruned %d sparks", - n, pruned_sparks); + debugTrace(DEBUG_sched, "pruned %d sparks", pruned_sparks); debugTrace(DEBUG_sched, "new spark queue len=%d; (hd=%p; tl=%p)", sparkPoolSize(pool), pool->hd, pool->tl); } +void +pruneSparkQueues (void) +{ + nat i; + for (i = 0; i < n_capabilities; i++) { + pruneSparkQueue(&capabilities[i]); + } +} + void traverseSparkQueue (evac_fn evac, void *user, Capability *cap) { @@ -228,7 +234,7 @@ traverseSparkQueue (evac_fn evac, void *user, Capability *cap) pool = &(cap->r.rSparks); sparkp = pool->hd; while (sparkp != pool->tl) { - evac(sparkp, user); + evac(user, sparkp); sparkp++; if (sparkp == pool->lim) { sparkp = pool->base; -- cgit v1.2.1