[project @ 2005-05-05 11:35:29 by simonmar]
[ghc-hetmet.git] / ghc / rts / GC.c
index a4f0c17..0cef213 100644 (file)
@@ -1029,7 +1029,7 @@ GarbageCollect ( void (*get_roots)(evac_fn), rtsBool force_major_gc )
     } else {
       // we might have added extra large blocks to the nursery, so
       // resize back to minAllocAreaSize again.
-      resizeNurseries(RtsFlags.GcFlags.minAllocAreaSize);
+      resizeNurseriesFixed(RtsFlags.GcFlags.minAllocAreaSize);
     }
   }
 
@@ -1294,6 +1294,21 @@ traverse_weak_ptr_list(void)
          }
       }
       
+      /* Finally, we can update the blackhole_queue.  This queue
+       * simply strings together TSOs blocked on black holes, it is
+       * not intended to keep anything alive.  Hence, we do not follow
+       * pointers on the blackhole_queue until now, when we have
+       * determined which TSOs are otherwise reachable.  We know at
+       * this point that all TSOs have been evacuated, however.
+       */
+      { 
+         StgTSO **pt;
+         for (pt = &blackhole_queue; *pt != END_TSO_QUEUE; pt = &((*pt)->link)) {
+             *pt = (StgTSO *)isAlive((StgClosure *)*pt);
+             ASSERT(*pt != NULL);
+         }
+      }
+
       weak_stage = WeakDone;  // *now* we're done,
       return rtsTrue;         // but one more round of scavenging, please
 
@@ -2356,8 +2371,10 @@ scavenge_fun_srt(const StgInfoTable *info)
 static void
 scavengeTSO (StgTSO *tso)
 {
-    // chase the link field for any TSOs on the same queue 
-    tso->link = (StgTSO *)evacuate((StgClosure *)tso->link);
+    // We don't chase the link field: TSOs on the blackhole queue are
+    // not automatically alive, so the link field is a "weak" pointer.
+    // Queues of TSOs are traversed explicitly.
+
     if (   tso->why_blocked == BlockedOnMVar
        || tso->why_blocked == BlockedOnBlackHole
        || tso->why_blocked == BlockedOnException
@@ -3368,11 +3385,11 @@ scavenge_one(StgPtr p)
     }
 
     case PAP:
-       p = scavenge_AP((StgAP *)p);
+       p = scavenge_PAP((StgPAP *)p);
        break;
 
     case AP:
-       p = scavenge_PAP((StgPAP *)p);
+       p = scavenge_AP((StgAP *)p);
        break;
 
     case ARR_WORDS:
@@ -4308,20 +4325,4 @@ printMutableList(generation *gen)
     }
     debugBelch("\n");
 }
-
-STATIC_INLINE rtsBool
-maybeLarge(StgClosure *closure)
-{
-  StgInfoTable *info = get_itbl(closure);
-
-  /* closure types that may be found on the new_large_objects list; 
-     see scavenge_large */
-  return (info->type == MUT_ARR_PTRS ||
-         info->type == MUT_ARR_PTRS_FROZEN ||
-         info->type == MUT_ARR_PTRS_FROZEN0 ||
-         info->type == TSO ||
-         info->type == ARR_WORDS);
-}
-
-  
 #endif /* DEBUG */