[project @ 2000-02-23 19:41:50 by lewie]
[ghc-hetmet.git] / ghc / includes / Closures.h
index 17bcbf2..85d8704 100644 (file)
@@ -1,5 +1,5 @@
 /* ----------------------------------------------------------------------------
- * $Id: Closures.h,v 1.12 1999/03/25 13:01:44 simonm Exp $
+ * $Id: Closures.h,v 1.16 2000/01/18 12:36:38 simonmar Exp $
  *
  * (c) The GHC Team, 1998-1999
  *
@@ -37,21 +37,39 @@ typedef struct {
    The parallel header
    -------------------------------------------------------------------------- */
 
-#ifdef GRAN
+#ifdef PAR
 
 typedef struct {
-  W_ procs;
-} StgGranHeader;
+  /* StgWord ga; */  /* nope! global addresses are managed via a hash table */
+} StgParHeader;
 
 #else /* !PAR */
 
 typedef struct {
   /* empty */
-} StgGranHeader;
+} StgParHeader;
 
 #endif /* PAR */
 
 /* -----------------------------------------------------------------------------
+   The GranSim header
+   -------------------------------------------------------------------------- */
+
+#if defined(GRAN)
+
+typedef struct {
+  StgWord procs; /* bitmask indicating on which PEs this closure resides */
+} StgGranHeader;
+
+#else /* !GRAN */
+
+typedef struct {
+  /* empty */
+} StgGranHeader;
+
+#endif /* GRAN */
+
+/* -----------------------------------------------------------------------------
    The ticky-ticky header
 
    Comment from old Ticky.h:
@@ -70,19 +88,19 @@ typedef struct {
    info tables to be @_Evacuate_1@ and @_Scavenge_1_0@.
    -------------------------------------------------------------------------- */
 
-#ifdef TICKY
+#ifdef TICKY_TICKY
 
 typedef struct {
-  W_ updated;
+  /* old: W_ updated; */
 } StgTickyHeader;
 
-#else /* !TICKY */
+#else /* !TICKY_TICKY */
 
 typedef struct {
        /* empty */
 } StgTickyHeader;
 
-#endif /* TICKY */
+#endif /* TICKY_TICKY */
 
 /* -----------------------------------------------------------------------------
    The full fixed-size closure header
@@ -96,10 +114,13 @@ typedef struct {
 #ifdef PROFILING
        StgProfHeader         prof;
 #endif
+#ifdef PAR
+       StgParHeader          par;
+#endif
 #ifdef GRAN
-       StgGranHeader         par;
+       StgGranHeader         gran;
 #endif
-#ifdef TICKY
+#ifdef TICKY_TICKY
        StgTickyHeader        ticky;
 #endif
 } StgHeader;
@@ -189,12 +210,6 @@ typedef struct StgCAF_ {
 
 typedef struct {
     StgHeader  header;
-    struct StgTSO_ *blocking_queue;
-    StgMutClosure *mut_link;
-} StgBlockingQueue;
-
-typedef struct {
-    StgHeader  header;
     StgWord    words;
     StgWord    payload[0];
 } StgArrWords;
@@ -226,6 +241,7 @@ typedef struct {
 typedef struct {
     StgHeader  header;
     struct _StgUpdateFrame *link;
+    StgInt      exceptions_blocked;
     StgClosure *handler;
 } StgCatchFrame;
 
@@ -257,7 +273,7 @@ typedef struct _StgStableName {
   StgHeader      header;
   StgWord        sn;
 } StgStableName;
-  
+
 typedef struct _StgWeak {      /* Weak v */
   StgHeader header;
   StgClosure *key;
@@ -293,12 +309,72 @@ typedef struct {
   StgClosure*     value;
 } StgMVar;
 
-/* Parallel FETCH_ME closures */
-#ifdef PAR
-typedef struct {
+#if defined(PAR) || defined(GRAN)
+/*
+  StgBlockingQueueElement represents the types of closures that can be 
+  found on a blocking queue: StgTSO, StgRBHSave, StgBlockedFetch.
+  (StgRBHSave can only appear at the end of a blocking queue).  
+  Logically, this is a union type, but defining another struct with a common
+  layout is easier to handle in the code (same as for StgMutClosures).
+*/
+typedef struct StgBlockingQueueElement_ {
+  StgHeader                         header;
+  struct StgBlockingQueueElement_  *link;
+  StgMutClosure                    *mut_link;
+  struct StgClosure_               *payload[0];
+} StgBlockingQueueElement;
+
+typedef struct StgBlockingQueue_ {
+  StgHeader                 header;
+  struct StgBlockingQueueElement_ *blocking_queue;
+  StgMutClosure            *mut_link;
+} StgBlockingQueue;
+
+/* this closure is hanging at the end of a blocking queue in (par setup only) */
+typedef struct StgRBHSave_ {
   StgHeader    header;
-  void        *ga;             /* type globalAddr is abstract here */
+  StgPtr       payload[0];
+} StgRBHSave;
+
+typedef struct StgRBH_ {
+  StgHeader                                header;
+  struct StgBlockingQueueElement_         *blocking_queue;
+  StgMutClosure                           *mut_link;
+} StgRBH;
+
+#else
+
+typedef struct StgBlockingQueue_ {
+  StgHeader          header;
+  struct StgTSO_    *blocking_queue;
+  StgMutClosure     *mut_link;
+} StgBlockingQueue;
+
+#endif
+
+#if defined(PAR)
+/* global indirections aka FETCH_ME closures */
+typedef struct StgFetchMe_ {
+  StgHeader              header;
+  globalAddr            *ga;           /* type globalAddr is abstract here */
+  StgMutClosure         *mut_link;
 } StgFetchMe;
+
+/* same contents as an ordinary StgBlockingQueue */
+typedef struct StgFetchMeBlockingQueue_ {
+  StgHeader                          header;
+  struct StgBlockingQueueElement_   *blocking_queue;
+  StgMutClosure                     *mut_link;
+} StgFetchMeBlockingQueue;
+
+/* entry in a blocking queue, indicating a request from a TSO on another PE */
+typedef struct StgBlockedFetch_ {
+  StgHeader                         header;
+  struct StgBlockingQueueElement_  *link;
+  StgMutClosure                    *mut_link;
+  StgClosure                       *node;
+  globalAddr                        ga;
+} StgBlockedFetch;
 #endif
 
 #endif /* CLOSURES_H */