Weak debugging
authorBen Gamari <ben@smart-cactus.org>
Tue, 21 May 2019 22:08:01 +0000 (18:08 -0400)
committerBen Gamari <ben@smart-cactus.org>
Wed, 19 Jun 2019 01:44:01 +0000 (21:44 -0400)
rts/Schedule.c
rts/sm/MarkWeak.c
rts/sm/NonMoving.c
rts/sm/NonMovingMark.c
rts/sm/NonMovingScav.c

index dbe3377..c0e066a 100644 (file)
@@ -3074,6 +3074,7 @@ resurrectThreads (StgTSO *threads)
 
     for (tso = threads; tso != END_TSO_QUEUE; tso = next) {
         next = tso->global_link;
+        debugBelch("resurrect %p\n", tso);
 
         gen = Bdescr((P_)tso)->gen;
         tso->global_link = gen->threads;
index d5982e2..b93e6b1 100644 (file)
@@ -205,6 +205,7 @@ static bool resurrectUnreachableThreads (generation *gen, StgTSO **resurrected_t
 
     for (t = gen->old_threads; t != END_TSO_QUEUE; t = next) {
         next = t->global_link;
+        debugBelch("resurrectUnreachableThreads %p, gen=%d\n", t, gen->no);
 
         // ThreadFinished and ThreadComplete: we have to keep
         // these on the all_threads list until they
@@ -295,6 +296,9 @@ static bool tidyWeakList(generation *gen)
                 continue;
             }
             else {
+                debugTrace(DEBUG_weak,
+                           "weak pointer %p with key %p died at",
+                           w, w->key);
                 last_w = &(w->link);
                 next_w = w->link;
                 continue;
@@ -322,6 +326,8 @@ static void tidyThreadList (generation *gen)
             t = tmp;
         }
 
+        debugBelch("tidyThreadList(gen=%d): %p => %p\n", gen->no, t, tmp);
+
         ASSERT(get_itbl((StgClosure *)t)->type == TSO);
         next = t->global_link;
 
index f1f2d45..8b3ab04 100644 (file)
@@ -835,6 +835,7 @@ void nonmovingCollect(StgWeak **dead_weaks, StgTSO **resurrected_threads)
 
     // Mark threads resurrected during moving heap scavenging
     for (StgTSO *tso = *resurrected_threads; tso != END_TSO_QUEUE; tso = tso->global_link) {
+        debugBelch("resurrecting from moving %p\n", tso);
         markQueuePushClosure_(mark_queue, (StgClosure*)tso);
     }
     LONG_PAUSE_END(&pause, 20, "root-marking");
index 2a82535..9805bc2 100644 (file)
@@ -1609,6 +1609,7 @@ mark_closure (MarkQueue *queue, const StgClosure *p0, StgClosure **origin)
     }
 
     case TSO:
+        debugBelch("Marked TSO %p\n", p);
         mark_tso(queue, (StgTSO *) p);
         break;
 
@@ -1958,6 +1959,9 @@ void nonmovingTidyThreads ()
 
         next = t->global_link;
 
+        debugBelch("nonmovingTidyThreads: %p => %s\n",
+                   t, nonmovingIsNowAlive((StgClosure*) t) ? "live" : "dead");
+
         // N.B. This thread is in old_threads, consequently we *know* it is in
         // the snapshot and it is therefore safe to rely on the bitmap to
         // determine its reachability.
@@ -1980,6 +1984,7 @@ void nonmovingResurrectThreads (struct MarkQueue_ *queue, StgTSO **resurrected_t
     StgTSO *next;
     for (StgTSO *t = nonmoving_old_threads; t != END_TSO_QUEUE; t = next) {
         next = t->global_link;
+        debugBelch("nonmoving resurrect %p\n", t);
 
         switch (t->what_next) {
         case ThreadKilled:
index 82b8059..bc1f63b 100644 (file)
@@ -134,9 +134,11 @@ nonmovingScavengeOne (StgClosure *q)
         // moving heap which may be long gone by the time we call
         // nonmovingTidyWeaks.
         StgWeak *weak = (StgWeak *) p;
-        gct->eager_promotion = true;
-        evacuate(&weak->key);
-        gct->eager_promotion = saved_eager_promotion;
+        debugBelch("nonmovingScav: evac key %p (gen=%d) of weak %p\n",
+                   weak->key, Bdescr(weak->key)->gen_no, weak);
+        //gct->eager_promotion = true;
+        //evacuate(&weak->key);
+        //gct->eager_promotion = saved_eager_promotion;
         goto gen_obj;
     }