X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2Fsm%2FScav.c-inc;h=bff193be7c7bdc7ca1304475388f044b33b455b1;hb=9de1ad504a0a12dabd42b206f06ca04fa0e7009a;hp=951341f235af9f183b19ca0b995ed92e49e62369;hpb=56798c9137870dddb70074ef9e411e8e08eb68e8;p=ghc-hetmet.git diff --git a/rts/sm/Scav.c-inc b/rts/sm/Scav.c-inc index 951341f..bff193b 100644 --- a/rts/sm/Scav.c-inc +++ b/rts/sm/Scav.c-inc @@ -1,6 +1,6 @@ -/* ----------------------------------------------------------------------------- +/* -----------------------------------------------------------------------*-c-*- * - * (c) The GHC Team 1998-2006 + * (c) The GHC Team 1998-2008 * * Generational garbage collector: scavenging functions * @@ -11,18 +11,20 @@ * * ---------------------------------------------------------------------------*/ -// This file is #included into Scav.c, twice: firstly with MINOR_GC +// This file is #included into Scav.c, twice: firstly with PARALLEL_GC // defined, the second time without. -#ifdef MINOR_GC -#define scavenge_block(a,b) scavenge_block0(a,b) -#define evacuate(a) evacuate0(a) +#ifndef PARALLEL_GC +#define scavenge_block(a) scavenge_block1(a) +#define evacuate(a) evacuate1(a) +#define recordMutableGen_GC(a,b) recordMutableGen(a,b) #else #undef scavenge_block #undef evacuate +#undef recordMutableGen_GC #endif -static void scavenge_block (bdescr *bd, StgPtr scan); +static void scavenge_block (bdescr *bd); /* ----------------------------------------------------------------------------- Scavenge a block from the given scan pointer up to bd->free. @@ -37,27 +39,31 @@ static void scavenge_block (bdescr *bd, StgPtr scan); -------------------------------------------------------------------------- */ static void -scavenge_block (bdescr *bd, StgPtr scan) +scavenge_block (bdescr *bd) { StgPtr p, q; StgInfoTable *info; step *saved_evac_step; rtsBool saved_eager_promotion; + step_workspace *ws; - p = scan; - debugTrace(DEBUG_gc, "scavenging block %p (gen %d, step %d) @ %p", - bd->start, bd->gen_no, bd->step->no, scan); + bd->start, bd->gen_no, bd->step->no, bd->u.scan); + gct->scan_bd = bd; gct->evac_step = bd->step; saved_evac_step = gct->evac_step; saved_eager_promotion = gct->eager_promotion; gct->failed_to_evac = rtsFalse; + ws = &gct->steps[bd->step->abs_no]; + + p = bd->u.scan; + // we might be evacuating into the very object that we're // scavenging, so we have to check the real bd->free pointer each // time around the loop. - while (p < bd->free) { + while (p < bd->free || (bd == ws->todo_bd && p < ws->todo_free)) { ASSERT(LOOKS_LIKE_CLOSURE_PTR(p)); info = get_itbl((StgClosure *)p); @@ -87,18 +93,14 @@ scavenge_block (bdescr *bd, StgPtr scan) } case FUN_2_0: -#ifndef MINOR_GC scavenge_fun_srt(info); -#endif evacuate(&((StgClosure *)p)->payload[1]); evacuate(&((StgClosure *)p)->payload[0]); p += sizeofW(StgHeader) + 2; break; case THUNK_2_0: -#ifndef MINOR_GC scavenge_thunk_srt(info); -#endif evacuate(&((StgThunk *)p)->payload[1]); evacuate(&((StgThunk *)p)->payload[0]); p += sizeofW(StgThunk) + 2; @@ -111,82 +113,62 @@ scavenge_block (bdescr *bd, StgPtr scan) break; case THUNK_1_0: -#ifndef MINOR_GC scavenge_thunk_srt(info); -#endif evacuate(&((StgThunk *)p)->payload[0]); p += sizeofW(StgThunk) + 1; break; case FUN_1_0: -#ifndef MINOR_GC scavenge_fun_srt(info); -#endif case CONSTR_1_0: evacuate(&((StgClosure *)p)->payload[0]); p += sizeofW(StgHeader) + 1; break; case THUNK_0_1: -#ifndef MINOR_GC scavenge_thunk_srt(info); -#endif p += sizeofW(StgThunk) + 1; break; case FUN_0_1: -#ifndef MINOR_GC scavenge_fun_srt(info); -#endif case CONSTR_0_1: p += sizeofW(StgHeader) + 1; break; case THUNK_0_2: -#ifndef MINOR_GC scavenge_thunk_srt(info); -#endif p += sizeofW(StgThunk) + 2; break; case FUN_0_2: -#ifndef MINOR_GC scavenge_fun_srt(info); -#endif case CONSTR_0_2: p += sizeofW(StgHeader) + 2; break; case THUNK_1_1: -#ifndef MINOR_GC scavenge_thunk_srt(info); -#endif evacuate(&((StgThunk *)p)->payload[0]); p += sizeofW(StgThunk) + 2; break; case FUN_1_1: -#ifndef MINOR_GC scavenge_fun_srt(info); -#endif case CONSTR_1_1: evacuate(&((StgClosure *)p)->payload[0]); p += sizeofW(StgHeader) + 2; break; case FUN: -#ifndef MINOR_GC scavenge_fun_srt(info); -#endif goto gen_obj; case THUNK: { StgPtr end; -#ifndef MINOR_GC scavenge_thunk_srt(info); -#endif end = (P_)((StgThunk *)p)->payload + info->layout.payload.ptrs; for (p = (P_)((StgThunk *)p)->payload; p < end; p++) { evacuate((StgClosure **)p); @@ -462,5 +444,27 @@ scavenge_block (bdescr *bd, StgPtr scan) } } - debugTrace(DEBUG_gc, " scavenged %ld bytes", (bd->free - scan) * sizeof(W_)); + if (p > bd->free) { + gct->copied += ws->todo_free - bd->free; + bd->free = p; + } + + debugTrace(DEBUG_gc, " scavenged %ld bytes", + (unsigned long)((bd->free - bd->u.scan) * sizeof(W_))); + + // update stats: this is a block that has been scavenged + gct->scanned += bd->free - bd->u.scan; + bd->u.scan = bd->free; + + if (bd != ws->todo_bd) { + // we're not going to evac any more objects into + // this block, so push it now. + push_scanned_block(bd, ws); + } + + gct->scan_bd = NULL; } + +#undef scavenge_block +#undef evacuate +#undef recordMutableGen_GC