[project @ 2005-10-26 10:42:54 by simonmar]
[ghc-hetmet.git] / ghc / includes / Regs.h
index 0203238..f1b8597 100644 (file)
@@ -22,6 +22,7 @@
 #ifndef REGS_H
 #define REGS_H
 
+#include "gmp.h" // Needs MP_INT definition 
 
 /* 
  * This is the table that holds shadow-locations for all the STG
@@ -87,41 +88,22 @@ typedef struct StgRegTable_ {
   StgPtr         rHpLim;
   struct StgTSO_ *rCurrentTSO;
   struct step_   *rNursery;
-  struct bdescr_ *rCurrentNursery;
+  struct bdescr_ *rCurrentNursery; /* Hp/HpLim point into this block */
+  struct bdescr_ *rCurrentAlloc;   /* for allocation using allocate() */
   StgWord         rHpAlloc;    /* number of *bytes* being allocated in heap */
+  // rmp_tmp1..rmp_result2 are only used in SMP builds to avoid per-thread temps
+  // in bss, but currently always incldue here so we just run mkDerivedConstants once
+  StgInt          rmp_tmp_w;
+  MP_INT          rmp_tmp1;      
+  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 */
+  StgSparkPool    rSparks;     /* per-task spark pool */
 #endif
-  StgWord        rInHaskell;    /* non-zero if we're in Haskell code */
-    // If this flag is set, we are running Haskell code.  Used to detect
-    // uses of 'foreign import unsafe' that should be 'safe'.
 } 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 Capability_ *link;    /* per-task register tables are linked together */
-#endif
-} Capability;
-
-/* No such thing as a MainCapability under SMP - each thread must have
- * its own Capability.
- */
-#ifndef SMP
-#if IN_STG_CODE
-extern W_ MainCapability[];
-#else
-extern DLL_IMPORT_RTS Capability  MainCapability;
-#endif
-#endif
-
 #if IN_STG_CODE
 
 /*
@@ -320,13 +302,32 @@ GLOBAL_REG_DECL(StgWord64,L1,REG_L1)
  * concurrent Haskell, MainRegTable otherwise).
  */
 
+/* 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).
+ * This is a cut-down version of the Capability structure; the full
+ * version is defined in Capability.h.
+ */
+struct PartCapability_ {
+    StgFunTable f;
+    StgRegTable r;
+};
+
+/* No such thing as a MainCapability under SMP - each thread must have
+ * its own Capability.
+ */
+#if IN_STG_CODE && !defined(SMP)
+extern W_ MainCapability[];
+#endif
+
 #if defined(REG_Base) && !defined(NO_GLOBAL_REG_DECLS)
 GLOBAL_REG_DECL(StgRegTable *,BaseReg,REG_Base)
 #else
 #ifdef SMP
 #error BaseReg must be in a register for SMP
 #endif
-#define BaseReg (&((Capability *)MainCapability)[0].r)
+#define BaseReg (&((struct PartCapability_ *)MainCapability)->r)
 #endif
 
 #if defined(REG_Sp) && !defined(NO_GLOBAL_REG_DECLS)