[project @ 2006-01-17 16:03:47 by simonmar]
[ghc-hetmet.git] / ghc / rts / GCCompact.c
index f4e66b6..9d05f5d 100644 (file)
@@ -138,7 +138,8 @@ obj_sizeW( StgClosure *p, StgInfoTable *info )
        return pap_sizeW((StgPAP *)p);
     case ARR_WORDS:
        return arr_words_sizeW((StgArrWords *)p);
-    case MUT_ARR_PTRS:
+    case MUT_ARR_PTRS_CLEAN:
+    case MUT_ARR_PTRS_DIRTY:
     case MUT_ARR_PTRS_FROZEN:
     case MUT_ARR_PTRS_FROZEN0:
        return mut_arr_ptrs_sizeW((StgMutArrPtrs*)p);
@@ -478,7 +479,8 @@ update_fwd_large( bdescr *bd )
       // nothing to follow 
       continue;
 
-    case MUT_ARR_PTRS:
+    case MUT_ARR_PTRS_CLEAN:
+    case MUT_ARR_PTRS_DIRTY:
     case MUT_ARR_PTRS_FROZEN:
     case MUT_ARR_PTRS_FROZEN0:
       // follow everything 
@@ -504,6 +506,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 +596,6 @@ thread_obj (StgInfoTable *info, StgPtr p)
 
     case FUN:
     case CONSTR:
-    case FOREIGN:
     case STABLE_NAME:
     case IND_PERM:
     case MUT_VAR:
@@ -644,7 +659,8 @@ thread_obj (StgInfoTable *info, StgPtr p)
     case ARR_WORDS:
        return p + arr_words_sizeW((StgArrWords *)p);
        
-    case MUT_ARR_PTRS:
+    case MUT_ARR_PTRS_CLEAN:
+    case MUT_ARR_PTRS_DIRTY:
     case MUT_ARR_PTRS_FROZEN:
     case MUT_ARR_PTRS_FROZEN0:
        // follow everything 
@@ -675,9 +691,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 +842,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 +917,6 @@ update_bkwd_compact( step *stp )
        freeChain(free_bd->link);
        free_bd->link = NULL;
     }
-    stp->n_blocks = free_blocks;
 
     return free_blocks;
 }
@@ -920,10 +932,10 @@ compact( void (*get_roots)(evac_fn) )
 
     // the weak pointer lists...
     if (weak_ptr_list != NULL) {
-       thread((StgPtr)&weak_ptr_list);
+       thread((StgPtr)(void *)&weak_ptr_list);
     }
     if (old_weak_ptr_list != NULL) {
-       thread((StgPtr)&old_weak_ptr_list); // tmp
+       thread((StgPtr)(void *)&old_weak_ptr_list); // tmp
     }
 
     // mutable lists
@@ -938,16 +950,18 @@ compact( void (*get_roots)(evac_fn) )
     }
 
     // the global thread list
-    thread((StgPtr)&all_threads);
+    thread((StgPtr)(void *)&all_threads);
 
     // any threads resurrected during this GC
-    thread((StgPtr)&resurrected_threads);
+    thread((StgPtr)(void *)&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 +977,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;
     }
 }