simplification/optimisation: update tso->bound->tso when scavenging the TSO
authorSimon Marlow <marlowsd@gmail.com>
Tue, 8 Dec 2009 08:57:39 +0000 (08:57 +0000)
committerSimon Marlow <marlowsd@gmail.com>
Tue, 8 Dec 2009 08:57:39 +0000 (08:57 +0000)
rts/sm/GC.c
rts/sm/Scav.c

index 99b0ecc..63023b6 100644 (file)
@@ -140,7 +140,6 @@ static nat  initialise_N            (rtsBool force_major_gc);
 static void init_collected_gen      (nat g, nat threads);
 static void init_uncollected_gen    (nat g, nat threads);
 static void init_gc_thread          (gc_thread *t);
-static void update_task_list        (void);
 static void resize_generations      (void);
 static void resize_nursery          (void);
 static void start_gc_threads        (void);
@@ -416,9 +415,6 @@ SET_GCT(gc_threads[0]);
 
   shutdown_gc_threads(n_gc_threads, gct->thread_index);
 
-  // Update pointers from the Task list
-  update_task_list();
-
   // Now see which stable names are still alive.
   gcStablePtrTable();
 
@@ -1452,39 +1448,6 @@ zero_static_object_list(StgClosure* first_static)
 }
 
 /* ----------------------------------------------------------------------------
-   Update the pointers from the task list
-
-   These are treated as weak pointers because we want to allow a main
-   thread to get a BlockedOnDeadMVar exception in the same way as any
-   other thread.  Note that the threads should all have been retained
-   by GC by virtue of being on the all_threads list, we're just
-   updating pointers here.
-   ------------------------------------------------------------------------- */
-
-static void
-update_task_list (void)
-{
-    Task *task;
-    StgTSO *tso;
-    for (task = all_tasks; task != NULL; task = task->all_link) {
-       if (!task->stopped && task->tso) {
-           ASSERT(task->tso->bound == task);
-           tso = (StgTSO *) isAlive((StgClosure *)task->tso);
-           if (tso == NULL) {
-               barf("task %p: main thread %d has been GC'd", 
-#ifdef THREADED_RTS
-                    (void *)task->id, 
-#else
-                    (void *)task,
-#endif
-                    task->tso->id);
-           }
-           task->tso = tso;
-       }
-    }
-}
-
-/* ----------------------------------------------------------------------------
    Reset the sizes of the older generations when we do a major
    collection.
   
index b34aca6..4fa0a22 100644 (file)
@@ -73,6 +73,11 @@ scavengeTSO (StgTSO *tso)
 
     debugTrace(DEBUG_gc,"scavenging thread %d",(int)tso->id);
 
+    // update the pointer from the Task.
+    if (tso->bound != NULL) {
+        tso->bound->tso = tso;
+    }
+
     saved_eager = gct->eager_promotion;
     gct->eager_promotion = rtsFalse;