/* -----------------------------------------------------------------------------
- * $Id: GC.c,v 1.83 2000/05/26 08:42:59 simonmar Exp $
+ * $Id: GC.c,v 1.90 2000/12/04 12:31:20 simonmar Exp $
*
* (c) The GHC Team 1998-1999
*
#include "Sanity.h"
#include "GC.h"
#include "BlockAlloc.h"
+#include "MBlock.h"
#include "Main.h"
#include "ProfHeap.h"
#include "SchedAPI.h"
# include "ParallelDebug.h"
# endif
#endif
+#if defined(GHCI)
+# include "HsFFI.h"
+# include "Linker.h"
+#endif
+#if defined(RTS_GTK_FRONTPANEL)
+#include "FrontPanel.h"
+#endif
//@node STATIC OBJECT LIST, Static function declarations, Includes
//@subsection STATIC OBJECT LIST
*/
bdescr *old_to_space;
-
/* Data used for allocation area sizing.
*/
lnat new_blocks; /* blocks allocated during this GC */
CCCS = CCS_GC;
#endif
- /* Approximate how much we allocated */
+ /* Approximate how much we allocated.
+ * Todo: only when generating stats?
+ */
allocated = calcAllocated();
/* Figure out which generation to collect
major_gc = (N == RtsFlags.GcFlags.generations-1);
}
+#ifdef RTS_GTK_FRONTPANEL
+ if (RtsFlags.GcFlags.frontpanel) {
+ updateFrontPanelBeforeGC(N);
+ }
+#endif
+
/* check stack sanity *before* GC (ToDo: check all threads) */
#if defined(GRAN)
// ToDo!: check sanity IF_DEBUG(sanity, checkTSOsSanity());
/* check for memory leaks if sanity checking is on */
IF_DEBUG(sanity, memInventory());
+#ifdef RTS_GTK_VISUALS
+ if (RtsFlags.GcFlags.visuals) {
+ updateFrontPanelAfterGC( N, live );
+ }
+#endif
+
/* ok, GC over: tell the stats department what happened. */
stat_endGC(allocated, collected, live, copied, N);
}
/* There might be a DEAD_WEAK on the list if finalizeWeak# was
* called on a live weak pointer object. Just remove it.
*/
- if (w->header.info == &DEAD_WEAK_info) {
+ if (w->header.info == &stg_DEAD_WEAK_info) {
next_w = ((StgDeadWeak *)w)->link;
*last_w = next_w;
continue;
next = t->global_link;
*prev = next;
continue;
- default:
+ default: ;
}
/* Threads which have already been determined to be alive are
static __inline__ void
upd_evacuee(StgClosure *p, StgClosure *dest)
{
- p->header.info = &EVACUATED_info;
+ p->header.info = &stg_EVACUATED_info;
((StgEvacuated *)p)->evacuee = dest;
}
q = (StgMutVar *)step->hp;
step->hp += sizeofW(StgMutVar);
- SET_HDR(q,&MUT_CONS_info,CCS_GC);
+ SET_HDR(q,&stg_MUT_CONS_info,CCS_GC);
q->var = ptr;
recordOldToNewPtrs((StgMutClosure *)q);
}
case MUT_VAR:
- ASSERT(q->header.info != &MUT_CONS_info);
+ ASSERT(q->header.info != &stg_MUT_CONS_info);
case MVAR:
to = copy(q,sizeW_fromITBL(info),step);
recordMutable((StgMutClosure *)to);
return to;
+ case CONSTR_0_1:
+ {
+ StgWord w = (StgWord)q->payload[0];
+ if (q->header.info == Czh_con_info &&
+ /* unsigned, so always true: (StgChar)w >= MIN_CHARLIKE && */
+ (StgChar)w <= MAX_CHARLIKE) {
+ return (StgClosure *)CHARLIKE_CLOSURE((StgChar)w);
+ }
+ if (q->header.info == Izh_con_info &&
+ (StgInt)w >= MIN_INTLIKE && (StgInt)w <= MAX_INTLIKE) {
+ return (StgClosure *)INTLIKE_CLOSURE((StgInt)w);
+ }
+ /* else, fall through ... */
+ }
+
case FUN_1_0:
case FUN_0_1:
case CONSTR_1_0:
- case CONSTR_0_1:
return copy(q,sizeofW(StgHeader)+1,step);
case THUNK_1_0: /* here because of MIN_UPD_SIZE */
/* relocate the stack pointers... */
new_tso->su = (StgUpdateFrame *) ((StgPtr)new_tso->su + diff);
new_tso->sp = (StgPtr)new_tso->sp + diff;
- new_tso->splim = (StgPtr)new_tso->splim + diff;
relocate_TSO(tso, new_tso);
case IND_PERM:
if (step->gen->no != 0) {
- SET_INFO(((StgClosure *)p), &IND_OLDGEN_PERM_info);
+ SET_INFO(((StgClosure *)p), &stg_IND_OLDGEN_PERM_info);
}
/* fall through */
case IND_OLDGEN_PERM:
case MUT_VAR:
/* ignore MUT_CONSs */
- if (((StgMutVar *)p)->header.info != &MUT_CONS_info) {
+ if (((StgMutVar *)p)->header.info != &stg_MUT_CONS_info) {
evac_gen = 0;
((StgMutVar *)p)->var = evacuate(((StgMutVar *)p)->var);
evac_gen = saved_evac_gen;
* it from the mutable list if possible by promoting whatever it
* points to.
*/
- ASSERT(p->header.info == &MUT_CONS_info);
+ ASSERT(p->header.info == &stg_MUT_CONS_info);
if (scavenge_one(((StgMutVar *)p)->var) == rtsTrue) {
/* didn't manage to promote everything, so put the
* MUT_CONS back on the list.
* it from the mutable list if possible by promoting whatever it
* points to.
*/
- ASSERT(p->header.info != &MUT_CONS_info);
+ ASSERT(p->header.info != &stg_MUT_CONS_info);
((StgMutVar *)p)->var = evacuate(((StgMutVar *)p)->var);
p->mut_link = gen->mut_list;
gen->mut_list = p;
if (STATIC_LINK(info,p) == NULL) {
IF_DEBUG(gccafs, fprintf(stderr, "CAF gc'd at 0x%04x\n", (int)p));
/* black hole it */
- SET_INFO(p,&BLACKHOLE_info);
+ SET_INFO(p,&stg_BLACKHOLE_info);
p = STATIC_LINK2(info,p);
*pp = p;
}
* The blackhole made for a CAF is a CAF_BLACKHOLE, so they
* don't interfere with this optimisation.
*/
- if (bh->header.info == &BLACKHOLE_info) {
+ if (bh->header.info == &stg_BLACKHOLE_info) {
return;
}
- if (bh->header.info != &BLACKHOLE_BQ_info &&
- bh->header.info != &CAF_BLACKHOLE_info) {
+ if (bh->header.info != &stg_BLACKHOLE_BQ_info &&
+ bh->header.info != &stg_CAF_BLACKHOLE_info) {
#if (!defined(LAZY_BLACKHOLING)) && defined(DEBUG)
fprintf(stderr,"Unexpected lazy BHing required at 0x%04x\n",(int)bh);
#endif
- SET_INFO(bh,&BLACKHOLE_info);
+ SET_INFO(bh,&stg_BLACKHOLE_info);
}
update_frame = update_frame->link;
})
switch (get_itbl(frame)->type) {
case UPDATE_FRAME: upd_frames++;
- if (frame->updatee->header.info == &BLACKHOLE_info)
+ if (frame->updatee->header.info == &stg_BLACKHOLE_info)
bhs++;
break;
case STOP_FRAME: stop_frames++;
}
#endif
if (get_itbl(frame)->type == UPDATE_FRAME
- && frame->updatee->header.info == &BLACKHOLE_info) {
+ && frame->updatee->header.info == &stg_BLACKHOLE_info) {
break;
}
}
# if (!defined(LAZY_BLACKHOLING)) && defined(DEBUG)
# error Unimplemented lazy BH warning. (KSW 1999-01)
# endif
- if (GET_INFO(updatee_bypass) == BLACKHOLE_BQ_info
- || GET_INFO(updatee_bypass) == CAF_BLACKHOLE_info
+ if (GET_INFO(updatee_bypass) == stg_BLACKHOLE_BQ_info
+ || GET_INFO(updatee_bypass) == stg_CAF_BLACKHOLE_info
) {
/* Sigh. It has one. Don't lose those threads! */
- if (GET_INFO(updatee_keep) == BLACKHOLE_BQ_info) {
+ if (GET_INFO(updatee_keep) == stg_BLACKHOLE_BQ_info) {
/* Urgh. Two queues. Merge them. */
P_ keep_tso = ((StgBlockingQueue *)updatee_keep)->blocking_queue;
*/
if (is_update_frame) {
StgBlockingQueue *bh = (StgBlockingQueue *)frame->updatee;
- if (bh->header.info != &BLACKHOLE_info &&
- bh->header.info != &BLACKHOLE_BQ_info &&
- bh->header.info != &CAF_BLACKHOLE_info) {
+ if (bh->header.info != &stg_BLACKHOLE_info &&
+ bh->header.info != &stg_BLACKHOLE_BQ_info &&
+ bh->header.info != &stg_CAF_BLACKHOLE_info) {
#if (!defined(LAZY_BLACKHOLING)) && defined(DEBUG)
fprintf(stderr,"Unexpected lazy BHing required at 0x%04x\n",(int)bh);
#endif
- SET_INFO(bh,&BLACKHOLE_info);
+#ifdef DEBUG
+ /* zero out the slop so that the sanity checker can tell
+ * where the next closure is.
+ */
+ {
+ StgInfoTable *info = get_itbl(bh);
+ nat np = info->layout.payload.ptrs, nw = info->layout.payload.nptrs, i;
+ for (i = np; i < np + nw; i++) {
+ ((StgClosure *)bh)->payload[i] = 0;
+ }
+ }
+#endif
+ SET_INFO(bh,&stg_BLACKHOLE_info);
}
}