X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fincludes%2FRegs.h;h=1cbca51ffdb673b067b05c4515db1dd435b44b83;hb=ba2843abdfe6f055777e4e66e8add769fce31d29;hp=579382b31f7aa90383a8f2e2b5a2673fe20d76e9;hpb=b933b46923f9e67fbb20a62b9ccde5a9a3e8fb7e;p=ghc-hetmet.git diff --git a/ghc/includes/Regs.h b/ghc/includes/Regs.h index 579382b..1cbca51 100644 --- a/ghc/includes/Regs.h +++ b/ghc/includes/Regs.h @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: Regs.h,v 1.8 2000/01/12 15:15:17 simonmar Exp $ + * $Id: Regs.h,v 1.12 2002/12/11 15:36:37 simonmar Exp $ * * (c) The GHC Team, 1998-1999 * @@ -32,6 +32,11 @@ typedef struct StgSparkPool_ { StgClosure **tl; } StgSparkPool; +typedef struct { + StgFunPtr stgGCEnter1; + StgFunPtr stgGCFun; +} StgFunTable; + typedef struct StgRegTable_ { StgUnion rR1; StgUnion rR2; @@ -41,8 +46,8 @@ typedef struct StgRegTable_ { StgUnion rR6; StgUnion rR7; StgUnion rR8; - StgUnion rR9; /* used occasionally by heap/stack checks */ - StgUnion rR10; /* used occasionally by heap/stack checks */ + StgUnion rR9; // used occasionally by heap/stack checks + StgUnion rR10; // used occasionally by heap/stack checks StgFloat rF1; StgFloat rF2; StgFloat rF3; @@ -51,26 +56,37 @@ typedef struct StgRegTable_ { StgDouble rD2; StgWord64 rL1; StgPtr rSp; - StgUpdateFrame *rSu; StgPtr rSpLim; StgPtr rHp; StgPtr rHpLim; StgTSO *rCurrentTSO; struct _bdescr *rNursery; struct _bdescr *rCurrentNursery; + StgWord rHpAlloc; // number of words being allocated in heap #if defined(SMP) || defined(PAR) - StgSparkPool rSparks; /* per-task spark pool */ + StgSparkPool rSparks; // per-task spark pool #endif +} StgRegTable; + + +/* A capability is a combination of a FunTable and a RegTable. In STG + * code, BaseReg normally points to the RegTable portion of this + * structure, so that we can index both forwards and backwards to take + * advantage of shorter instruction forms on some archs (eg. x86). + */ +typedef struct Capability_ { + StgFunTable f; + StgRegTable r; #if defined(SMP) - struct StgRegTable_ *link; /* per-task register tables are linked together */ + struct Capability_ *link; /* per-task register tables are linked together */ #endif -} StgRegTable; +} Capability; /* No such thing as a MainRegTable under SMP - each thread must * have its own MainRegTable. */ #ifndef SMP -extern DLL_IMPORT_RTS StgRegTable MainRegTable; +extern DLL_IMPORT_RTS Capability MainCapability; #endif #if IN_STG_CODE @@ -79,7 +95,7 @@ extern DLL_IMPORT_RTS StgRegTable MainRegTable; * Registers Hp and HpLim are global across the entire system, and are * copied into the RegTable before executing a thread. * - * Registers Sp, Su, and SpLim are saved in the TSO for the + * Registers Sp and SpLim are saved in the TSO for the * thread, but are copied into the RegTable before executing a thread. * * All other registers are "general purpose", and are used for passing @@ -105,7 +121,6 @@ extern DLL_IMPORT_RTS StgRegTable MainRegTable; */ #define SAVE_Sp (CurrentTSO->sp) -#define SAVE_Su (CurrentTSO->su) #define SAVE_SpLim (CurrentTSO->splim) #define SAVE_Hp (BaseReg->rHp) @@ -113,6 +128,7 @@ extern DLL_IMPORT_RTS StgRegTable MainRegTable; #define SAVE_CurrentTSO (BaseReg->rCurrentTSO) #define SAVE_CurrentNursery (BaseReg->rCurrentNursery) +#define SAVE_HpAlloc (BaseReg->rHpAlloc) #if defined(SMP) || defined(PAR) #define SAVE_SparkHd (BaseReg->rSparks.hd) #define SAVE_SparkTl (BaseReg->rSparks.tl) @@ -275,7 +291,7 @@ GLOBAL_REG_DECL(StgRegTable *,BaseReg,REG_Base) #ifdef SMP #error BaseReg must be in a register for SMP #endif -#define BaseReg (&MainRegTable) +#define BaseReg (&MainCapability.r) #endif #ifdef REG_Sp @@ -284,12 +300,6 @@ GLOBAL_REG_DECL(P_,Sp,REG_Sp) #define Sp (BaseReg->rSp) #endif -#ifdef REG_Su -GLOBAL_REG_DECL(StgUpdateFrame *,Su,REG_Su) -#else -#define Su (BaseReg->rSu) -#endif - #ifdef REG_SpLim GLOBAL_REG_DECL(P_,SpLim,REG_SpLim) #else @@ -320,6 +330,12 @@ GLOBAL_REG_DECL(bdescr *,CurrentNursery,REG_CurrentNursery) #define CurrentNursery (BaseReg->rCurrentNursery) #endif +#ifdef REG_HpAlloc +GLOBAL_REG_DECL(bdescr *,HpAlloc,REG_HpAlloc) +#else +#define HpAlloc (BaseReg->rHpAlloc) +#endif + #ifdef REG_SparkHd GLOBAL_REG_DECL(bdescr *,SparkHd,REG_SparkHd) #else @@ -345,6 +361,37 @@ GLOBAL_REG_DECL(bdescr *,SparkLim,REG_SparkLim) #endif /* ----------------------------------------------------------------------------- + Get absolute function pointers from the register table, to save + code space. On x86, + + jmp *-12(%ebx) + + is shorter than + + jmp absolute_address + + as long as the offset is within the range of a signed byte + (-128..+127). So we pick some common absolute_addresses and put + them in the register table. As a bonus, linking time should also + be reduced. + + Other possible candidates in order of importance: + + stg_upd_frame_info + stg_CAF_BLACKHOLE_info + stg_IND_STATIC_info + + anything else probably isn't worth the effort. + + -------------------------------------------------------------------------- */ + + +#define FunReg ((StgFunTable *)((void *)BaseReg - sizeof(StgFunTable))) + +#define stg_gc_enter_1 (FunReg->stgGCEnter1) +#define stg_gc_fun (FunReg->stgGCFun) + +/* ----------------------------------------------------------------------------- For any registers which are denoted "caller-saves" by the C calling convention, we have to emit code to save and restore them across C calls. @@ -494,14 +541,6 @@ GLOBAL_REG_DECL(bdescr *,SparkLim,REG_SparkLim) #define CALLER_RESTORE_Sp /* nothing */ #endif -#ifdef CALLER_SAVES_Su -#define CALLER_SAVE_Su SAVE_Su = Su; -#define CALLER_RESTORE_Su Su = SAVE_Su; -#else -#define CALLER_SAVE_Su /* nothing */ -#define CALLER_RESTORE_Su /* nothing */ -#endif - #ifdef CALLER_SAVES_SpLim #define CALLER_SAVE_SpLim SAVE_SpLim = SpLim; #define CALLER_RESTORE_SpLim SpLim = SAVE_SpLim; @@ -553,6 +592,14 @@ GLOBAL_REG_DECL(bdescr *,SparkLim,REG_SparkLim) #define CALLER_RESTORE_CurrentNursery /* nothing */ #endif +#ifdef CALLER_SAVES_HpAlloc +#define CALLER_SAVE_HpAlloc SAVE_HpAlloc = HpAlloc; +#define CALLER_RESTORE_HpAlloc HpAlloc = SAVE_HpAlloc; +#else +#define CALLER_SAVE_HpAlloc /* nothing */ +#define CALLER_RESTORE_HpAlloc /* nothing */ +#endif + #ifdef CALLER_SAVES_SparkHd #define CALLER_SAVE_SparkHd SAVE_SparkHd = SparkHd; #define CALLER_RESTORE_SparkHd SparkHd = SAVE_SparkHd; @@ -610,9 +657,10 @@ GLOBAL_REG_DECL(bdescr *,SparkLim,REG_SparkLim) CALLER_SAVE_D2 \ CALLER_SAVE_L1 + /* Save Base last, since the others may + be addressed relative to it */ #define CALLER_SAVE_SYSTEM \ CALLER_SAVE_Sp \ - CALLER_SAVE_Su \ CALLER_SAVE_SpLim \ CALLER_SAVE_Hp \ CALLER_SAVE_HpLim \ @@ -621,7 +669,8 @@ GLOBAL_REG_DECL(bdescr *,SparkLim,REG_SparkLim) CALLER_SAVE_SparkHd \ CALLER_SAVE_SparkTl \ CALLER_SAVE_SparkBase \ - CALLER_SAVE_SparkLim + CALLER_SAVE_SparkLim \ + CALLER_SAVE_Base #define CALLER_RESTORE_USER \ CALLER_RESTORE_R1 \ @@ -640,10 +689,11 @@ GLOBAL_REG_DECL(bdescr *,SparkLim,REG_SparkLim) CALLER_RESTORE_D2 \ CALLER_RESTORE_L1 + /* Restore Base first, since the others may + be addressed relative to it */ #define CALLER_RESTORE_SYSTEM \ CALLER_RESTORE_Base \ CALLER_RESTORE_Sp \ - CALLER_RESTORE_Su \ CALLER_RESTORE_SpLim \ CALLER_RESTORE_Hp \ CALLER_RESTORE_HpLim \