[project @ 2000-07-11 19:17:20 by panne]
[ghc-hetmet.git] / ghc / interpreter / storage.h
index 8fc200f..0cbf7df 100644 (file)
@@ -10,8 +10,8 @@
  * included in the distribution.
  *
  * $RCSfile: storage.h,v $
- * $Revision: 1.40 $
- * $Date: 2000/04/05 16:57:18 $
+ * $Revision: 1.45 $
+ * $Date: 2000/04/27 16:35:29 $
  * ------------------------------------------------------------------------*/
 
 #define DEBUG_STORAGE               /* a moderate level of sanity checking */
@@ -60,7 +60,7 @@ typedef Cell         ConVarId;
  * -heapSize .. -1                                    cells in the heap
  * 0                                                  NIL
  *
- * TAG_NONPTR_MIN(100) .. TAG_NONPTR_MAX(115)         non pointer tags
+ * TAG_NONPTR_MIN(100) .. TAG_NONPTR_MAX(116)         non pointer tags
  * TAG_PTR_MIN(200)    .. TAG_PTR_MAX(298)            pointer tags
  * TAG_SPEC_MIN(400)   .. TAG_SPEC_MAX(431)           special tags
  * OFF_MIN(1,000)      .. OFF_MAX(1,999)              offsets
@@ -196,7 +196,7 @@ extern  Cell         whatIs    ( Cell );
  * ------------------------------------------------------------------------*/
 
 #define TAG_NONPTR_MIN 100
-#define TAG_NONPTR_MAX 115
+#define TAG_NONPTR_MAX 116
 
 #define FREECELL     100          /* Free list cell:          snd :: Cell  */
 #define VARIDCELL    101          /* Identifier variable:     snd :: Text  */
@@ -209,16 +209,17 @@ extern  Cell         whatIs    ( Cell );
 #define ADDPAT       108          /* (_+k) pattern discr:     snd :: Int   */
 #define FLOATCELL    109          /* Floating Pt literal:     snd :: Text  */
 #define BIGCELL      110          /* Integer literal:         snd :: Text  */
-#define PTRCELL      111          /* C Heap Pointer           snd :: Ptr   */
-#define CPTRCELL     112          /* Native code pointer      snd :: Ptr   */
+#define ADDRCELL     111          /* Address literal          snd :: Ptr   */
+#define MPTRCELL     112          /* C (malloc) Heap Pointer  snd :: Ptr   */
+#define CPTRCELL     113          /* Closure pointer          snd :: Ptr   */
 
 #if IPARAM
-#define IPCELL       113                 /* Imp Param Cell:          snd :: Text  */
-#define IPVAR       114          /* ?x:                      snd :: Text  */
+#define IPCELL       114                 /* Imp Param Cell:          snd :: Text  */
+#define IPVAR       115          /* ?x:                      snd :: Text  */
 #endif
 
 #if TREX
-#define EXTCOPY      115          /* Copy of an Ext:          snd :: Text  */
+#define EXTCOPY      116          /* Copy of an Ext:          snd :: Text  */
 #endif
 
 #define qmodOf(c)       (textOf(fst(snd(c))))    /* c ::  QUALIDENT        */
@@ -266,19 +267,22 @@ extern  Text            textOf       ( Cell );
 #define stringToBignum(s) pair(BIGCELL,findText(s))
 #define bignumToString(b) textToStr(snd(b))
 
-#define isPtr(c)        (isPair(c) && fst(c)==PTRCELL)
-extern  Cell            mkPtr           ( Ptr );
-extern  Ptr             ptrOf           ( Cell );
+#define isMPtr(c)       (isPair(c) && fst(c)==MPTRCELL)
+extern  Cell            mkMPtr          ( Ptr );
+extern  Ptr             mptrOf          ( Cell );
 #define isCPtr(c)       (isPair(c) && fst(c)==CPTRCELL)
 extern  Cell            mkCPtr          ( Ptr );
 extern  Ptr             cptrOf          ( Cell );
+#define isAddr(c)       (isPair(c) && fst(c)==ADDRCELL)
+extern  Cell            mkAddr          ( Ptr );
+extern  Ptr             addrOf          ( Cell );
 
 /* --------------------------------------------------------------------------
  * Tags for pointer cells.
  * ------------------------------------------------------------------------*/
 
 #define TAG_PTR_MIN 200
-#define TAG_PTR_MAX 298
+#define TAG_PTR_MAX 299
 
 #define LETREC       200          /* LETREC     snd :: ([Decl],Exp)        */
 #define COND         201          /* COND       snd :: (Exp,Exp,Exp)       */
@@ -444,6 +448,7 @@ extern  Ptr             cptrOf          ( Cell );
 #define ZTUP4        297          /* snd :: (Cell,(Cell,(Cell,Cell)))      */
 #define ZTUP5        298       /* snd :: (Cell,(Cell,(Cell,(Cell,Cell))))  */
 
+#define MDOCOMP      299          /* MDOCOMP     snd :: (Exp,[Qual])       */
 
 
 /* --------------------------------------------------------------------------
@@ -593,6 +598,9 @@ struct strModule {
 
    List   qualImports; /* Qualified imports.                               */
 
+   List   codeList;    /* [ Name | StgTree ] before code generation,
+                          [ Name | CPtr ] afterwards                       */
+
    Bool   fake;        /* TRUE if module exists only via GHC primop        */
                        /* defn; usually FALSE                              */
 
@@ -619,7 +627,7 @@ extern Module currentModule;           /* Module currently being processed */
 extern List   moduleGraph;             /* :: [GRP_REC | GRP_NONREC]        */
 extern List   prelModules;             /* :: [CONID]                       */
 extern List   targetModules;           /* :: [CONID]                       */
-
+extern Bool   nukeModule_needs_major_gc; /* see comment in compiler.c      */
 
 extern Bool         isValidModule   ( Module );
 extern Module       newModule       ( Text );
@@ -627,6 +635,12 @@ extern Void         nukeModule      ( Module );
 extern Module       findModule      ( Text );
 extern Module       findModid       ( Cell );
 extern Void         setCurrModule   ( Module );
+extern void         addToCodeList   ( Module, Cell );
+extern void         setNameOrTupleClosure ( Cell c, Cell closure );
+extern Cell         getNameOrTupleClosure ( Cell c );
+extern void         setNameOrTupleClosureCPtr ( Cell c, 
+                                                void* /* StgClosure* */ cptr );
+
 
 extern void         addOTabName     ( Module,char*,void* );
 extern void*        lookupOTabName  ( Module,char* );
@@ -634,7 +648,8 @@ extern char*        nameFromOPtr    ( void* );
 
 extern void         addSection      ( Module,void*,void*,OSectionKind );
 extern OSectionKind lookupSection   ( void* );
-extern void*    lookupOExtraTabName ( char* sym );
+extern void*    lookupOExtraTabName                ( char* sym );
+extern void*    lookupOTabNameAbsolutelyEverywhere ( char* sym );
 
 #define isPrelude(m) (m==modulePrelude)
 
@@ -682,17 +697,22 @@ struct strTycon {
     Name   conToTag;                    /* used in derived code            */
     Name   tagToCon;
     void*  itbl;                       /* For tuples, the info tbl pointer */
+    Cell   closure;       /* Either StgTree, or (later) CPtr, which is the
+                             address in the evaluator's heap.  Only Tuples
+                             use the closure field; all other tycons which
+                             require actual code have associated name table 
+                                                                 entries.  */
     Tycon  nextTyconHash;
 };
 
 extern struct strTycon* tabTycon;
 extern Int              tabTyconSz;
 
-extern Tycon newTycon     ( Text );
-extern Tycon findTycon    ( Text );
-extern Tycon addTycon     ( Tycon );
+extern Tycon newTycon      ( Text );
+extern Tycon findTycon     ( Text );
+extern Tycon addTycon      ( Tycon );
 extern Tycon findQualTycon ( Cell );
-extern Tycon addPrimTycon ( Text,Kind,Int,Cell,Cell );
+extern Tycon addPrimTycon  ( Text,Kind,Int,Cell,Cell );
 
 #define isSynonym(h)    (isTycon(h) && tycon(h).what==SYNONYM)
 #define isQualType(t)  (isPair(t) && fst(t)==QUAL)
@@ -705,6 +725,9 @@ extern Tycon addPrimTycon ( Text,Kind,Int,Cell,Cell );
 
 extern Tycon findQualTyconWithoutConsultingExportList ( QualId q );
 
+extern Int numQualifiers   ( Type );
+
+
 /* --------------------------------------------------------------------------
  * Globally defined name values:
  * ------------------------------------------------------------------------*/
@@ -738,10 +761,12 @@ struct strName {
     Cell   type;
     Cell   defn;
     Bool   hasStrict;          /* does constructor have strict components? */
-    Cell   stgVar;                                      /* really StgVar   */
     Text   callconv;                          /* for foreign import/export */
     void*  primop;                                      /* really StgPrim* */
     void*  itbl;                 /* For constructors, the info tbl pointer */
+    Cell   closure;       /* Either StgTree, or (later) Ptr, an AsmBCO/
+                             AsmCAF/AsmCon thing, or CPtr, which is the
+                             address in the evaluator's heap               */
     Name   nextNameHash;
 };
 
@@ -786,7 +811,6 @@ extern Name   findQualName    ( Cell );
 extern Name   addPrimCfun     ( Text,Int,Int,Cell );
 extern Name   addPrimCfunREP  ( Text,Int,Int,Int );
 extern Int    sfunPos         ( Name,Name );
-extern Name   nameFromStgVar  ( Cell );
 extern Name   jrsFindQualName ( Text,Text );
 
 extern Name findQualNameWithoutConsultingExportList ( QualId q );