X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fincludes%2FStgMacros.h;h=8aabf2ee55e204af960dd403fe09480f3016497e;hb=c0624c7661a229bfeed128ca96b07e2f4d5d677c;hp=6bd5887008e21e82ce8a9aecfdd1bd857f5ba497;hpb=db61851c5472bf565cd1da900b33d6e033fd743d;p=ghc-hetmet.git diff --git a/ghc/includes/StgMacros.h b/ghc/includes/StgMacros.h index 6bd5887..8aabf2e 100644 --- a/ghc/includes/StgMacros.h +++ b/ghc/includes/StgMacros.h @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: StgMacros.h,v 1.42 2001/11/22 14:25:11 simonmar Exp $ + * $Id: StgMacros.h,v 1.49 2002/10/12 23:19:54 wolfgang Exp $ * * (c) The GHC Team, 1998-1999 * @@ -148,7 +148,7 @@ static inline int IS_ARG_TAG( StgWord p ) { return p <= ARGTAG_MAX; } #define HP_STK_CHK(stk_headroom,hp_headroom,ret,r,layout,tag_assts) \ DO_GRAN_ALLOCATE(hp_headroom) \ - if (Sp - stk_headroom < SpLim || (Hp += hp_headroom) > HpLim) { \ + if ((Hp += hp_headroom) > HpLim || Sp - stk_headroom < SpLim) { \ HpAlloc = (hp_headroom); \ tag_assts \ (r) = (P_)ret; \ @@ -198,7 +198,7 @@ static inline int IS_ARG_TAG( StgWord p ) { return p <= ARGTAG_MAX; } #define HP_STK_CHK_NP(stk_headroom, hp_headroom, ptrs, tag_assts) \ DO_GRAN_ALLOCATE(hp_headroom) \ - if ((Sp - (stk_headroom)) < SpLim || (Hp += (hp_headroom)) > HpLim) { \ + if ((Hp += (hp_headroom)) > HpLim || (Sp - (stk_headroom)) < SpLim) { \ HpAlloc = (hp_headroom); \ tag_assts \ JMP_(stg_gc_enter_##ptrs); \ @@ -228,7 +228,7 @@ static inline int IS_ARG_TAG( StgWord p ) { return p <= ARGTAG_MAX; } GEN_HP_CHK_ALT(headroom,stg_gc_d1,tag_assts); #define HP_CHK_L1(headroom,tag_assts) \ - GEN_HP_CHK_ALT(headroom,stg_gc_d1,tag_assts); + GEN_HP_CHK_ALT(headroom,stg_gc_l1,tag_assts); #define HP_CHK_UT_ALT(headroom, ptrs, nptrs, r, ret, tag_assts) \ GEN_HP_CHK_ALT(headroom, stg_gc_ut_##ptrs##_##nptrs, \ @@ -410,8 +410,8 @@ EXTINFO_RTS(stg_gen_chk_info); TICK_UPD_BH_UPDATABLE(); \ { \ bdescr *bd = Bdescr(R1.p); \ - if (bd->back != (bdescr *)BaseReg) { \ - if (bd->gen->no >= 1 || bd->step->no >= 1) { \ + if (bd->u.back != (bdescr *)BaseReg) { \ + if (bd->gen_no >= 1 || bd->step->no >= 1) { \ LOCK_THUNK(info); \ } else { \ EXTFUN_RTS(stg_gc_enter_1_hponly); \ @@ -424,8 +424,8 @@ EXTINFO_RTS(stg_gen_chk_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) { \ + if (bd->u.back != (bdescr *)BaseReg) { \ + if (bd->gen_no >= 1 || bd->step->no >= 1) { \ LOCK_THUNK(info); \ } else { \ EXTFUN_RTS(stg_gc_enter_1_hponly); \ @@ -670,7 +670,7 @@ extern DLL_IMPORT_RTS const StgPolyInfoTable stg_seq_frame_info; StgSeqFrame *__frame; \ TICK_SEQF_PUSHED(); \ __frame = (StgSeqFrame *)(sp); \ - SET_HDR_(__frame,&stg_seq_frame_info,CCCS); \ + SET_HDR((StgClosure *)__frame,(StgInfoTable *)&stg_seq_frame_info,CCCS);\ __frame->link = Su; \ Su = (StgUpdateFrame *)__frame; \ } @@ -680,7 +680,7 @@ extern DLL_IMPORT_RTS const StgPolyInfoTable stg_seq_frame_info; -------------------------------------------------------------------------- */ #if defined(USE_SPLIT_MARKERS) -#if defined(cygwin32_TARGET_OS) || defined(mingw32_TARGET_OS) +#if defined(LEADING_UNDERSCORE) #define __STG_SPLIT_MARKER __asm__("\n___stg_split_marker:"); #else #define __STG_SPLIT_MARKER __asm__("\n__stg_split_marker:"); @@ -693,11 +693,20 @@ extern DLL_IMPORT_RTS const StgPolyInfoTable stg_seq_frame_info; Closure and Info Macros with casting. We don't want to mess around with casts in the generated C code, so - we use these casting versions of the closure/info tables macros. + we use this casting versions of the closure macro. + + This version of SET_HDR also includes CCS_ALLOC for profiling - the + reason we don't use two separate macros is that the cost centre + field is sometimes a non-simple expression and we want to share its + value between SET_HDR and CCS_ALLOC. -------------------------------------------------------------------------- */ -#define SET_HDR_(c,info,ccs) \ - SET_HDR((StgClosure *)(c),(StgInfoTable *)(info),ccs) +#define SET_HDR_(c,info,ccs,size) \ + { \ + CostCentreStack *tmp = (ccs); \ + SET_HDR((StgClosure *)(c),(StgInfoTable *)(info),tmp); \ + CCS_ALLOC(tmp,size); \ + } /* ----------------------------------------------------------------------------- Saving context for exit from the STG world, and loading up context @@ -765,6 +774,33 @@ LoadThreadState (void) /* ----------------------------------------------------------------------------- Module initialisation + + The module initialisation code looks like this, roughly: + + FN(__stginit_Foo) { + JMP_(__stginit_Foo_1_p) + } + + FN(__stginit_Foo_1_p) { + ... + } + + We have one version of the init code with a module version and the + 'way' attached to it. The version number helps to catch cases + where modules are not compiled in dependency order before being + linked: if a module has been compiled since any modules which depend on + it, then the latter modules will refer to a different version in their + init blocks and a link error will ensue. + + The 'way' suffix helps to catch cases where modules compiled in different + ways are linked together (eg. profiled and non-profiled). + + We provide a plain, unadorned, version of the module init code + which just jumps to the version with the label and way attached. The + reason for this is that when using foreign exports, the caller of + startupHaskell() must supply the name of the init function for the "top" + module in the program, and we don't want to require that this name + has the version and way info appended to it. -------------------------------------------------------------------------- */ #define PUSH_INIT_STACK(reg_function) \ @@ -773,9 +809,18 @@ LoadThreadState (void) #define POP_INIT_STACK() \ *(--Sp) -#define START_MOD_INIT(reg_mod_name) \ +#define MOD_INIT_WRAPPER(label,real_init) \ + + +#define START_MOD_INIT(plain_lbl, real_lbl) \ static int _module_registered = 0; \ - FN_(reg_mod_name) { \ + EF_(real_lbl); \ + FN_(plain_lbl) { \ + FB_ \ + JMP_(real_lbl); \ + FE_ \ + } \ + FN_(real_lbl) { \ FB_; \ if (! _module_registered) { \ _module_registered = 1; \ @@ -801,20 +846,20 @@ LoadThreadState (void) * Suspending/resuming threads for doing external C-calls (_ccall_GC). * These functions are defined in rts/Schedule.c. */ -StgInt suspendThread ( StgRegTable * ); -StgRegTable * resumeThread ( StgInt ); +StgInt suspendThread ( StgRegTable *, rtsBool); +StgRegTable * resumeThread ( StgInt, rtsBool ); -#define SUSPEND_THREAD(token) \ +#define SUSPEND_THREAD(token,threaded) \ SaveThreadState(); \ - token = suspendThread(BaseReg); + token = suspendThread(BaseReg,threaded); #ifdef SMP -#define RESUME_THREAD(token) \ - BaseReg = resumeThread(token); \ +#define RESUME_THREAD(token,threaded) \ + BaseReg = resumeThread(token,threaded); \ LoadThreadState(); #else -#define RESUME_THREAD(token) \ - (void)resumeThread(token); \ +#define RESUME_THREAD(token,threaded) \ + (void)resumeThread(token,threaded); \ LoadThreadState(); #endif