/* -----------------------------------------------------------------------------
- * $Id: Block.h,v 1.7 2000/04/05 14:26:31 panne Exp $
+ * $Id: Block.h,v 1.8 2001/07/23 10:47:16 simonmar Exp $
*
* (c) The GHC Team, 1998-1999
*
StgPtr free; /* first free byte of memory */
struct _bdescr *link; /* used for chaining blocks together */
struct _bdescr *back; /* used (occasionally) for doubly-linked lists*/
- struct _generation *gen; /* generation */
+ unsigned int gen_no; /* generation */
struct _step *step; /* step */
StgWord32 blocks; /* no. of blocks (if grp head, 0 otherwise) */
StgWord32 evacuated; /* block is in to-space */
/* -----------------------------------------------------------------------------
- * $Id: StgStorage.h,v 1.7 2000/04/11 16:36:53 sewardj Exp $
+ * $Id: StgStorage.h,v 1.8 2001/07/23 10:47:16 simonmar Exp $
*
* (c) The GHC Team, 1998-1999
*
unsigned int n_blocks; /* number of blocks */
struct _step *to; /* where collected objects from this step go */
struct _generation *gen; /* generation this step belongs to */
+ unsigned int gen_no; /* generation number (cached) */
bdescr *large_objects; /* large objects (doubly linked) */
/* temporary use during GC: */
/* -----------------------------------------------------------------------------
- * $Id: BlockAlloc.c,v 1.7 2000/01/30 10:17:44 simonmar Exp $
+ * $Id: BlockAlloc.c,v 1.8 2001/07/23 10:47:16 simonmar Exp $
*
* (c) The GHC Team 1998-2000
*
#ifdef DEBUG
p->free = (void *)-1; /* indicates that this block is free */
p->step = NULL;
- p->gen = NULL;
+ p->gen_no = 0;
/* fill the block group with garbage if sanity checking is on */
IF_DEBUG(sanity,memset(p->start, 0xaa, p->blocks * BLOCK_SIZE));
#endif
/* -----------------------------------------------------------------------------
- * $Id: GC.c,v 1.102 2001/04/03 16:35:12 sewardj Exp $
+ * $Id: GC.c,v 1.103 2001/07/23 10:47:16 simonmar Exp $
*
* (c) The GHC Team 1998-1999
*
*/
bd = allocBlock();
stp = &generations[g].steps[s];
- ASSERT(stp->gen->no == g);
+ ASSERT(stp->gen_no == g);
ASSERT(stp->hp ? Bdescr(stp->hp)->step == stp : rtsTrue);
- bd->gen = &generations[g];
+ bd->gen_no = g;
bd->step = stp;
bd->link = NULL;
bd->evacuated = 1; /* it's a to-space block */
stp = &generations[g].steps[s];
if (stp->hp_bd == NULL) {
bd = allocBlock();
- bd->gen = &generations[g];
+ bd->gen_no = g;
bd->step = stp;
bd->link = NULL;
bd->evacuated = 0; /* *not* a to-space block */
*/
/* ignore closures in generations that we're not collecting. */
- if (LOOKS_LIKE_STATIC(p) || Bdescr((P_)p)->gen->no > N) {
+ if (LOOKS_LIKE_STATIC(p) || Bdescr((P_)p)->gen_no > N) {
return p;
}
static void addBlock(step *stp)
{
bdescr *bd = allocBlock();
- bd->gen = stp->gen;
+ bd->gen_no = stp->gen_no;
bd->step = stp;
- if (stp->gen->no <= N) {
+ if (stp->gen_no <= N) {
bd->evacuated = 1;
} else {
bd->evacuated = 0;
* evacuate to an older generation, adjust it here (see comment
* by evacuate()).
*/
- if (stp->gen->no < evac_gen) {
+ if (stp->gen_no < evac_gen) {
#ifdef NO_EAGER_PROMOTION
failed_to_evac = rtsTrue;
#else
P_ dest, to, from;
TICK_GC_WORDS_COPIED(size_to_copy);
- if (stp->gen->no < evac_gen) {
+ if (stp->gen_no < evac_gen) {
#ifdef NO_EAGER_PROMOTION
failed_to_evac = rtsTrue;
#else
/* Don't forget to set the failed_to_evac flag if we didn't get
* the desired destination (see comments in evacuate()).
*/
- if (bd->gen->no < evac_gen) {
+ if (bd->gen_no < evac_gen) {
failed_to_evac = rtsTrue;
TICK_GC_FAILED_PROMOTION();
}
/* link it on to the evacuated large object list of the destination step
*/
stp = bd->step->to;
- if (stp->gen->no < evac_gen) {
+ if (stp->gen_no < evac_gen) {
#ifdef NO_EAGER_PROMOTION
failed_to_evac = rtsTrue;
#else
}
bd->step = stp;
- bd->gen = stp->gen;
+ bd->gen_no = stp->gen_no;
bd->link = stp->new_large_objects;
stp->new_large_objects = bd;
bd->evacuated = 1;
loop:
if (HEAP_ALLOCED(q)) {
bd = Bdescr((P_)q);
- if (bd->gen->no > N) {
+ if (bd->gen_no > N) {
/* Can't evacuate this object, because it's in a generation
* older than the ones we're collecting. Let's hope that it's
* in evac_gen or older, or we will have to make an IND_OLDGEN object.
*/
- if (bd->gen->no < evac_gen) {
+ if (bd->gen_no < evac_gen) {
/* nope */
failed_to_evac = rtsTrue;
TICK_GC_FAILED_PROMOTION();
case THUNK_0_2:
case THUNK_2_0:
#ifdef NO_PROMOTE_THUNKS
- if (bd->gen->no == 0 &&
+ if (bd->gen_no == 0 &&
bd->step->no != 0 &&
- bd->step->no == bd->gen->n_steps-1) {
+ bd->step->no == generations[bd->gen_no].n_steps-1) {
stp = bd->step;
}
#endif
if (HEAP_ALLOCED(q)) {
bdescr *bd = Bdescr((P_)q);
if (bd->evacuated) {
- if (bd->gen->no < evac_gen) {
+ if (bd->gen_no < evac_gen) {
failed_to_evac = rtsTrue;
TICK_GC_FAILED_PROMOTION();
}
*/
if (evac_gen > 0) { /* optimisation */
StgClosure *p = ((StgEvacuated*)q)->evacuee;
- if (Bdescr((P_)p)->gen->no < evac_gen) {
+ if (Bdescr((P_)p)->gen_no < evac_gen) {
IF_DEBUG(gc, belch("@@ evacuate: evac of EVACUATED node %p failed!", p));
failed_to_evac = rtsTrue;
TICK_GC_FAILED_PROMOTION();
}
case IND_PERM:
- if (stp->gen->no != 0) {
+ if (stp->gen_no != 0) {
SET_INFO(((StgClosure *)p), &stg_IND_OLDGEN_PERM_info);
}
/* fall through */
} else {
bdescr *bd = Bdescr((P_)frame->updatee);
step *stp;
- if (bd->gen->no > N) {
- if (bd->gen->no < evac_gen) {
+ if (bd->gen_no > N) {
+ if (bd->gen_no < evac_gen) {
failed_to_evac = rtsTrue;
}
continue;
/* Don't promote blackholes */
stp = bd->step;
- if (!(stp->gen->no == 0 &&
+ if (!(stp->gen_no == 0 &&
stp->no != 0 &&
stp->no == stp->gen->n_steps-1)) {
stp = stp->to;
/* -----------------------------------------------------------------------------
- * $Id: Storage.c,v 1.39 2001/07/19 07:28:00 andy Exp $
+ * $Id: Storage.c,v 1.40 2001/07/23 10:47:16 simonmar Exp $
*
* (c) The GHC Team, 1998-1999
*
stp->blocks = NULL;
stp->n_blocks = 0;
stp->gen = &generations[g];
+ stp->gen_no = g;
stp->hp = NULL;
stp->hpLim = NULL;
stp->hp_bd = NULL;
for (cap = free_capabilities; cap != NULL; cap = cap->link) {
for (bd = cap->rNursery; bd; bd = bd->link) {
bd->free = bd->start;
- ASSERT(bd->gen == g0);
+ ASSERT(bd->gen_no == 0);
ASSERT(bd->step == g0s0);
IF_DEBUG(sanity,memset(bd->start, 0xaa, BLOCK_SIZE));
}
#else
for (bd = g0s0->blocks; bd; bd = bd->link) {
bd->free = bd->start;
- ASSERT(bd->gen == g0);
+ ASSERT(bd->gen_no == 0);
ASSERT(bd->step == g0s0);
IF_DEBUG(sanity,memset(bd->start, 0xaa, BLOCK_SIZE));
}
bd = allocBlock();
bd->link = last_bd;
bd->step = g0s0;
- bd->gen = g0;
+ bd->gen_no = 0;
bd->evacuated = 0;
bd->free = bd->start;
last_bd = bd;
nat req_blocks = (lnat)BLOCK_ROUND_UP(n*sizeof(W_)) / BLOCK_SIZE;
bd = allocGroup(req_blocks);
dbl_link_onto(bd, &g0s0->large_objects);
- bd->gen = g0;
+ bd->gen_no = 0;
bd->step = g0s0;
bd->evacuated = 0;
bd->free = bd->start;
bd = allocBlock();
bd->link = small_alloc_list;
small_alloc_list = bd;
- bd->gen = g0;
+ bd->gen_no = 0;
bd->step = g0s0;
bd->evacuated = 0;
alloc_Hp = bd->start;
/* -----------------------------------------------------------------------------
- * $Id: Storage.h,v 1.32 2001/05/03 16:33:27 simonmar Exp $
+ * $Id: Storage.h,v 1.33 2001/07/23 10:47:16 simonmar Exp $
*
* (c) The GHC Team, 1998-1999
*
#endif
bd = Bdescr((P_)p);
- if (bd->gen->no > 0) {
- p->mut_link = bd->gen->mut_list;
- bd->gen->mut_list = p;
+ if (bd->gen_no > 0) {
+ p->mut_link = generations[bd->gen_no].mut_list;
+ generations[bd->gen_no].mut_list = p;
}
}
bdescr *bd;
bd = Bdescr((P_)p);
- if (bd->gen->no > 0) {
- p->mut_link = bd->gen->mut_once_list;
- bd->gen->mut_once_list = p;
+ if (bd->gen_no > 0) {
+ p->mut_link = generations[bd->gen_no].mut_once_list;
+ generations[bd->gen_no].mut_once_list = p;
}
}
bdescr *bd; \
\
bd = Bdescr((P_)p1); \
- if (bd->gen->no == 0) { \
+ if (bd->gen_no == 0) { \
((StgInd *)p1)->indirectee = p2; \
SET_INFO(p1,&stg_IND_info); \
TICK_UPD_NEW_IND(); \
((StgIndOldGen *)p1)->indirectee = p2; \
if (info != &stg_BLACKHOLE_BQ_info) { \
ACQUIRE_LOCK(&sm_mutex); \
- ((StgIndOldGen *)p1)->mut_link = bd->gen->mut_once_list; \
- bd->gen->mut_once_list = (StgMutClosure *)p1; \
+ ((StgIndOldGen *)p1)->mut_link = generations[bd->gen_no].mut_once_list; \
+ generations[bd->gen_no].mut_once_list = (StgMutClosure *)p1; \
RELEASE_LOCK(&sm_mutex); \
} \
SET_INFO(p1,&stg_IND_OLDGEN_info); \
\
ASSERT( p1 != p2 && !closure_IND(p1) ); \
bd = Bdescr((P_)p1); \
- if (bd->gen->no == 0) { \
+ if (bd->gen_no == 0) { \
((StgInd *)p1)->indirectee = p2; \
SET_INFO(p1,&stg_IND_info); \
TICK_UPD_NEW_IND(); \
} \
} \
ACQUIRE_LOCK(&sm_mutex); \
- ((StgIndOldGen *)p1)->mut_link = bd->gen->mut_once_list; \
- bd->gen->mut_once_list = (StgMutClosure *)p1; \
+ ((StgIndOldGen *)p1)->mut_link = generations[bd->gen_no].mut_once_list; \
+ generations[bd->gen_no].mut_once_list = (StgMutClosure *)p1; \
RELEASE_LOCK(&sm_mutex); \
} \
((StgIndOldGen *)p1)->indirectee = p2; \
ASSERT( p1 != p2 && !closure_IND(p1) );
bd = Bdescr((P_)p1);
- if (bd->gen->no == 0) {
+ if (bd->gen_no == 0) {
((StgInd *)p1)->indirectee = p2;
SET_INFO(p1,&stg_IND_PERM_info);
TICK_UPD_NEW_PERM_IND(p1);
((StgIndOldGen *)p1)->indirectee = p2;
if (info != &stg_BLACKHOLE_BQ_info) {
ACQUIRE_LOCK(&sm_mutex);
- ((StgIndOldGen *)p1)->mut_link = bd->gen->mut_once_list;
- bd->gen->mut_once_list = (StgMutClosure *)p1;
+ ((StgIndOldGen *)p1)->mut_link = generations[bd->gen_no].mut_once_list;
+ generations[bd->gen_no].mut_once_list = (StgMutClosure *)p1;
RELEASE_LOCK(&sm_mutex);
}
SET_INFO(p1,&stg_IND_OLDGEN_PERM_info);