/* -----------------------------------------------------------------------------
- * $Id: Storage.h,v 1.47 2002/12/13 14:43:06 simonmar Exp $
+ * $Id: Storage.h,v 1.53 2003/11/12 17:49:11 sof Exp $
*
* (c) The GHC Team, 1998-2002
*
lnat allocated_bytes(void) Returns the number of bytes allocated
via allocate() since the last GC.
- Used in the reoprting of statistics.
+ Used in the reporting of statistics.
SMP: allocate and doYouWantToGC can be used from STG code, they are
surrounded by a mutex.
extern StgPtr allocatePinned ( nat n );
extern lnat allocated_bytes ( void );
-static inline rtsBool
+INLINE_HEADER rtsBool
doYouWantToGC( void )
{
return (alloc_blocks >= alloc_blocks_lim);
-------------------------------------------------------------------------- */
#define ExtendNursery(hp,hplim) \
- (CurrentNursery->free = (P_)(hp)+1, \
+ (CloseNursery(hp), \
CurrentNursery->link == NULL ? rtsFalse : \
(CurrentNursery = CurrentNursery->link, \
OpenNursery(hp,hplim), \
rtsTrue))
-extern void PleaseStopAllocating(void);
-
/* -----------------------------------------------------------------------------
Performing Garbage Collection
/* ToDo: shouldn't recordMutable and recordOldToNewPtrs acquire some
* kind of lock in the SMP case?
*/
-static inline void
+INLINE_HEADER void
recordMutable(StgMutClosure *p)
{
bdescr *bd;
}
}
-static inline void
+INLINE_HEADER void
recordOldToNewPtrs(StgMutClosure *p)
{
bdescr *bd;
// We zero out the slop when PROFILING is on.
// #ifndef DEBUG
#if !defined(DEBUG) && !defined(PROFILING)
-#define updateWithIndirection(info, p1, p2) \
+#define updateWithIndirection(info, ind_info, p1, p2, and_then) \
{ \
bdescr *bd; \
\
bd = Bdescr((P_)p1); \
if (bd->gen_no == 0) { \
((StgInd *)p1)->indirectee = p2; \
- SET_INFO(p1,&stg_IND_info); \
+ SET_INFO(p1,ind_info); \
TICK_UPD_NEW_IND(); \
+ and_then; \
} else { \
((StgIndOldGen *)p1)->indirectee = p2; \
if (info != &stg_BLACKHOLE_BQ_info) { \
} \
SET_INFO(p1,&stg_IND_OLDGEN_info); \
TICK_UPD_OLD_IND(); \
+ and_then; \
} \
}
#elif defined(PROFILING)
// the invariants that every closure keeps its creation time in the profiling
// field. So, we call LDV_recordCreate().
-#define updateWithIndirection(info, p1, p2) \
+#define updateWithIndirection(info, ind_info, p1, p2, and_then) \
{ \
bdescr *bd; \
\
bd = Bdescr((P_)p1); \
if (bd->gen_no == 0) { \
((StgInd *)p1)->indirectee = p2; \
- SET_INFO(p1,&stg_IND_info); \
+ SET_INFO(p1,ind_info); \
LDV_recordCreate((p1)); \
TICK_UPD_NEW_IND(); \
+ and_then; \
} else { \
((StgIndOldGen *)p1)->indirectee = p2; \
if (info != &stg_BLACKHOLE_BQ_info) { \
} \
SET_INFO(p1,&stg_IND_OLDGEN_info); \
LDV_recordCreate((p1)); \
+ and_then; \
} \
}
* already have been updated (the mutable list will get messed up
* otherwise).
*/
-#define updateWithIndirection(info, p1, p2) \
+#define updateWithIndirection(info, ind_info, p1, p2, and_then) \
{ \
bdescr *bd; \
\
bd = Bdescr((P_)p1); \
if (bd->gen_no == 0) { \
((StgInd *)p1)->indirectee = p2; \
- SET_INFO(p1,&stg_IND_info); \
+ SET_INFO(p1,ind_info); \
TICK_UPD_NEW_IND(); \
+ and_then; \
} else { \
if (info != &stg_BLACKHOLE_BQ_info) { \
{ \
((StgIndOldGen *)p1)->indirectee = p2; \
SET_INFO(p1,&stg_IND_OLDGEN_info); \
TICK_UPD_OLD_IND(); \
+ and_then; \
} \
}
#endif
}
#if defined(TICKY_TICKY) || defined(PROFILING)
-static inline void
+INLINE_HEADER void
updateWithPermIndirection(const StgInfoTable *info, StgClosure *p1, StgClosure *p2)
{
bdescr *bd;
Macros for calculating how big a closure will be (used during allocation)
-------------------------------------------------------------------------- */
-static __inline__ StgOffset PAP_sizeW ( nat n_args )
+INLINE_HEADER StgOffset PAP_sizeW ( nat n_args )
{ return sizeofW(StgPAP) + n_args; }
-static __inline__ StgOffset AP_STACK_sizeW ( nat size )
+INLINE_HEADER StgOffset AP_STACK_sizeW ( nat size )
{ return sizeofW(StgAP_STACK) + size; }
-static __inline__ StgOffset CONSTR_sizeW( nat p, nat np )
+INLINE_HEADER StgOffset CONSTR_sizeW( nat p, nat np )
{ return sizeofW(StgHeader) + p + np; }
-static __inline__ StgOffset THUNK_SELECTOR_sizeW ( void )
+INLINE_HEADER StgOffset THUNK_SELECTOR_sizeW ( void )
{ return sizeofW(StgHeader) + MIN_UPD_SIZE; }
-static __inline__ StgOffset BLACKHOLE_sizeW ( void )
+INLINE_HEADER StgOffset BLACKHOLE_sizeW ( void )
{ return sizeofW(StgHeader) + MIN_UPD_SIZE; }
/* --------------------------------------------------------------------------
Sizes of closures
------------------------------------------------------------------------*/
-static __inline__ StgOffset sizeW_fromITBL( const StgInfoTable* itbl )
+INLINE_HEADER StgOffset sizeW_fromITBL( const StgInfoTable* itbl )
{ return sizeofW(StgClosure)
+ sizeofW(StgPtr) * itbl->layout.payload.ptrs
+ sizeofW(StgWord) * itbl->layout.payload.nptrs; }
-static __inline__ StgOffset ap_stack_sizeW( StgAP_STACK* x )
+INLINE_HEADER StgOffset ap_stack_sizeW( StgAP_STACK* x )
{ return AP_STACK_sizeW(x->size); }
-static __inline__ StgOffset pap_sizeW( StgPAP* x )
+INLINE_HEADER StgOffset pap_sizeW( StgPAP* x )
{ return PAP_sizeW(x->n_args); }
-static __inline__ StgOffset arr_words_sizeW( StgArrWords* x )
+INLINE_HEADER StgOffset arr_words_sizeW( StgArrWords* x )
{ return sizeofW(StgArrWords) + x->words; }
-static __inline__ StgOffset mut_arr_ptrs_sizeW( StgMutArrPtrs* x )
+INLINE_HEADER StgOffset mut_arr_ptrs_sizeW( StgMutArrPtrs* x )
{ return sizeofW(StgMutArrPtrs) + x->ptrs; }
-static __inline__ StgWord tso_sizeW ( StgTSO *tso )
+INLINE_HEADER StgWord tso_sizeW ( StgTSO *tso )
{ return TSO_STRUCT_SIZEW + tso->stack_size; }
+INLINE_HEADER StgWord bco_sizeW ( StgBCO *bco )
+{ return bco->size; }
+
/* -----------------------------------------------------------------------------
Sizes of stack frames
-------------------------------------------------------------------------- */
-static inline StgWord stack_frame_sizeW( StgClosure *frame )
+INLINE_HEADER StgWord stack_frame_sizeW( StgClosure *frame )
{
StgRetInfoTable *info;
case RET_DYN:
{
StgRetDyn *dyn = (StgRetDyn *)frame;
- return sizeofW(StgRetDyn) + RET_DYN_SIZE +
+ return sizeofW(StgRetDyn) + RET_DYN_BITMAP_SIZE +
+ RET_DYN_NONPTR_REGS_SIZE +
GET_PTRS(dyn->liveness) + GET_NONPTRS(dyn->liveness);
}