[project @ 2005-06-13 12:29:48 by simonmar]
[ghc-hetmet.git] / ghc / includes / Updates.h
index 034412e..39e17d2 100644 (file)
    UPD_PERM_IND(updclosure,heapptr)
 # define UPD_SPEC_IND(updclosure, ind_info, heapptr, and_then) \
    UPD_PERM_IND(updclosure,heapptr); and_then
-# define NOBH_UPD_SPEC_IND(updclosure, ind_info, heapptr, and_then) \
-   NOBH_UPD_PERM_IND(updclosure,heapptr); and_then
 #else
 #  define SEMI ;
 # define UPD_IND(updclosure, heapptr) \
    UPD_REAL_IND(updclosure,INFO_PTR(stg_IND_info),heapptr,SEMI)
 # define UPD_SPEC_IND(updclosure, ind_info, heapptr, and_then) \
    UPD_REAL_IND(updclosure,ind_info,heapptr,and_then)
-# define NOBH_UPD_SPEC_IND(updclosure, ind_info, heapptr, and_then) \
-   NOBH_UPD_REAL_IND(updclosure,ind_info,heapptr,and_then)
 #endif
 
 /* These macros have to work in both C and C--, so here's the
         BLOCK_BEGIN                                            \
        DECLARE_IPTR(info);                                     \
        info = GET_INFO(updclosure);                            \
-        AWAKEN_BQ(info,updclosure);                            \
-       updateWithIndirection(GET_INFO(updclosure), ind_info,   \
-                             updclosure,                       \
-                             heapptr,                          \
-                             and_then);                        \
-       BLOCK_END
-
-#define NOBH_UPD_REAL_IND(updclosure, ind_info, heapptr, and_then)     \
-        BLOCK_BEGIN                                            \
-       updateWithIndirection(GET_INFO(updclosure), ind_info,   \
+       updateWithIndirection(ind_info,                         \
                              updclosure,                       \
                              heapptr,                          \
                              and_then);                        \
 #if defined(PROFILING) || defined(TICKY_TICKY)
 #define UPD_PERM_IND(updclosure, heapptr)      \
         BLOCK_BEGIN                            \
-       DECLARE_IPTR(info);                     \
-       info = GET_INFO(updclosure);            \
-        AWAKEN_BQ(info,updclosure);            \
-       updateWithPermIndirection(info,         \
-                                 updclosure,   \
-                                 heapptr);     \
-       BLOCK_END
-
-#define NOBH_UPD_PERM_IND(updclosure, heapptr) \
-        BLOCK_BEGIN                            \
-       updateWithPermIndirection(GET_INFO(updclosure),         \
-                                 updclosure,   \
+       updateWithPermIndirection(updclosure,   \
                                  heapptr);     \
        BLOCK_END
 #endif
 # ifdef TICKY_TICKY
 #  define UPD_IND_NOLOCK(updclosure, heapptr)  \
         BLOCK_BEGIN                            \
-       DECLARE_IPTR(info);                     \
-       info = GET_INFO(updclosure);            \
-        AWAKEN_BQ_NOLOCK(info,updclosure);     \
-       updateWithPermIndirection(info,         \
-                                 updclosure,   \
+       updateWithPermIndirection(updclosure,   \
                                  heapptr);     \
        BLOCK_END
 # else
 #  define UPD_IND_NOLOCK(updclosure, heapptr)                  \
         BLOCK_BEGIN                                            \
-       DECLARE_IPTR(info);                                     \
-       info = GET_INFO(updclosure);                            \
-        AWAKEN_BQ_NOLOCK(info,updclosure);                     \
-       updateWithIndirection(info, INFO_PTR(stg_IND_info),     \
+       updateWithIndirection(INFO_PTR(stg_IND_info),           \
                              updclosure,                       \
                              heapptr,);                        \
        BLOCK_END
@@ -186,31 +155,6 @@ extern void awakenBlockedQueue(StgBlockingQueueElement *q, StgClosure *node);
                DO_AWAKEN_BQ(((StgBlockingQueue *)closure)->blocking_queue, closure);                           \
        }
 
-
-#else /* !GRAN && !PAR */
-
-#define DO_AWAKEN_BQ(closure)          \
-        FCALL awakenBlockedQueue(StgBlockingQueue_blocking_queue(closure) ARG_PTR);
-
-#define AWAKEN_BQ(info,closure)                                                \
-       if (info == INFO_PTR(stg_BLACKHOLE_BQ_info)) {                  \
-          DO_AWAKEN_BQ(closure);                                        \
-       }
-
-#define AWAKEN_STATIC_BQ(info,closure)                                 \
-       if (info == INFO_PTR(stg_BLACKHOLE_BQ_STATIC_info)) {           \
-          DO_AWAKEN_BQ(closure);                                        \
-       }
-
-#ifdef RTS_SUPPORTS_THREADS
-#define DO_AWAKEN_BQ_NOLOCK(closure) \
-        FCALL awakenBlockedQueueNoLock(StgBlockingQueue_blocking_queue(closure) ARG_PTR);
-
-#define AWAKEN_BQ_NOLOCK(info,closure)                                 \
-       if (info == INFO_PTR(stg_BLACKHOLE_BQ_info)) {                  \
-          DO_AWAKEN_BQ_NOLOCK(closure);                                 \
-       }
-#endif
 #endif /* GRAN || PAR */
 
 /* -----------------------------------------------------------------------------
@@ -249,23 +193,25 @@ extern void awakenBlockedQueue(StgBlockingQueueElement *q, StgClosure *node);
 
 #ifdef CMINUSMINUS
 
-#define DEBUG_FILL_SLOP(p)                     \
-  W_ inf;                                      \
-  W_ np;                                       \
-  W_ nw;                                       \
-  W_ i;                                                \
-  inf = %GET_STD_INFO(p);                      \
-  np = TO_W_(%INFO_PTRS(inf));                 \
-  nw = TO_W_(%INFO_NPTRS(inf));                        \
-  if (%INFO_TYPE(inf) != HALF_W_(THUNK_SELECTOR)) {    \
-    i = 0;                                     \
-    for:                                       \
-      if (i < np + nw) {                       \
-        StgClosure_payload(p,i) = 0;           \
-        i = i + 1;                             \
-        goto for;                              \
-      }                                                \
-  }
+#define DEBUG_FILL_SLOP(p)                                     \
+  W_ inf;                                                      \
+  W_ np;                                                       \
+  W_ nw;                                                       \
+  W_ i;                                                                \
+  inf = %GET_STD_INFO(p);                                      \
+  np = TO_W_(%INFO_PTRS(inf));                                 \
+  nw = TO_W_(%INFO_NPTRS(inf));                                        \
+  if (%INFO_TYPE(inf) == HALF_W_(THUNK_SELECTOR)) {            \
+       StgThunk_payload(p,0) = 0;                              \
+  } else { if (%INFO_TYPE(inf) != HALF_W_(BLACKHOLE)) {                \
+    i = 0;                                                     \
+    for:                                                       \
+      if (i < np + nw) {                                       \
+        StgThunk_payload(p,i) = 0;                             \
+        i = i + 1;                                             \
+        goto for;                                              \
+      }                                                                \
+  } }
 
 
 #else /* !CMINUSMINUS */
@@ -276,9 +222,18 @@ DEBUG_FILL_SLOP(StgClosure *p)
     StgInfoTable *inf = get_itbl(p);           
     nat np = inf->layout.payload.ptrs,         
        nw = inf->layout.payload.nptrs, i;
-    if (inf->type != THUNK_SELECTOR) {
+
+    switch (inf->type) {
+    case BLACKHOLE:
+       break;
+    case THUNK_SELECTOR:
+#ifdef SMP
+       ((StgSelector *)p)->selectee = 0;
+#endif
+       break;
+    default:
        for (i = 0; i < np + nw; i++) {
-           ((StgClosure *)p)->payload[i] = 0;
+           ((StgThunk *)p)->payload[i] = 0;
        }
     }
 }
@@ -298,7 +253,7 @@ DEBUG_FILL_SLOP(StgClosure *p)
  */
 #ifdef CMINUSMINUS
 #define generation(n) (W_[generations] + n*SIZEOF_generation)
-#define updateWithIndirection(info, ind_info, p1, p2, and_then)        \
+#define updateWithIndirection(ind_info, p1, p2, and_then)      \
     W_ bd;                                                     \
                                                                \
 /*    ASSERT( p1 != p2 && !closure_IND(p1) );                  \
@@ -311,11 +266,9 @@ DEBUG_FILL_SLOP(StgClosure *p)
       TICK_UPD_NEW_IND();                                      \
       and_then;                                                        \
     } else {                                                   \
-      if (info != stg_BLACKHOLE_BQ_info) {                     \
-        DEBUG_FILL_SLOP(p1);                                   \
-        foreign "C" recordMutableGen(p1 "ptr",                         \
+      DEBUG_FILL_SLOP(p1);                                     \
+      foreign "C" recordMutableGenLock(p1 "ptr",               \
                 generation(TO_W_(bdescr_gen_no(bd))) "ptr");   \
-      }                                                                \
       StgInd_indirectee(p1) = p2;                              \
       SET_INFO(p1, stg_IND_OLDGEN_info);                       \
       LDV_RECORD_CREATE(p1);                                   \
@@ -323,7 +276,7 @@ DEBUG_FILL_SLOP(StgClosure *p)
       and_then;                                                        \
   }
 #else
-#define updateWithIndirection(_info, ind_info, p1, p2, and_then)       \
+#define updateWithIndirection(ind_info, p1, p2, and_then)              \
   {                                                                    \
     bdescr *bd;                                                                \
                                                                        \
@@ -337,10 +290,8 @@ DEBUG_FILL_SLOP(StgClosure *p)
       TICK_UPD_NEW_IND();                                              \
       and_then;                                                                \
     } else {                                                           \
-      if (_info != &stg_BLACKHOLE_BQ_info) {                           \
-        DEBUG_FILL_SLOP(p1);                                           \
-        recordMutableGen(p1, &generations[bd->gen_no]);                        \
-      }                                                                        \
+      DEBUG_FILL_SLOP(p1);                                             \
+      recordMutableGenLock(p1, &generations[bd->gen_no]);              \
       ((StgInd *)p1)->indirectee = p2;                                 \
       SET_INFO(p1, &stg_IND_OLDGEN_info);                              \
       TICK_UPD_OLD_IND();                                              \
@@ -354,35 +305,38 @@ DEBUG_FILL_SLOP(StgClosure *p)
  */
 #ifndef CMINUSMINUS
 INLINE_HEADER void
-updateWithPermIndirection(const StgInfoTable *info, 
-                         StgClosure *p1,
+updateWithPermIndirection(StgClosure *p1,
                          StgClosure *p2) 
 {
   bdescr *bd;
 
   ASSERT( p1 != p2 && !closure_IND(p1) );
 
-  // @LDV profiling
-  // Destroy the old closure.
-  // Nb: LDV_* stuff cannot mix with ticky-ticky
+  /*
+   * @LDV profiling
+   * Destroy the old closure.
+   * Nb: LDV_* stuff cannot mix with ticky-ticky
+   */
   LDV_RECORD_DEAD_FILL_SLOP_DYNAMIC(p1);
 
   bd = Bdescr((P_)p1);
   if (bd->gen_no == 0) {
     ((StgInd *)p1)->indirectee = p2;
     SET_INFO(p1, &stg_IND_PERM_info);
-    // @LDV profiling
-    // We have just created a new closure.
+    /*
+     * @LDV profiling
+     * We have just created a new closure.
+     */
     LDV_RECORD_CREATE(p1);
     TICK_UPD_NEW_PERM_IND(p1);
   } else {
-    if (info != &stg_BLACKHOLE_BQ_info) {
-       recordMutableGen(p1, &generations[bd->gen_no]);
-    }
+    recordMutableGenLock(p1, &generations[bd->gen_no]);
     ((StgInd *)p1)->indirectee = p2;
     SET_INFO(p1, &stg_IND_OLDGEN_PERM_info);
-    // @LDV profiling
-    // We have just created a new closure.
+    /*
+     * @LDV profiling
+     * We have just created a new closure.
+     */
     LDV_RECORD_CREATE(p1);
     TICK_UPD_OLD_PERM_IND();
   }