[project @ 2006-01-09 14:31:37 by simonmar]
[ghc-hetmet.git] / ghc / rts / GCCompact.c
index f4e66b6..e53429c 100644 (file)
@@ -504,6 +504,20 @@ update_fwd_large( bdescr *bd )
        thread_PAP((StgPAP *)p);
        continue;
 
+    case TREC_CHUNK:
+    {
+        StgWord i;
+        StgTRecChunk *tc = (StgTRecChunk *)p;
+       TRecEntry *e = &(tc -> entries[0]);
+       thread((StgPtr)&tc->prev_chunk);
+       for (i = 0; i < tc -> next_entry_idx; i ++, e++ ) {
+         thread((StgPtr)&e->tvar);
+         thread((StgPtr)&e->expected_value);
+         thread((StgPtr)&e->new_value);
+       }
+       continue;
+    }
+
     default:
       barf("update_fwd_large: unknown/strange object  %d", (int)(info->type));
     }
@@ -580,7 +594,6 @@ thread_obj (StgInfoTable *info, StgPtr p)
 
     case FUN:
     case CONSTR:
-    case FOREIGN:
     case STABLE_NAME:
     case IND_PERM:
     case MUT_VAR:
@@ -675,9 +688,6 @@ thread_obj (StgInfoTable *info, StgPtr p)
         StgTVar *tvar = (StgTVar *)p;
        thread((StgPtr)&tvar->current_value);
        thread((StgPtr)&tvar->first_wait_queue_entry);
-#if defined(SMP)
-       thread((StgPtr)&tvar->last_update_by);
-#endif
        return p + sizeofW(StgTVar);
     }
     
@@ -829,7 +839,7 @@ update_bkwd_compact( step *stp )
     StgInfoTable *info;
     nat size, free_blocks;
 
-    bd = free_bd = stp->blocks;
+    bd = free_bd = stp->old_blocks;
     free = free_bd->start;
     free_blocks = 1;
 
@@ -904,7 +914,6 @@ update_bkwd_compact( step *stp )
        freeChain(free_bd->link);
        free_bd->link = NULL;
     }
-    stp->n_blocks = free_blocks;
 
     return free_blocks;
 }
@@ -943,11 +952,13 @@ compact( void (*get_roots)(evac_fn) )
     // any threads resurrected during this GC
     thread((StgPtr)&resurrected_threads);
 
-    // the main threads list
+    // the task list
     {
-       StgMainThread *m;
-       for (m = main_threads; m != NULL; m = m->link) {
-           thread((StgPtr)&m->tso);
+       Task *task;
+       for (task = all_tasks; task != NULL; task = task->all_link) {
+           if (task->tso) {
+               thread((StgPtr)&task->tso);
+           }
        }
     }
 
@@ -963,25 +974,26 @@ compact( void (*get_roots)(evac_fn) )
     // 2. update forward ptrs
     for (g = 0; g < RtsFlags.GcFlags.generations; g++) {
        for (s = 0; s < generations[g].n_steps; s++) {
+           if (g==0 && s ==0) continue;
            stp = &generations[g].steps[s];
            IF_DEBUG(gc, debugBelch("update_fwd:  %d.%d\n", stp->gen->no, stp->no););
 
-           update_fwd(stp->to_blocks);
+           update_fwd(stp->blocks);
            update_fwd_large(stp->scavenged_large_objects);
-           if (g == RtsFlags.GcFlags.generations-1 && stp->blocks != NULL) {
+           if (g == RtsFlags.GcFlags.generations-1 && stp->old_blocks != NULL) {
                IF_DEBUG(gc, debugBelch("update_fwd:  %d.%d (compact)\n", stp->gen->no, stp->no););
-               update_fwd_compact(stp->blocks);
+               update_fwd_compact(stp->old_blocks);
            }
        }
     }
 
     // 3. update backward ptrs
     stp = &oldest_gen->steps[0];
-    if (stp->blocks != NULL) {
+    if (stp->old_blocks != NULL) {
        blocks = update_bkwd_compact(stp);
        IF_DEBUG(gc, debugBelch("update_bkwd: %d.%d (compact, old: %d blocks, now %d blocks)\n", 
                             stp->gen->no, stp->no,
-                            stp->n_blocks, blocks););
-       stp->n_blocks = blocks;
+                            stp->n_old_blocks, blocks););
+       stp->n_old_blocks = blocks;
     }
 }