Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/8413d83859ee0120e52bb1b3cd775b7344b52c76

>---------------------------------------------------------------

commit 8413d83859ee0120e52bb1b3cd775b7344b52c76
Author: Ian Lynagh <[email protected]>
Date:   Sat Aug 25 11:31:50 2012 +0100

    Make a function for get_itbl, rather than using a CPP macro
    
    This has several advantages:
    * It can be called from gdb
    * There is more type information for the user, and type checking
      for the compiler
    * Less opportunity for things to go wrong, e.g. due to missing
      parentheses or repeated execution
    
    The sizes of the non-debug .o files hasn't changed (other than
    Inlines.o), so I'm pretty sure the compiled code is identical.

>---------------------------------------------------------------

 includes/rts/storage/ClosureMacros.h |   13 +++++++------
 rts/Printer.c                        |    2 +-
 rts/RaiseAsync.c                     |    2 +-
 rts/sm/MarkWeak.c                    |    4 ++--
 rts/sm/Sanity.c                      |    8 ++++----
 5 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/includes/rts/storage/ClosureMacros.h 
b/includes/rts/storage/ClosureMacros.h
index 122f446..4442838 100644
--- a/includes/rts/storage/ClosureMacros.h
+++ b/includes/rts/storage/ClosureMacros.h
@@ -50,12 +50,6 @@
 #define GET_INFO(c)   ((c)->header.info)
 #define GET_ENTRY(c)  (ENTRY_CODE(GET_INFO(c)))
 
-#define get_itbl(c)   (INFO_PTR_TO_STRUCT((c)->header.info))
-#define get_ret_itbl(c) (RET_INFO_PTR_TO_STRUCT((c)->header.info))
-#define get_fun_itbl(c) (FUN_INFO_PTR_TO_STRUCT((c)->header.info))
-#define get_thunk_itbl(c) (THUNK_INFO_PTR_TO_STRUCT((c)->header.info))
-#define get_con_itbl(c) (CON_INFO_PTR_TO_STRUCT((c)->header.info))
-
 #define GET_TAG(con) (get_itbl(con)->srt_bitmap)
 
 #ifdef TABLES_NEXT_TO_CODE
@@ -80,6 +74,13 @@
 #define itbl_to_con_itbl(i) ((StgConInfoTable *)(i))
 #endif
 
+EXTERN_INLINE StgInfoTable *get_itbl(StgClosure *c);
+EXTERN_INLINE StgInfoTable *get_itbl(StgClosure *c) {return 
INFO_PTR_TO_STRUCT(c->header.info);}
+#define get_ret_itbl(c) (RET_INFO_PTR_TO_STRUCT((c)->header.info))
+#define get_fun_itbl(c) (FUN_INFO_PTR_TO_STRUCT((c)->header.info))
+#define get_thunk_itbl(c) (THUNK_INFO_PTR_TO_STRUCT((c)->header.info))
+#define get_con_itbl(c) (CON_INFO_PTR_TO_STRUCT((c)->header.info))
+
 /* 
-----------------------------------------------------------------------------
    Macros for building closures
    -------------------------------------------------------------------------- 
*/
diff --git a/rts/Printer.c b/rts/Printer.c
index a7ce367..737fba4 100644
--- a/rts/Printer.c
+++ b/rts/Printer.c
@@ -91,7 +91,7 @@ printThunkPayload( StgThunk *obj )
     StgWord i, j;
     const StgInfoTable* info;
 
-    info = get_itbl(obj);
+    info = get_itbl((StgClosure *)obj);
     for (i = 0; i < info->layout.payload.ptrs; ++i) {
         debugBelch(", ");
         printPtr((StgPtr)obj->payload[i]);
diff --git a/rts/RaiseAsync.c b/rts/RaiseAsync.c
index 9e5a8c3..47d8806 100644
--- a/rts/RaiseAsync.c
+++ b/rts/RaiseAsync.c
@@ -306,7 +306,7 @@ check_target:
 
        // ASSUMPTION: tso->block_info must always point to a
        // closure.  In the threaded RTS it does.
-        switch (get_itbl(mvar)->type) {
+        switch (get_itbl((StgClosure *)mvar)->type) {
         case MVAR_CLEAN:
         case MVAR_DIRTY:
             break;
diff --git a/rts/sm/MarkWeak.c b/rts/sm/MarkWeak.c
index b7d6226..d57f7a0 100644
--- a/rts/sm/MarkWeak.c
+++ b/rts/sm/MarkWeak.c
@@ -127,7 +127,7 @@ traverseWeakPtrList(void)
              continue;
          }
          
-          info = get_itbl(w);
+          info = get_itbl((StgClosure *)w);
          switch (info->type) {
 
          case WEAK:
@@ -269,7 +269,7 @@ static rtsBool tidyThreadList (generation *gen)
             t = tmp;
         }
         
-        ASSERT(get_itbl(t)->type == TSO);
+        ASSERT(get_itbl((StgClosure *)t)->type == TSO);
         next = t->global_link;
         
         // if the thread is not masking exceptions but there are
diff --git a/rts/sm/Sanity.c b/rts/sm/Sanity.c
index 9a22dcb..99cea93 100644
--- a/rts/sm/Sanity.c
+++ b/rts/sm/Sanity.c
@@ -328,12 +328,12 @@ checkClosure( StgClosure* p )
         // ASSERT(get_itbl(bq->bh)->type == BLACKHOLE);
         ASSERT(LOOKS_LIKE_CLOSURE_PTR(bq->bh));
 
-        ASSERT(get_itbl(bq->owner)->type == TSO);
+        ASSERT(get_itbl((StgClosure *)(bq->owner))->type == TSO);
         ASSERT(bq->queue == (MessageBlackHole*)END_TSO_QUEUE 
                || bq->queue->header.info == &stg_MSG_BLACKHOLE_info);
         ASSERT(bq->link == (StgBlockingQueue*)END_TSO_QUEUE || 
-               get_itbl(bq->link)->type == IND ||
-               get_itbl(bq->link)->type == BLOCKING_QUEUE);
+               get_itbl((StgClosure *)(bq->link))->type == IND ||
+               get_itbl((StgClosure *)(bq->link))->type == BLOCKING_QUEUE);
 
         return sizeofW(StgBlockingQueue);
     }
@@ -567,7 +567,7 @@ checkGlobalTSOList (rtsBool checkTSOs)
       for (tso=generations[g].threads; tso != END_TSO_QUEUE; 
            tso = tso->global_link) {
           ASSERT(LOOKS_LIKE_CLOSURE_PTR(tso));
-          ASSERT(get_itbl(tso)->type == TSO);
+          ASSERT(get_itbl((StgClosure *)tso)->type == TSO);
           if (checkTSOs)
               checkTSO(tso);
 



_______________________________________________
Cvs-ghc mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-ghc

Reply via email to