summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2023-04-28 12:34:08 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2023-05-15 18:02:20 -0400
commit18ea2295f3f1496981ace990ec8e6f7ba844e666 (patch)
tree3d5ae60e53d92f895cdd534e6861196dd294e486
parent21f3aae7371469beb3950a6170db6c5668379ff3 (diff)
downloadhaskell-18ea2295f3f1496981ace990ec8e6f7ba844e666.tar.gz
rts: Weak pointer cleanups
Various stylistic cleanups. No functional changes.
-rw-r--r--rts/sm/MarkWeak.c28
-rw-r--r--rts/sm/Sanity.c3
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