X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2Fsm%2FScav.c-inc;h=bff193be7c7bdc7ca1304475388f044b33b455b1;hb=9de1ad504a0a12dabd42b206f06ca04fa0e7009a;hp=e9aeb2c934a674abec06ea1a3169e8dd839a9ee7;hpb=e5601110f37f48771b9e62296770a29e79d96e28;p=ghc-hetmet.git diff --git a/rts/sm/Scav.c-inc b/rts/sm/Scav.c-inc index e9aeb2c..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,19 +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. @@ -38,7 +39,7 @@ 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; @@ -46,11 +47,10 @@ scavenge_block (bdescr *bd, StgPtr scan) 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; @@ -58,6 +58,8 @@ scavenge_block (bdescr *bd, StgPtr scan) 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. @@ -91,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; @@ -115,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); @@ -467,9 +445,26 @@ scavenge_block (bdescr *bd, StgPtr scan) } if (p > bd->free) { + gct->copied += ws->todo_free - bd->free; bd->free = p; } debugTrace(DEBUG_gc, " scavenged %ld bytes", - (unsigned long)((bd->free - scan) * sizeof(W_))); + (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