[commit: ghc] master: Convert more RTS macros to functions (ef3339c)

Ian Lynagh <[email protected]>
Newsgroups gmane.comp.lang.haskell.cvs.ghc
Message-ID <[email protected]>
Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/ef3339cf634aceddae43cc42bfe545a5461ebe36

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

commit ef3339cf634aceddae43cc42bfe545a5461ebe36
Author: Ian Lynagh <[email protected]>
Date:   Fri Sep 21 17:56:14 2012 +0100

    Convert more RTS macros to functions
    
    No size changes in the non-debug object files

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

 includes/rts/storage/ClosureMacros.h |   17 ++++++++++++-----
 rts/Interpreter.c                    |    2 +-
 rts/Printer.c                        |    6 +++---
 rts/sm/Evac.c                        |   10 +++++-----
 rts/sm/GCAux.c                       |    2 +-
 5 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/includes/rts/storage/ClosureMacros.h b/includes/rts/storage/ClosureMacros.h
index 146564a..8f071a2 100644
--- a/includes/rts/storage/ClosureMacros.h
+++ b/includes/rts/storage/ClosureMacros.h
@@ -46,11 +46,14 @@
  
    -------------------------------------------------------------------------- */
 
-#define SET_INFO(c,i) ((c)->header.info = (i))
-#define GET_INFO(c)   ((c)->header.info)
-#define GET_ENTRY(c)  (ENTRY_CODE(GET_INFO(c)))
+INLINE_HEADER void SET_INFO(StgClosure *c, const StgInfoTable *info) {
+    c->header.info = info;
+}
+INLINE_HEADER const StgInfoTable *GET_INFO(StgClosure *c) {
+    return c->header.info;
+}
 
-#define GET_TAG(con) (get_itbl(con)->srt_bitmap)
+#define GET_ENTRY(c)  (ENTRY_CODE(GET_INFO(c)))
 
 #ifdef TABLES_NEXT_TO_CODE
 EXTERN_INLINE StgInfoTable *INFO_PTR_TO_STRUCT(const StgInfoTable *info);
@@ -90,6 +93,10 @@ INLINE_HEADER StgThunkInfoTable *get_thunk_itbl(const StgClosure *c) {return THU
 
 INLINE_HEADER StgConInfoTable *get_con_itbl(const StgClosure *c) {return CON_INFO_PTR_TO_STRUCT((c)->header.info);}
 
+INLINE_HEADER StgHalfWord GET_TAG(const StgClosure *con) {
+    return get_itbl(con)->srt_bitmap;
+}
+
 /* -----------------------------------------------------------------------------
    Macros for building closures
    -------------------------------------------------------------------------- */
@@ -142,7 +149,7 @@ INLINE_HEADER StgConInfoTable *get_con_itbl(const StgClosure *c) {return CON_INF
 // Use when changing a closure from one kind to another
 #define OVERWRITE_INFO(c, new_info)                             \
     OVERWRITING_CLOSURE((StgClosure *)(c));                     \
-    SET_INFO((c), (new_info));                                  \
+    SET_INFO((StgClosure *)(c), (new_info));                    \
     LDV_RECORD_CREATE(c);
 
 /* -----------------------------------------------------------------------------
diff --git a/rts/Interpreter.c b/rts/Interpreter.c
index f3e0700..83973e8 100644
--- a/rts/Interpreter.c
+++ b/rts/Interpreter.c
@@ -339,7 +339,7 @@ eval_obj:
 	{
 	    StgUpdateFrame *__frame;
 	    __frame = (StgUpdateFrame *)Sp;
-	    SET_INFO(__frame, (StgInfoTable *)&stg_upd_frame_info);
+	    SET_INFO((StgClosure *)__frame, (StgInfoTable *)&stg_upd_frame_info);
 	    __frame->updatee = (StgClosure *)(ap);
 	}
 	
diff --git a/rts/Printer.c b/rts/Printer.c
index 02fbb09..fb00401 100644
--- a/rts/Printer.c
+++ b/rts/Printer.c
@@ -259,7 +259,7 @@ printClosure( StgClosure *obj )
         {
             StgUpdateFrame* u = (StgUpdateFrame*)obj;
             debugBelch("UPDATE_FRAME(");
-            printPtr((StgPtr)GET_INFO(u));
+            printPtr((StgPtr)GET_INFO((StgClosure *)u));
             debugBelch(",");
             printPtr((StgPtr)u->updatee);
             debugBelch(")\n"); 
@@ -270,7 +270,7 @@ printClosure( StgClosure *obj )
         {
             StgCatchFrame* u = (StgCatchFrame*)obj;
             debugBelch("CATCH_FRAME(");
-            printPtr((StgPtr)GET_INFO(u));
+            printPtr((StgPtr)GET_INFO((StgClosure *)u));
             debugBelch(",");
             printPtr((StgPtr)u->handler);
             debugBelch(")\n"); 
@@ -290,7 +290,7 @@ printClosure( StgClosure *obj )
         {
             StgStopFrame* u = (StgStopFrame*)obj;
             debugBelch("STOP_FRAME(");
-            printPtr((StgPtr)GET_INFO(u));
+            printPtr((StgPtr)GET_INFO((StgClosure *)u));
             debugBelch(")\n"); 
             break;
         }
diff --git a/rts/sm/Evac.c b/rts/sm/Evac.c
index 867cef8..ed2bc4a 100644
--- a/rts/sm/Evac.c
+++ b/rts/sm/Evac.c
@@ -794,11 +794,11 @@ unchain_thunk_selectors(StgSelector *p, StgClosure *val)
             // entered, and should result in a NonTermination exception.
             ((StgThunk *)p)->payload[0] = val;
             write_barrier();
-            SET_INFO(p, &stg_sel_0_upd_info);
+            SET_INFO((StgClosure *)p, &stg_sel_0_upd_info);
         } else {
             ((StgInd *)p)->indirectee = val;
             write_barrier();
-            SET_INFO(p, &stg_IND_info);
+            SET_INFO((StgClosure *)p, &stg_IND_info);
         }
 
         // For the purposes of LDV profiling, we have created an
@@ -885,7 +885,7 @@ selector_chain:
             //   - if evac, we need to call evacuate(), because we
             //     need the write-barrier stuff.
             //   - undo the chain we've built to point to p.
-            SET_INFO(p, (const StgInfoTable *)info_ptr);
+            SET_INFO((StgClosure *)p, (const StgInfoTable *)info_ptr);
             *q = (StgClosure *)p;
             if (evac) evacuate(q);
             unchain_thunk_selectors(prev_thunk_selector, (StgClosure *)p);
@@ -895,7 +895,7 @@ selector_chain:
 #else
     // Save the real info pointer (NOTE: not the same as get_itbl()).
     info_ptr = (StgWord)p->header.info;
-    SET_INFO(p,&stg_WHITEHOLE_info);
+    SET_INFO((StgClosure *)p,&stg_WHITEHOLE_info);
 #endif
 
     field = INFO_PTR_TO_STRUCT((StgInfoTable *)info_ptr)->layout.selector_offset;
@@ -1073,7 +1073,7 @@ selector_loop:
 bale_out:
     // We didn't manage to evaluate this thunk; restore the old info
     // pointer.  But don't forget: we still need to evacuate the thunk itself.
-    SET_INFO(p, (const StgInfoTable *)info_ptr);
+    SET_INFO((StgClosure *)p, (const StgInfoTable *)info_ptr);
     // THREADED_RTS: we just unlocked the thunk, so another thread
     // might get in and update it.  copy() will lock it again and
     // check whether it was updated in the meantime.
diff --git a/rts/sm/GCAux.c b/rts/sm/GCAux.c
index 12e106b..3df36d7 100644
--- a/rts/sm/GCAux.c
+++ b/rts/sm/GCAux.c
@@ -113,7 +113,7 @@ revertCAFs( void )
          c != (StgIndStatic *)END_OF_STATIC_LIST; 
 	 c = (StgIndStatic *)c->static_link) 
     {
-	SET_INFO(c, c->saved_info);
+	SET_INFO((StgClosure *)c, c->saved_info);
 	c->saved_info = NULL;
 	// could, but not necessary: c->static_link = NULL; 
     }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.