X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fincludes%2FStgMacros.h;h=9cfc6c69b29765893e65413d963c1b5f298bb253;hb=e77996aa35993a6c54a5b2e9dee813f223912bbf;hp=4c7be2bdca2f8a421c7ce0dc6f85b678a650c5d1;hpb=eb407ca1d21a43ff86ad731868f71e994afafe78;p=ghc-hetmet.git diff --git a/ghc/includes/StgMacros.h b/ghc/includes/StgMacros.h index 4c7be2b..9cfc6c6 100644 --- a/ghc/includes/StgMacros.h +++ b/ghc/includes/StgMacros.h @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: StgMacros.h,v 1.10 1999/05/11 16:47:41 keithw Exp $ + * $Id: StgMacros.h,v 1.18 1999/11/09 15:57:40 simonmar Exp $ * * (c) The GHC Team, 1998-1999 * @@ -52,9 +52,9 @@ #define ED_RO_ extern const #define ID_ extern #define ID_RO_ extern const -#define EI_ extern const StgInfoTable -#define EDI_ extern DLLIMPORT const StgInfoTable -#define II_ extern const StgInfoTable +#define EI_ extern INFO_TBL_CONST StgInfoTable +#define EDI_ extern DLLIMPORT INFO_TBL_CONST StgInfoTable +#define II_ extern INFO_TBL_CONST StgInfoTable #define EC_ extern StgClosure #define EDC_ extern DLLIMPORT StgClosure #define IC_ extern StgClosure @@ -179,8 +179,7 @@ static inline int IS_ARG_TAG( StgWord p ) { return p <= ARGTAG_MAX; } tag_assts \ (r) = (P_)ret; \ JMP_(stg_chk_##layout); \ - } \ - TICK_ALLOC_HEAP(headroom); + } #define HP_STK_CHK(stk_headroom,hp_headroom,ret,r,layout,tag_assts) \ if (Sp - stk_headroom < SpLim || (Hp += hp_headroom) > HpLim) { \ @@ -188,8 +187,7 @@ static inline int IS_ARG_TAG( StgWord p ) { return p <= ARGTAG_MAX; } tag_assts \ (r) = (P_)ret; \ JMP_(stg_chk_##layout); \ - } \ - TICK_ALLOC_HEAP(hp_headroom); + } /* ----------------------------------------------------------------------------- A Heap Check in a case alternative are much simpler: everything is @@ -218,24 +216,22 @@ static inline int IS_ARG_TAG( StgWord p ) { return p <= ARGTAG_MAX; } EXTFUN_RTS(stg_gc_enter_##ptrs); \ tag_assts \ JMP_(stg_gc_enter_##ptrs); \ - } \ - TICK_ALLOC_HEAP(headroom); + } #define HP_CHK_SEQ_NP(headroom,ptrs,tag_assts) \ if ((Hp += (headroom)) > HpLim) { \ EXTFUN_RTS(stg_gc_seq_##ptrs); \ tag_assts \ JMP_(stg_gc_seq_##ptrs); \ - } \ - TICK_ALLOC_HEAP(headroom); + } #define HP_STK_CHK_NP(stk_headroom, hp_headroom, ptrs, tag_assts) \ if ((Sp - (stk_headroom)) < SpLim || (Hp += (hp_headroom)) > HpLim) { \ EXTFUN_RTS(stg_gc_enter_##ptrs); \ tag_assts \ JMP_(stg_gc_enter_##ptrs); \ - } \ - TICK_ALLOC_HEAP(hp_headroom); + } + /* Heap checks for branches of a primitive case / unboxed tuple return */ @@ -244,8 +240,7 @@ static inline int IS_ARG_TAG( StgWord p ) { return p <= ARGTAG_MAX; } EXTFUN_RTS(lbl); \ tag_assts \ JMP_(lbl); \ - } \ - TICK_ALLOC_HEAP(headroom); + } #define HP_CHK_NOREGS(headroom,tag_assts) \ GEN_HP_CHK_ALT(headroom,stg_gc_noregs,tag_assts); @@ -321,6 +316,7 @@ static inline int IS_ARG_TAG( StgWord p ) { return p <= ARGTAG_MAX; } #define R6_PTR 1<<5 #define R7_PTR 1<<6 #define R8_PTR 1<<7 + #define HP_CHK_GEN(headroom,liveness,reentry,tag_assts) \ if ((Hp += (headroom)) > HpLim ) { \ EF_(stg_gen_chk); \ @@ -328,8 +324,11 @@ static inline int IS_ARG_TAG( StgWord p ) { return p <= ARGTAG_MAX; } R9.w = (W_)LIVENESS_MASK(liveness); \ R10.w = (W_)reentry; \ JMP_(stg_gen_chk); \ - } \ - TICK_ALLOC_HEAP(headroom); + } + +#define HP_CHK_GEN_TICKY(headroom,liveness,reentry,tag_assts) \ + HP_CHK_GEN(headroom,liveness,reentry,tag_assts); \ + TICK_ALLOC_HEAP_NOCTR(headroom) #define STK_CHK_GEN(headroom,liveness,reentry,tag_assts) \ if ((Sp - (headroom)) < SpLim) { \ @@ -403,31 +402,66 @@ EDI_(stg_gen_chk_info); The extra subtraction of one word is because tags start at zero. -------------------------------------------------------------------------- */ -#ifdef USE_MINIINTERPRETER -#define RET_VEC(p,t) ((*(stgCast(StgInfoTable*,p)->vector))[t]) -#else +#ifdef TABLES_NEXT_TO_CODE #define RET_VEC(p,t) (*((P_)(p) - sizeofW(StgInfoTable) - t - 1)) +#else +#define RET_VEC(p,t) (((StgInfoTable *)p)->vector[t]) #endif /* ----------------------------------------------------------------------------- Misc -------------------------------------------------------------------------- */ + /* set the tag register (if we have one) */ #define SET_TAG(t) /* nothing */ #ifdef EAGER_BLACKHOLING -# define UPD_BH_UPDATABLE(thunk) \ - TICK_UPD_BH_UPDATABLE(); \ - SET_INFO((StgClosure *)thunk,&BLACKHOLE_info) -# define UPD_BH_SINGLE_ENTRY(thunk) \ - TICK_UPD_BH_SINGLE_ENTRY(); \ - SET_INFO((StgClosure *)thunk,&SE_BLACKHOLE_info) +# ifdef SMP +# define UPD_BH_UPDATABLE(info) \ + TICK_UPD_BH_UPDATABLE(); \ + { \ + bdescr *bd = Bdescr(R1.p); \ + if (bd->back != (bdescr *)BaseReg) { \ + if (bd->gen->no >= 1 || bd->step->no >= 1) { \ + LOCK_THUNK(info); \ + } else { \ + EXTFUN_RTS(stg_gc_enter_1_hponly); \ + JMP_(stg_gc_enter_1_hponly); \ + } \ + } \ + } \ + SET_INFO(R1.cl,&BLACKHOLE_info) +# define UPD_BH_SINGLE_ENTRY(info) \ + TICK_UPD_BH_SINGLE_ENTRY(); \ + { \ + bdescr *bd = Bdescr(R1.p); \ + if (bd->back != (bdescr *)BaseReg) { \ + if (bd->gen->no >= 1 || bd->step->no >= 1) { \ + LOCK_THUNK(info); \ + } else { \ + EXTFUN_RTS(stg_gc_enter_1_hponly); \ + JMP_(stg_gc_enter_1_hponly); \ + } \ + } \ + } \ + SET_INFO(R1.cl,&BLACKHOLE_info) +# else +# define UPD_BH_UPDATABLE(info) \ + TICK_UPD_BH_UPDATABLE(); \ + SET_INFO(R1.cl,&BLACKHOLE_info) +# define UPD_BH_SINGLE_ENTRY(info) \ + TICK_UPD_BH_SINGLE_ENTRY(); \ + SET_INFO(R1.cl,&SE_BLACKHOLE_info) +# endif #else /* !EAGER_BLACKHOLING */ # define UPD_BH_UPDATABLE(thunk) /* nothing */ # define UPD_BH_SINGLE_ENTRY(thunk) /* nothing */ #endif /* EAGER_BLACKHOLING */ +#define UPD_FRAME_UPDATEE(p) (((StgUpdateFrame *)(p))->updatee) +#define UPDATE_SU_FROM_UPD_FRAME(p) (Su=((StgUpdateFrame *)(p))->link) + /* ----------------------------------------------------------------------------- Moving Floats and Doubles @@ -640,10 +674,15 @@ extern DLL_IMPORT_DATA const StgPolyInfoTable seq_frame_info; We save all the STG registers (that is, the ones that are mapped to machine registers) in their places in the TSO. - The stack registers go into the current stack object, and the heap - registers are saved in global locations. + The stack registers go into the current stack object, and the + current nursery is updated from the heap pointer. + + These functions assume that BaseReg is loaded appropriately (if + we have one). -------------------------------------------------------------------------- */ +#if IN_STG_CODE + static __inline__ void SaveThreadState(void) { @@ -654,6 +693,12 @@ SaveThreadState(void) CurrentTSO->splim = SpLim; CloseNursery(Hp); +#ifdef REG_CurrentTSO + SAVE_CurrentTSO = CurrentTSO; +#endif +#ifdef REG_CurrentNursery + SAVE_CurrentNursery = CurrentNursery; +#endif #if defined(PROFILING) CurrentTSO->prof.CCCS = CCCS; #endif @@ -662,19 +707,48 @@ SaveThreadState(void) static __inline__ void LoadThreadState (void) { -#ifdef REG_Base - BaseReg = (StgRegTable*)&MainRegTable; -#endif - Sp = CurrentTSO->sp; Su = CurrentTSO->su; SpLim = CurrentTSO->splim; OpenNursery(Hp,HpLim); +#ifdef REG_CurrentTSO + CurrentTSO = SAVE_CurrentTSO; +#endif +#ifdef REG_CurrentNursery + CurrentNursery = SAVE_CurrentNursery; +#endif # if defined(PROFILING) CCCS = CurrentTSO->prof.CCCS; # endif } +#endif + +/* ----------------------------------------------------------------------------- + Support for _ccall_GC_ and _casm_GC. + -------------------------------------------------------------------------- */ + +/* + * Suspending/resuming threads for doing external C-calls (_ccall_GC). + * These functions are defined in rts/Schedule.c. + */ +StgInt suspendThread ( StgRegTable *cap ); +StgRegTable * resumeThread ( StgInt ); + +#define SUSPEND_THREAD(token) \ + SaveThreadState(); \ + token = suspendThread(BaseReg); + +#ifdef SMP +#define RESUME_THREAD(token) \ + BaseReg = resumeThread(token); \ + LoadThreadState(); +#else +#define RESUME_THREAD(token) \ + (void)resumeThread(token); \ + LoadThreadState(); +#endif + #endif /* STGMACROS_H */