diff options
-rw-r--r-- | rts/sm/MarkWeak.c | 28 | ||||
-rw-r--r-- | rts/sm/Sanity.c | 3 |
2 files changed, 17 insertions, 14 deletions
diff --git a/rts/sm/MarkWeak.c b/rts/sm/MarkWeak.c index 0cac3e7769..b74ba366ee 100644 --- a/rts/sm/MarkWeak.c +++ b/rts/sm/MarkWeak.c @@ -251,7 +251,7 @@ static void collectDeadWeakPtrs (generation *gen, StgWeak **dead_weak_ptr_list) */ static bool resurrectUnreachableThreads (generation *gen, StgTSO **resurrected_threads) { - StgTSO *t, *tmp, *next; + StgTSO *t, *next; bool flag = false; for (t = gen->old_threads; t != END_TSO_QUEUE; t = next) { @@ -272,12 +272,14 @@ static bool resurrectUnreachableThreads (generation *gen, StgTSO **resurrected_t t->global_link = END_TSO_QUEUE; continue; default: - tmp = t; + { + StgTSO *tmp = t; evacuate((StgClosure **)&tmp); tmp->global_link = *resurrected_threads; *resurrected_threads = tmp; flag = true; } + } } gen->old_threads = END_TSO_QUEUE; @@ -387,18 +389,21 @@ static bool tidyWeakList(generation *gen) } /* - * Walk over the `old_threads` list of the given generation and move any - * reachable threads onto the `threads` list. + * Walk over the given generation's thread list and promote TSOs which are + * reachable via the heap. This will move the TSO from gen->old_threads to + * new_gen->threads. + * + * This has the side-effect of updating the global thread list to account for + * indirections introduced by evacuation. */ static void tidyThreadList (generation *gen) { - StgTSO *t, *tmp, *next, **prev; + StgTSO *next; + StgTSO **prev = &gen->old_threads; - prev = &gen->old_threads; - - for (t = gen->old_threads; t != END_TSO_QUEUE; t = next) { + for (StgTSO *t = gen->old_threads; t != END_TSO_QUEUE; t = next) { - tmp = (StgTSO *)isAlive((StgClosure *)t); + StgTSO *tmp = (StgTSO *)isAlive((StgClosure *)t); if (tmp != NULL) { t = tmp; @@ -426,10 +431,9 @@ static void tidyThreadList (generation *gen) *prev = next; // move this thread onto the correct threads list. - generation *new_gen; - new_gen = Bdescr((P_)t)->gen; + generation *new_gen = Bdescr((P_)t)->gen; t->global_link = new_gen->threads; - new_gen->threads = t; + new_gen->threads = t; } } } diff --git a/rts/sm/Sanity.c b/rts/sm/Sanity.c index fa497251e2..7fcc601bbd 100644 --- a/rts/sm/Sanity.c +++ b/rts/sm/Sanity.c @@ -740,11 +740,10 @@ checkSTACK (StgStack *stack) void checkTSO(StgTSO *tso) { - StgTSO *next = tso->_link; const StgInfoTable *info = (const StgInfoTable*) tso->_link->header.info; load_load_barrier(); - ASSERT(next == END_TSO_QUEUE || + ASSERT(tso->_link == END_TSO_QUEUE || info == &stg_MVAR_TSO_QUEUE_info || info == &stg_TSO_info || info == &stg_WHITEHOLE_info); // used to happen due to STM doing |