[project @ 2003-12-28 13:02:46 by panne]
[ghc-hetmet.git] / ghc / rts / Storage.h
index 12f9982..fb84740 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: Storage.h,v 1.50 2003/03/26 17:40:57 sof Exp $
+ * $Id: Storage.h,v 1.53 2003/11/12 17:49:11 sof Exp $
  *
  * (c) The GHC Team, 1998-2002
  *
@@ -63,7 +63,7 @@ extern StgPtr  allocate        ( nat n );
 extern StgPtr  allocatePinned  ( nat n );
 extern lnat    allocated_bytes ( void );
 
-static inline rtsBool
+INLINE_HEADER rtsBool
 doYouWantToGC( void )
 {
   return (alloc_blocks >= alloc_blocks_lim);
@@ -129,7 +129,7 @@ extern Mutex sm_mutex;
 /* 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;
@@ -147,7 +147,7 @@ recordMutable(StgMutClosure *p)
   }
 }
 
-static inline void
+INLINE_HEADER void
 recordOldToNewPtrs(StgMutClosure *p)
 {
   bdescr *bd;
@@ -163,15 +163,16 @@ recordOldToNewPtrs(StgMutClosure *p)
 // 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) {                            \
@@ -182,6 +183,7 @@ recordOldToNewPtrs(StgMutClosure *p)
       }                                                                        \
       SET_INFO(p1,&stg_IND_OLDGEN_info);                               \
       TICK_UPD_OLD_IND();                                              \
+      and_then;                                                                \
     }                                                                  \
   }
 #elif defined(PROFILING)
@@ -195,7 +197,7 @@ recordOldToNewPtrs(StgMutClosure *p)
 //   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;                                                                \
                                                                        \
@@ -203,9 +205,10 @@ recordOldToNewPtrs(StgMutClosure *p)
     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) {                            \
@@ -216,6 +219,7 @@ recordOldToNewPtrs(StgMutClosure *p)
       }                                                                        \
       SET_INFO(p1,&stg_IND_OLDGEN_info);                               \
       LDV_recordCreate((p1));                                           \
+      and_then;                                                                \
     }                                                                  \
   }
 
@@ -229,7 +233,7 @@ recordOldToNewPtrs(StgMutClosure *p)
  * 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;                                                                \
                                                                        \
@@ -237,8 +241,9 @@ recordOldToNewPtrs(StgMutClosure *p)
     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) {                            \
        {                                                               \
@@ -259,6 +264,7 @@ recordOldToNewPtrs(StgMutClosure *p)
       ((StgIndOldGen *)p1)->indirectee = p2;                           \
       SET_INFO(p1,&stg_IND_OLDGEN_info);                               \
       TICK_UPD_OLD_IND();                                              \
+      and_then;                                                                \
     }                                                                  \
   }
 #endif
@@ -281,7 +287,7 @@ recordOldToNewPtrs(StgMutClosure *p)
   }
 
 #if defined(TICKY_TICKY) || defined(PROFILING)
-static inline void
+INLINE_HEADER void
 updateWithPermIndirection(const StgInfoTable *info, StgClosure *p1, StgClosure *p2) 
 {
   bdescr *bd;
@@ -357,53 +363,53 @@ void revertCAFs( void );
    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; }
 
-static __inline__ StgWord bco_sizeW ( StgBCO *bco )
+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;
 
@@ -413,7 +419,8 @@ static inline StgWord stack_frame_sizeW( StgClosure *frame )
     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);
     }