profiling fixes
authorSimon Marlow <marlowsd@gmail.com>
Fri, 19 Oct 2012 10:27:53 +0000 (11:27 +0100)
committerSimon Marlow <marlowsd@gmail.com>
Fri, 19 Oct 2012 10:49:37 +0000 (11:49 +0100)
includes/Cmm.h
rts/Exception.cmm
rts/HeapStackCheck.cmm
rts/PrimOps.cmm
rts/StgStartup.cmm
rts/StgStdThunks.cmm
rts/Updates.cmm
rts/Updates.h

index 805806b..9cb2dbc 100644 (file)
 #define LOAD_INFO(ret,x)                        \
     info = %INFO_PTR(UNTAG(x));
 
-#define MAYBE_UNTAG(x) UNTAG(x);
+#define UNTAG_IF_PROF(x) UNTAG(x)
 
 #else
 
   }                                             \
   info = %INFO_PTR(x);
 
-#define MAYBE_UNTAG(x) (x) /* already untagged */
+#define UNTAG_IF_PROF(x) (x) /* already untagged */
 
 #endif
 
    }                                                   \
   default:                                             \
    {                                                   \
-       x = MAYBE_UNTAG(x);                              \
+       x = UNTAG_IF_PROF(x);                            \
        jump %ENTRY_CODE(info) (x);                      \
    }                                                   \
   }
    ------------------------------------------------------------------------- */
 
 #if defined(PROFILING)
-#define PROF_HDR_FIELDS(w_) PROF_HDR_FIELDS_(w_,prof_hdr_1,prof_hdr_2)
-#define PROF_HDR_FIELDS_(w_,hdr1,hdr2)          \
-  w_ hdr1,                                      \
+#define PROF_HDR_FIELDS(w_,hdr1,hdr2)          \
+  w_ hdr1,                                     \
   w_ hdr2,
 #else
-#define PROF_HDR_FIELDS(w_) /* nothing */
-#define PROF_HDR_FIELDS_(w_,hdr1,hdr2) /* nothing */
+#define PROF_HDR_FIELDS(w_,hdr1,hdr2) /* nothing */
 #endif
 
 /* -------------------------------------------------------------------------
index 8a9f4e6..3f1dc10 100644 (file)
@@ -341,15 +341,15 @@ stg_killMyself
  * kind of return to the activation record underneath us on the stack.
  */
 
-#define CATCH_FRAME_FIELDS(w_,p_,info_ptr,exceptions_blocked,handler)   \
+#define CATCH_FRAME_FIELDS(w_,p_,info_ptr,p1,p2,exceptions_blocked,handler)   \
   w_ info_ptr,                                                          \
-  PROF_HDR_FIELDS(w_)                                                   \
+  PROF_HDR_FIELDS(w_,p1,p2)                                             \
   w_ exceptions_blocked,                                                \
   p_ handler
 
 
 INFO_TABLE_RET(stg_catch_frame, CATCH_FRAME,
-               CATCH_FRAME_FIELDS(W_,P_,info_ptr,
+               CATCH_FRAME_FIELDS(W_,P_,info_ptr, p1, p2,
                                   exceptions_blocked,handler))
     return (P_ ret)
 {
@@ -388,7 +388,7 @@ stg_catchzh ( P_ io,      /* :: IO a */
     TICK_SLOW_CALL_v();
 
     jump stg_ap_v_fast
-        (CATCH_FRAME_FIELDS(,,stg_catch_frame_info,
+        (CATCH_FRAME_FIELDS(,,stg_catch_frame_info, CCCS, 0,
                             exceptions_blocked, handler))
         (io);
 }
index 1375216..4fd4430 100644 (file)
@@ -216,7 +216,7 @@ stg_gc_prim_n (W_ arg)
 /* The stg_enter_checkbh frame has the same shape as an update frame: */
 
 INFO_TABLE_RET ( stg_enter_checkbh, RET_SMALL,
-                 UPDATE_FRAME_FIELDS(W_,P_,info_ptr,ccs,updatee))
+                 UPDATE_FRAME_FIELDS(W_,P_,info_ptr,ccs,p2,updatee))
     return (P_ ret)
 {
     foreign "C" checkBlockingQueues(MyCapability() "ptr",
index fb46cee..6cba3f5 100644 (file)
@@ -676,11 +676,12 @@ stg_threadStatuszh ( gcptr tso )
 // Catch retry frame -----------------------------------------------------------
 
 #define CATCH_RETRY_FRAME_FIELDS(w_,p_,info_ptr,        \
+                                 p1, p2,                \
                                  running_alt_code,      \
                                  first_code,            \
                                  alt_code)              \
   w_ info_ptr,                                          \
-  PROF_HDR_FIELDS(w_)                                   \
+  PROF_HDR_FIELDS(w_,p1,p2)                             \
   w_ running_alt_code,                                  \
   p_ first_code,                                        \
   p_ alt_code
@@ -688,7 +689,7 @@ stg_threadStatuszh ( gcptr tso )
 
 INFO_TABLE_RET(stg_catch_retry_frame, CATCH_RETRY_FRAME,
                CATCH_RETRY_FRAME_FIELDS(W_,P_,
-                                        info_ptr,
+                                        info_ptr, p1, p2,
                                         running_alt_code,
                                         first_code,
                                         alt_code))
@@ -712,14 +713,14 @@ INFO_TABLE_RET(stg_catch_retry_frame, CATCH_RETRY_FRAME,
         StgTSO_trec(CurrentTSO) = new_trec;
         if (running_alt_code != 0) {
             jump stg_ap_v_fast
-                (CATCH_RETRY_FRAME_FIELDS(,,info_ptr,
+                (CATCH_RETRY_FRAME_FIELDS(,,info_ptr, p1, p2,
                                           running_alt_code,
                                           first_code,
                                           alt_code))
                 (alt_code);
         } else {
             jump stg_ap_v_fast
-                (CATCH_RETRY_FRAME_FIELDS(,,info_ptr,
+                (CATCH_RETRY_FRAME_FIELDS(,,info_ptr, p1, p2,
                                           running_alt_code,
                                           first_code,
                                           alt_code))
@@ -731,9 +732,9 @@ INFO_TABLE_RET(stg_catch_retry_frame, CATCH_RETRY_FRAME,
 // Atomically frame ------------------------------------------------------------
 
 // This must match StgAtomicallyFrame in Closures.h
-#define ATOMICALLY_FRAME_FIELDS(w_,p_,info_ptr,code,next,result)        \
+#define ATOMICALLY_FRAME_FIELDS(w_,p_,info_ptr,p1,p2,code,next,result)  \
   w_ info_ptr,                                                          \
-  PROF_HDR_FIELDS(w_)                                                   \
+  PROF_HDR_FIELDS(w_,p1,p2)                                             \
   p_ code,                                                              \
   p_ next,                                                              \
   p_ result
@@ -742,7 +743,7 @@ INFO_TABLE_RET(stg_catch_retry_frame, CATCH_RETRY_FRAME,
 INFO_TABLE_RET(stg_atomically_frame, ATOMICALLY_FRAME,
                // layout of the frame, and bind the field names
                ATOMICALLY_FRAME_FIELDS(W_,P_,
-                                       info_ptr,
+                                       info_ptr, p1, p2,
                                        code,
                                        next_invariant,
                                        frame_result))
@@ -779,7 +780,8 @@ INFO_TABLE_RET(stg_atomically_frame, ATOMICALLY_FRAME,
     StgTSO_trec(CurrentTSO) = trec;
     q = StgInvariantCheckQueue_invariant(next_invariant);
     jump stg_ap_v_fast
-        (ATOMICALLY_FRAME_FIELDS(,,info_ptr,code,next_invariant,frame_result))
+        (ATOMICALLY_FRAME_FIELDS(,,info_ptr,p1,p2,
+                                 code,next_invariant,frame_result))
         (StgAtomicInvariant_code(q));
 
   } else {
@@ -799,7 +801,8 @@ INFO_TABLE_RET(stg_atomically_frame, ATOMICALLY_FRAME,
       jump stg_ap_v_fast
           // push the StgAtomicallyFrame again: the code generator is
           // clever enough to only assign the fields that have changed.
-          (ATOMICALLY_FRAME_FIELDS(,,info_ptr,code,next_invariant,frame_result))
+          (ATOMICALLY_FRAME_FIELDS(,,info_ptr,p1,p2,
+                                   code,next_invariant,frame_result))
           (code);
     }
   }
@@ -809,7 +812,7 @@ INFO_TABLE_RET(stg_atomically_frame, ATOMICALLY_FRAME,
 INFO_TABLE_RET(stg_atomically_waiting_frame, ATOMICALLY_FRAME,
                // layout of the frame, and bind the field names
                ATOMICALLY_FRAME_FIELDS(W_,P_,
-                                       info_ptr,
+                                       info_ptr, p1, p2,
                                        code,
                                        next_invariant,
                                        frame_result))
@@ -822,7 +825,7 @@ INFO_TABLE_RET(stg_atomically_waiting_frame, ATOMICALLY_FRAME,
   if (valid != 0) {
       /* Previous attempt is still valid: no point trying again yet */
       jump stg_block_noregs
-          (ATOMICALLY_FRAME_FIELDS(,,info_ptr,
+          (ATOMICALLY_FRAME_FIELDS(,,info_ptr, p1, p2,
                                    code,next_invariant,frame_result))
           ();
   } else {
@@ -832,7 +835,7 @@ INFO_TABLE_RET(stg_atomically_waiting_frame, ATOMICALLY_FRAME,
 
     // change the frame header to stg_atomically_frame_info
     jump stg_ap_v_fast
-        (ATOMICALLY_FRAME_FIELDS(,,stg_atomically_frame_info,
+        (ATOMICALLY_FRAME_FIELDS(,,stg_atomically_frame_info, p1, p2,
                                  code,next_invariant,frame_result))
         (code);
   }
@@ -845,15 +848,15 @@ INFO_TABLE_RET(stg_atomically_waiting_frame, ATOMICALLY_FRAME,
  * kind of return to the activation record underneath us on the stack.
  */
 
-#define CATCH_STM_FRAME_FIELDS(w_,p_,info_ptr,code,handler)     \
+#define CATCH_STM_FRAME_FIELDS(w_,p_,info_ptr,p1,p2,code,handler) \
   w_ info_ptr,                                                  \
-  PROF_HDR_FIELDS(w_)                                           \
+  PROF_HDR_FIELDS(w_,p1,p2)                                     \
   p_ code,                                                      \
   p_ handler
 
 INFO_TABLE_RET(stg_catch_stm_frame, CATCH_STM_FRAME,
                // layout of the frame, and bind the field names
-               CATCH_STM_FRAME_FIELDS(W_,P_,info_ptr,code,handler))
+               CATCH_STM_FRAME_FIELDS(W_,P_,info_ptr,p1,p2,code,handler))
     return (P_ ret)
 {
     W_ r, trec, outer;
@@ -872,7 +875,7 @@ INFO_TABLE_RET(stg_catch_stm_frame, CATCH_STM_FRAME,
         StgTSO_trec(CurrentTSO) = new_trec;
 
         jump stg_ap_v_fast
-            (CATCH_STM_FRAME_FIELDS(,,info_ptr,code,handler))
+            (CATCH_STM_FRAME_FIELDS(,,info_ptr,p1,p2,code,handler))
             (code);
     }
 }
@@ -907,7 +910,7 @@ stg_atomicallyzh (P_ stm)
   StgTSO_trec(CurrentTSO) = new_trec;
 
   jump stg_ap_v_fast
-      (ATOMICALLY_FRAME_FIELDS(,,stg_atomically_frame_info,
+      (ATOMICALLY_FRAME_FIELDS(,,stg_atomically_frame_info, CCCS, 0,
                                code,next_invariant,frame_result))
       (stm);
 }
@@ -937,7 +940,8 @@ stg_catchSTMzh (P_ code    /* :: STM a */,
     StgTSO_trec(CurrentTSO) = new_trec;
 
     jump stg_ap_v_fast
-        (CATCH_STM_FRAME_FIELDS(,,stg_catch_stm_frame_info, code, handler))
+        (CATCH_STM_FRAME_FIELDS(,,stg_catch_stm_frame_info, CCCS, 0,
+                                code, handler))
         (code);
 }
 
@@ -959,7 +963,7 @@ stg_catchRetryzh (P_ first_code, /* :: STM a */
 
   // push the CATCH_RETRY stack frame, and apply first_code to realWorld#
   jump stg_ap_v_fast
-      (CATCH_RETRY_FRAME_FIELDS(,, stg_catch_retry_frame_info,
+      (CATCH_RETRY_FRAME_FIELDS(,, stg_catch_retry_frame_info, CCCS, 0,
                                 0, /* not running_alt_code */
                                 first_code,
                                 alt_code))
index 6793913..5ad2ff6 100644 (file)
@@ -36,7 +36,7 @@
 
 INFO_TABLE_RET(stg_stop_thread, STOP_FRAME,
                W_ info_ptr,
-               PROF_HDR_FIELDS(W_))
+               PROF_HDR_FIELDS(W_,p1,p2))
 /* no return list: explicit stack layout */
 {
     /* 
index bd2b3df..53e4cb1 100644 (file)
       UPD_BH_UPDATABLE(node);                                           \
       LDV_ENTER(node);                                                  \
       selectee = StgThunk_payload(node,0);                              \
-      push (UPDATE_FRAME_FIELDS(,,stg_upd_frame_info,CCCS,node)) {      \
+      push (UPDATE_FRAME_FIELDS(,,stg_upd_frame_info,CCCS,0,node)) {    \
         ENTER_CCS_THUNK(node);                                          \
         if (NEED_EVAL(selectee)) {                                      \
           SAVE_CCS;                                                     \
-          (P_ constr) = call %GET_ENTRY(selectee) (selectee);           \
+          (P_ constr) = call %GET_ENTRY(UNTAG_IF_PROF(selectee)) (selectee); \
           RESTORE_CCS;                                                  \
           selectee = constr;                                            \
         }                                                               \
@@ -165,7 +165,7 @@ INFO_TABLE(stg_ap_1_upd,1,0,THUNK_1_0,"stg_ap_1_upd_info","stg_ap_1_upd_info")
     STK_CHK_NP(node);
     UPD_BH_UPDATABLE(node);
     LDV_ENTER(node);
-    push (UPDATE_FRAME_FIELDS(,,stg_upd_frame_info, CCCS, node)) {
+    push (UPDATE_FRAME_FIELDS(,,stg_upd_frame_info, CCCS, 0, node)) {
         ENTER_CCS_THUNK(node);
         jump stg_ap_0_fast
             (StgThunk_payload(node,0));
@@ -179,7 +179,7 @@ INFO_TABLE(stg_ap_2_upd,2,0,THUNK_2_0,"stg_ap_2_upd_info","stg_ap_2_upd_info")
     STK_CHK_NP(node);
     UPD_BH_UPDATABLE(node);
     LDV_ENTER(node);
-    push (UPDATE_FRAME_FIELDS(,,stg_upd_frame_info, CCCS, node)) {
+    push (UPDATE_FRAME_FIELDS(,,stg_upd_frame_info, CCCS, 0, node)) {
         ENTER_CCS_THUNK(node);
         jump stg_ap_p_fast
             (StgThunk_payload(node,0),
@@ -194,7 +194,7 @@ INFO_TABLE(stg_ap_3_upd,3,0,THUNK,"stg_ap_3_upd_info","stg_ap_3_upd_info")
     STK_CHK_NP(node);
     UPD_BH_UPDATABLE(node);
     LDV_ENTER(node);
-    push (UPDATE_FRAME_FIELDS(,,stg_upd_frame_info, CCCS, node)) {
+    push (UPDATE_FRAME_FIELDS(,,stg_upd_frame_info, CCCS, 0, node)) {
         ENTER_CCS_THUNK(node);
         jump stg_ap_pp_fast
             (StgThunk_payload(node,0),
@@ -210,7 +210,7 @@ INFO_TABLE(stg_ap_4_upd,4,0,THUNK,"stg_ap_4_upd_info","stg_ap_4_upd_info")
     STK_CHK_NP(node);
     UPD_BH_UPDATABLE(node);
     LDV_ENTER(node);
-    push (UPDATE_FRAME_FIELDS(,,stg_upd_frame_info, CCCS, node)) {
+    push (UPDATE_FRAME_FIELDS(,,stg_upd_frame_info, CCCS, 0, node)) {
         ENTER_CCS_THUNK(node);
         jump stg_ap_ppp_fast
             (StgThunk_payload(node,0),
@@ -227,7 +227,7 @@ INFO_TABLE(stg_ap_5_upd,5,0,THUNK,"stg_ap_5_upd_info","stg_ap_5_upd_info")
     STK_CHK_NP(node);
     UPD_BH_UPDATABLE(node);
     LDV_ENTER(node);
-    push (UPDATE_FRAME_FIELDS(,,stg_upd_frame_info, CCCS, node)) {
+    push (UPDATE_FRAME_FIELDS(,,stg_upd_frame_info, CCCS, 0, node)) {
         ENTER_CCS_THUNK(node);
         jump stg_ap_pppp_fast
             (StgThunk_payload(node,0),
@@ -245,7 +245,7 @@ INFO_TABLE(stg_ap_6_upd,6,0,THUNK,"stg_ap_6_upd_info","stg_ap_6_upd_info")
     STK_CHK_NP(node);
     UPD_BH_UPDATABLE(node);
     LDV_ENTER(node);
-    push (UPDATE_FRAME_FIELDS(,,stg_upd_frame_info, CCCS, node)) {
+    push (UPDATE_FRAME_FIELDS(,,stg_upd_frame_info, CCCS, 0, node)) {
         ENTER_CCS_THUNK(node);
         jump stg_ap_ppppp_fast
             (StgThunk_payload(node,0),
@@ -264,7 +264,7 @@ INFO_TABLE(stg_ap_7_upd,7,0,THUNK,"stg_ap_7_upd_info","stg_ap_7_upd_info")
     STK_CHK_NP(node);
     UPD_BH_UPDATABLE(node);
     LDV_ENTER(node);
-    push (UPDATE_FRAME_FIELDS(,,stg_upd_frame_info, CCCS, node)) {
+    push (UPDATE_FRAME_FIELDS(,,stg_upd_frame_info, CCCS, 0, node)) {
       ENTER_CCS_THUNK(node);
       jump stg_ap_pppppp_fast
           (StgThunk_payload(node,0),
index bd6060f..01eb682 100644 (file)
@@ -26,7 +26,7 @@
  * we don't mind duplicating this jump.
  */
 INFO_TABLE_RET ( stg_upd_frame, UPDATE_FRAME,
-                 UPDATE_FRAME_FIELDS(W_,P_,info_ptr,_ccs,updatee) )
+                 UPDATE_FRAME_FIELDS(W_,P_,info_ptr,_ccs,_unused,updatee) )
     return (P_ ret) /* the closure being returned */
 {
     /* ToDo: it might be a PAP, so we should check... */
@@ -42,7 +42,7 @@ INFO_TABLE_RET ( stg_upd_frame, UPDATE_FRAME,
  * another thread in the meantime.
  */
 INFO_TABLE_RET ( stg_marked_upd_frame, UPDATE_FRAME,
-                 UPDATE_FRAME_FIELDS(W_,P_,info_ptr,_ccs,updatee) )
+                 UPDATE_FRAME_FIELDS(W_,P_,info_ptr,_ccs,_unused,updatee) )
     return (P_ ret) /* the closure being returned */
 {
     W_ v, i, tso, link;
@@ -77,11 +77,11 @@ INFO_TABLE_RET ( stg_marked_upd_frame, UPDATE_FRAME,
  * high watermark.
  */
 INFO_TABLE_RET ( stg_bh_upd_frame, UPDATE_FRAME,
-                 UPDATE_FRAME_FIELDS(W_,P_,info_ptr,ccs,updatee) )
+                 UPDATE_FRAME_FIELDS(W_,P_,info_ptr,ccs,_unused,updatee) )
     return (P_ ret) /* the closure being returned */
 {
     // This all compiles away to a single jump instruction (sigh)
     jump RET_LBL(stg_marked_upd_frame)
-        ( UPDATE_FRAME_FIELDS(,,info_ptr,ccs,updatee) )
+        ( UPDATE_FRAME_FIELDS(,,info_ptr,ccs,_unused,updatee) )
         (ret);
 }
index c65af9a..b4ff7d1 100644 (file)
@@ -35,9 +35,9 @@
  */
 #ifdef CMINUSMINUS
 
-#define UPDATE_FRAME_FIELDS(w_,p_,info_ptr,ccs,updatee) \
+#define UPDATE_FRAME_FIELDS(w_,p_,info_ptr,ccs,p2,updatee)      \
                  w_ info_ptr,                           \
-                 PROF_HDR_FIELDS_(w_,ccs,_unused_)      \
+                 PROF_HDR_FIELDS(w_,ccs,p2)              \
                  p_ updatee