/* ----------------------------------------------------------------------------
- * $Id: ClosureMacros.h,v 1.29 2000/12/04 12:31:20 simonmar Exp $
+ * $Id: ClosureMacros.h,v 1.30 2000/12/11 12:36:59 simonmar Exp $
*
* (c) The GHC Team, 1998-1999
*
/* constructors don't have SRTs */
#define GET_TAG(info) (INFO_PTR_TO_STRUCT(info)->srt_len)
-/* -----------------------------------------------------------------------------
- BCOs.
- -------------------------------------------------------------------------- */
-
-#define bcoConstPtr( bco, i ) (*stgCast(StgPtr*, ((bco)->payload+(i))))
-#define bcoConstCPtr( bco, i ) (*stgCast(StgClosurePtr*,((bco)->payload+(i))))
-#define bcoConstInfoPtr( bco, i )(*stgCast(StgInfoTable**,((bco)->payload+(bco)->n_ptrs+i)))
-#define bcoConstInt( bco, i ) (*stgCast(StgInt*, ((bco)->payload+(bco)->n_ptrs+i)))
-#define bcoConstInt64( bco, i ) (PK_Int64(stgCast(StgWord*,(bco)->payload+(bco)->n_ptrs+i)))
-#define bcoConstWord( bco, i ) (*stgCast(StgWord*, ((bco)->payload+(bco)->n_ptrs+i)))
-#define bcoConstAddr( bco, i ) (*stgCast(StgAddr*, ((bco)->payload+(bco)->n_ptrs+i)))
-#define bcoConstChar( bco, i ) (*stgCast(StgChar*, ((bco)->payload+(bco)->n_ptrs+i)))
-#define bcoConstFloat( bco, i ) (PK_FLT(stgCast(StgWord*,(bco)->payload+(bco)->n_ptrs+i)))
-#define bcoConstDouble( bco, i ) (PK_DBL(stgCast(StgWord*,(bco)->payload+(bco)->n_ptrs+i)))
-#define bcoInstr( bco, i ) (stgCast(StgWord8*, ((bco)->payload+(bco)->n_ptrs+(bco)->n_words))[i])
-static __inline__ StgInt bcoInstr16 ( StgBCO* bco, unsigned int i )
-{ StgInt x = (bcoInstr(bco,i) << 8) + bcoInstr(bco,i+1); return x; }
-
#endif /* CLOSUREMACROS_H */
/* ----------------------------------------------------------------------------
- * $Id: Closures.h,v 1.19 2000/11/07 17:05:47 simonmar Exp $
+ * $Id: Closures.h,v 1.20 2000/12/11 12:36:59 simonmar Exp $
*
* (c) The GHC Team, 1998-1999
*
typedef struct {
StgHeader header;
- StgWord n_ptrs;
- StgWord n_words;
- StgWord n_instrs;
- StgWord stgexpr;
- StgClosure *payload[0];
+ StgPtr literals; /* a pointer to an ArrWords */
+ StgPtr instrs; /* a pointer to an ArrWords */
+ StgPtr ptrs; /* a pointer to a MutArrPtrs */
} StgBCO;
typedef struct {
/* -----------------------------------------------------------------------------
- * $Id: GC.c,v 1.90 2000/12/04 12:31:20 simonmar Exp $
+ * $Id: GC.c,v 1.91 2000/12/11 12:36:59 simonmar Exp $
*
* (c) The GHC Team 1998-1999
*
/* alive! */
return ((StgEvacuated *)p)->evacuee;
- case BCO:
- size = bco_sizeW((StgBCO*)p);
- goto large;
-
case ARR_WORDS:
size = arr_words_sizeW((StgArrWords *)p);
goto large;
switch (info -> type) {
- case BCO:
- {
- nat size = bco_sizeW((StgBCO*)q);
-
- if (size >= LARGE_OBJECT_THRESHOLD/sizeof(W_)) {
- evacuate_large((P_)q, rtsFalse);
- to = q;
- } else {
- /* just copy the block */
- to = copy(q,size,step);
- }
- return to;
- }
-
case MUT_VAR:
ASSERT(q->header.info != &stg_MUT_CONS_info);
case MVAR:
case WEAK:
case FOREIGN:
case STABLE_NAME:
+ case BCO:
return copy(q,sizeW_fromITBL(info),step);
case CAF_BLACKHOLE:
switch (info -> type) {
- case BCO:
- {
- StgBCO* bco = (StgBCO *)p;
- nat i;
- for (i = 0; i < bco->n_ptrs; i++) {
- bcoConstCPtr(bco,i) = evacuate(bcoConstCPtr(bco,i));
- }
- p += bco_sizeW(bco);
- break;
- }
-
case MVAR:
/* treat MVars specially, because we don't want to evacuate the
* mut_link field in the middle of the closure.
case WEAK:
case FOREIGN:
case STABLE_NAME:
+ case BCO:
{
StgPtr end;
continue;
}
- case BCO:
- {
- StgBCO* bco = (StgBCO *)p;
- nat i;
- evac_gen = saved_evac_gen;
- for (i = 0; i < bco->n_ptrs; i++) {
- bcoConstCPtr(bco,i) = evacuate(bcoConstCPtr(bco,i));
- }
- evac_gen = 0;
- continue;
- }
-
case TSO:
scavengeTSO((StgTSO *)p);
continue;
return (info->type == MUT_ARR_PTRS ||
info->type == MUT_ARR_PTRS_FROZEN ||
info->type == TSO ||
- info->type == ARR_WORDS ||
- info->type == BCO);
+ info->type == ARR_WORDS);
}
/* -----------------------------------------------------------------------------
- * $Id: ProfHeap.c,v 1.19 2000/12/04 12:31:21 simonmar Exp $
+ * $Id: ProfHeap.c,v 1.20 2000/12/11 12:36:59 simonmar Exp $
*
* (c) The GHC Team, 1998-2000
*
info = get_itbl((StgClosure *)p);
switch (info->type) {
- case BCO:
- size = bco_sizeW((StgBCO *)p);
- break;
case CONSTR:
if (((StgClosure *)p)->header.info == &stg_DEAD_WEAK_info
}
/* else, fall through... */
+ case BCO:
case FUN:
case THUNK:
case IND_PERM:
/* -----------------------------------------------------------------------------
- * $Id: Sanity.c,v 1.23 2000/12/04 12:31:21 simonmar Exp $
+ * $Id: Sanity.c,v 1.24 2000/12/11 12:37:00 simonmar Exp $
*
* (c) The GHC Team, 1998-1999
*
#include "RtsUtils.h"
#include "BlockAlloc.h"
#include "Sanity.h"
+#include "MBlock.h"
+#include "Storage.h"
#include "Schedule.h"
#include "StoragePriv.h" // for END_OF_STATIC_LIST
info = get_itbl(p);
switch (info->type) {
- case BCO:
- {
- StgBCO* bco = stgCast(StgBCO*,p);
- nat i;
- for(i=0; i < bco->n_ptrs; ++i) {
- ASSERT(LOOKS_LIKE_PTR(bcoConstPtr(bco,i)));
- }
- return bco_sizeW(bco);
- }
case MVAR:
{
#endif
case BLACKHOLE:
case FOREIGN:
+ case BCO:
case STABLE_NAME:
case MUT_VAR:
case CONSTR_INTLIKE:
/* -----------------------------------------------------------------------------
- * $Id: Sanity.h,v 1.6 2000/03/31 03:09:36 hwloidl Exp $
+ * $Id: Sanity.h,v 1.7 2000/12/11 12:37:00 simonmar Exp $
*
* (c) The GHC Team, 1998-1999
*
#ifdef DEBUG
/* debugging routines */
extern void checkHeap ( bdescr *bd, StgPtr start );
+extern void checkHeapChunk ( StgPtr start, StgPtr end );
extern void checkChain ( bdescr *bd );
extern void checkStack ( StgPtr sp, StgPtr stack_end, StgUpdateFrame* su );
extern void checkTSO ( StgTSO* tso );
/* -----------------------------------------------------------------------------
- * $Id: StgMiscClosures.hc,v 1.52 2000/12/04 12:31:21 simonmar Exp $
+ * $Id: StgMiscClosures.hc,v 1.53 2000/12/11 12:37:00 simonmar Exp $
*
* (c) The GHC Team, 1998-2000
*
/* -----------------------------------------------------------------------------
The code for a BCO returns to the scheduler
-------------------------------------------------------------------------- */
-INFO_TABLE(stg_BCO_info,stg_BCO_entry,0,0,BCO,,EF_,"BCO","BCO");
+INFO_TABLE(stg_BCO_info,stg_BCO_entry,3,0,BCO,,EF_,"BCO","BCO");
STGFUN(stg_BCO_entry) {
FB_
Sp -= 1;
/* -----------------------------------------------------------------------------
- * $Id: Storage.c,v 1.29 2000/12/04 12:31:22 simonmar Exp $
+ * $Id: Storage.c,v 1.30 2000/12/11 12:37:00 simonmar Exp $
*
* (c) The GHC Team, 1998-1999
*
stat_exit(calcAllocated());
}
+/* -----------------------------------------------------------------------------
+ Setting the heap size. This function is callable from Haskell (GHC
+ uses it to implement the -H<size> option).
+ -------------------------------------------------------------------------- */
+
+void
+setHeapSize( HsInt size )
+{
+ RtsFlags.GcFlags.heapSizeSuggestion = size / BLOCK_SIZE;
+ if (RtsFlags.GcFlags.heapSizeSuggestion >
+ RtsFlags.GcFlags.maxHeapSize) {
+ RtsFlags.GcFlags.maxHeapSize = RtsFlags.GcFlags.heapSizeSuggestion;
+ }
+}
/* -----------------------------------------------------------------------------
CAF management.
/* -----------------------------------------------------------------------------
- * $Id: Storage.h,v 1.18 2000/12/04 12:31:22 simonmar Exp $
+ * $Id: Storage.h,v 1.19 2000/12/11 12:37:00 simonmar Exp $
*
* (c) The GHC Team, 1998-1999
*
extern void exitStorage(void);
/* -----------------------------------------------------------------------------
+ Setting the heap size.
+ ------------------------------------------------------------------------- */
+
+extern void setHeapSize( HsInt size );
+
+/* -----------------------------------------------------------------------------
Generic allocation
StgPtr allocate(int n) Allocates a chunk of contiguous store
static __inline__ StgOffset mut_arr_ptrs_sizeW( StgMutArrPtrs* x )
{ return sizeofW(StgMutArrPtrs) + x->ptrs; }
-static __inline__ StgWord bco_sizeW( StgBCO* bco )
-{ return BCO_sizeW(bco->n_ptrs,bco->n_words,bco->n_instrs); }
-
static __inline__ StgWord tso_sizeW ( StgTSO *tso )
{ return TSO_STRUCT_SIZEW + tso->stack_size; }