X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fincludes%2FRegs.h;h=def36c327d2282ea3d786b3324633e0606561ddc;hb=ba41623270c1d541e74bd5182e1b4fcbe99809cc;hp=7333f2db84d1081196f8380e37f7ee7aa9397b68;hpb=03a9ff01812afc81eb5236fd3063cbec44cf469e;p=ghc-hetmet.git diff --git a/ghc/includes/Regs.h b/ghc/includes/Regs.h index 7333f2d..def36c3 100644 --- a/ghc/includes/Regs.h +++ b/ghc/includes/Regs.h @@ -24,15 +24,17 @@ #include "gmp.h" // Needs MP_INT definition -/* - * This is the table that holds shadow-locations for all the STG - * registers. The shadow locations are used when: - * - * 1) the particular register isn't mapped to a real machine - * register, probably because there's a shortage of real registers. - * 2) caller-saves registers are saved across a CCall +/* + * Spark pools: used to store pending sparks (SMP & PARALLEL_HASKELL only) + * This is a circular buffer. Invariants: + * - base <= hd < lim + * - base <= tl < lim + * - if hd==tl, then the pool is empty. + * - if hd == tl+1, then the pool is full. + * Adding to the pool is done by assigning to *tl++ (wrapping round as + * necessary). When adding to a full pool, we have the option of + * throwing away either the oldest (hd++) or the most recent (tl--) entry. */ - typedef struct StgSparkPool_ { StgClosure **base; StgClosure **lim; @@ -40,6 +42,12 @@ typedef struct StgSparkPool_ { StgClosure **tl; } StgSparkPool; +#define ASSERT_SPARK_POOL_INVARIANTS(p) \ + ASSERT((p)->base <= (p)->hd); \ + ASSERT((p)->hd < (p)->lim); \ + ASSERT((p)->base <= (p)->tl); \ + ASSERT((p)->tl < (p)->lim); + typedef struct { StgFunPtr stgGCEnter1; StgFunPtr stgGCFun; @@ -64,6 +72,14 @@ typedef union { StgTSOPtr t; } StgUnion; +/* + * This is the table that holds shadow-locations for all the STG + * registers. The shadow locations are used when: + * + * 1) the particular register isn't mapped to a real machine + * register, probably because there's a shortage of real registers. + * 2) caller-saves registers are saved across a CCall + */ typedef struct StgRegTable_ { StgUnion rR1; StgUnion rR2; @@ -98,11 +114,10 @@ typedef struct StgRegTable_ { MP_INT rmp_tmp2; MP_INT rmp_result1; MP_INT rmp_result2; + StgWord rRet; // holds the return code of the thread #if defined(SMP) || defined(PAR) StgSparkPool rSparks; /* per-task spark pool */ #endif - // If this flag is set, we are running Haskell code. Used to detect - // uses of 'foreign import unsafe' that should be 'safe'. } StgRegTable; #if IN_STG_CODE @@ -328,7 +343,7 @@ GLOBAL_REG_DECL(StgRegTable *,BaseReg,REG_Base) #ifdef SMP #error BaseReg must be in a register for SMP #endif -#define BaseReg (&((struct Capability_)MainCapability).r) +#define BaseReg (&((struct PartCapability_ *)MainCapability)->r) #endif #if defined(REG_Sp) && !defined(NO_GLOBAL_REG_DECLS)