From d4e0cee2445d9845bb7b0a0687bad84ff32bac28 Mon Sep 17 00:00:00 2001
From: simonm <unknown>
Date: Fri, 26 Mar 1999 10:29:08 +0000
Subject: [PATCH] [project @ 1999-03-26 10:29:02 by simonm] More profiling
 fixes.

---
 ghc/compiler/codeGen/CgUpdate.lhs |  9 ++++++---
 ghc/compiler/main/Constants.lhs   |  6 +++++-
 ghc/includes/Constants.h          | 17 +++++------------
 ghc/rts/GC.c                      | 10 +++++-----
 ghc/rts/StgStdThunks.hc           |  4 +++-
 ghc/rts/Updates.hc                | 12 ++++--------
 6 files changed, 28 insertions(+), 30 deletions(-)

diff --git a/ghc/compiler/codeGen/CgUpdate.lhs b/ghc/compiler/codeGen/CgUpdate.lhs
index 9164a2edefaa..1eec8f6be916 100644
--- a/ghc/compiler/codeGen/CgUpdate.lhs
+++ b/ghc/compiler/codeGen/CgUpdate.lhs
@@ -11,7 +11,7 @@ module CgUpdate ( pushUpdateFrame, reserveSeqFrame, pushSeqFrame ) where
 import CgMonad
 import AbsCSyn
 
-import Constants	( uF_SIZE, sCC_UF_SIZE, sEQ_FRAME_SIZE )
+import Constants	( uF_SIZE, sCC_UF_SIZE, sEQ_FRAME_SIZE, sCC_SEQ_FRAME_SIZE )
 import PrimRep		( PrimRep(..) )
 import CgStackery	( allocUpdateFrame )
 import CgUsages		( getSpRelOffset )
@@ -71,13 +71,16 @@ args_sp.  When the scrutinee comes around to pushing a return address,
 it will also push the SEQ frame, using pushSeqFrame.
 
 \begin{code}
+seq_frame_size | opt_SccProfilingOn = sCC_SEQ_FRAME_SIZE
+	       | otherwise          = sEQ_FRAME_SIZE
+
 reserveSeqFrame :: EndOfBlockInfo -> EndOfBlockInfo
 reserveSeqFrame (EndOfBlockInfo args_sp (CaseAlts amode stuff)) 
-  = EndOfBlockInfo (args_sp + sEQ_FRAME_SIZE) (SeqFrame amode stuff)
+  = EndOfBlockInfo (args_sp + seq_frame_size) (SeqFrame amode stuff)
 
 pushSeqFrame :: VirtualSpOffset -> FCode VirtualSpOffset
 pushSeqFrame args_sp
   = getSpRelOffset args_sp  `thenFC` \ sp_rel ->
     absC (CMacroStmt PUSH_SEQ_FRAME [CAddr sp_rel]) `thenC`
-    returnFC (args_sp - sEQ_FRAME_SIZE)
+    returnFC (args_sp - seq_frame_size)
 \end{code}
diff --git a/ghc/compiler/main/Constants.lhs b/ghc/compiler/main/Constants.lhs
index eca728d3c3fa..5b52a37bf0c2 100644
--- a/ghc/compiler/main/Constants.lhs
+++ b/ghc/compiler/main/Constants.lhs
@@ -50,6 +50,7 @@ module Constants (
 	uF_CCS,
 
 	sEQ_FRAME_SIZE,
+	sCC_SEQ_FRAME_SIZE,
 
 	mAX_Vanilla_REG,
 	mAX_Float_REG,
@@ -186,8 +187,11 @@ uF_UPDATEE     = (UF_UPDATEE::Int)
 uF_CCS         = (UF_CCS::Int)
 \end{code}
 
+Seq frame sizes.
+
 \begin{code}
-sEQ_FRAME_SIZE = (SEQ_FRAME_SIZE::Int)
+sEQ_FRAME_SIZE = (NOSCC_SEQ_FRAME_SIZE::Int)
+sCC_SEQ_FRAME_SIZE = (SCC_SEQ_FRAME_SIZE::Int)
 \end{code}
 
 \begin{code}
diff --git a/ghc/includes/Constants.h b/ghc/includes/Constants.h
index 2e2c37bbe276..12b6d0d14dfb 100644
--- a/ghc/includes/Constants.h
+++ b/ghc/includes/Constants.h
@@ -1,5 +1,5 @@
 /* ----------------------------------------------------------------------------
- * $Id: Constants.h,v 1.5 1999/02/05 16:02:21 simonm Exp $
+ * $Id: Constants.h,v 1.6 1999/03/26 10:29:02 simonm Exp $
  *
  * (c) The GHC Team, 1998-1999
  *
@@ -103,12 +103,6 @@
 #define NOSCC_UF_SIZE 	3
 #define SCC_UF_SIZE	4
 
-#if defined(PROFILING)
-#define UF_SIZE	SCC_UF_SIZE
-#else
-#define UF_SIZE NOSCC_UF_SIZE
-#endif
-
 #define UF_RET		0
 #define UF_SU		1
 #define UF_UPDATEE	2
@@ -116,13 +110,12 @@
 
 /* -----------------------------------------------------------------------------
    SEQ frame size
+
+   I don't think seq frames really need sccs --SDM
    -------------------------------------------------------------------------- */
 
-#if defined(PROFILING)
-#define SEQ_FRAME_SIZE 3
-#else
-#define SEQ_FRAME_SIZE 2
-#endif
+#define NOSCC_SEQ_FRAME_SIZE 2
+#define SCC_SEQ_FRAME_SIZE   3
 
 /* -----------------------------------------------------------------------------
    STG Registers.
diff --git a/ghc/rts/GC.c b/ghc/rts/GC.c
index b56f995411d7..05728ca3eaa7 100644
--- a/ghc/rts/GC.c
+++ b/ghc/rts/GC.c
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: GC.c,v 1.56 1999/03/25 13:14:05 simonm Exp $
+ * $Id: GC.c,v 1.57 1999/03/26 10:29:04 simonm Exp $
  *
  * (c) The GHC Team 1998-1999
  *
@@ -2313,10 +2313,10 @@ scavenge_stack(StgPtr p, StgPtr stack_end)
    */
 
   while (p < stack_end) {
-    q = *stgCast(StgPtr*,p);
+    q = *(P_ *)p;
 
     /* If we've got a tag, skip over that many words on the stack */
-    if (IS_ARG_TAG(stgCast(StgWord,q))) {
+    if (IS_ARG_TAG((W_)q)) {
       p += ARG_SIZE(q);
       p++; continue;
     }
@@ -2342,14 +2342,14 @@ scavenge_stack(StgPtr p, StgPtr stack_end)
      * record.  All activation records have 'bitmap' style layout
      * info.
      */
-    info  = get_itbl(stgCast(StgClosure*,p));
+    info  = get_itbl((StgClosure *)p);
       
     switch (info->type) {
 	
       /* Dynamic bitmap: the mask is stored on the stack */
     case RET_DYN:
       bitmap = ((StgRetDyn *)p)->liveness;
-      p      = (P_)((StgRetDyn *)p)->payload[0];
+      p      = (P_)&((StgRetDyn *)p)->payload[0];
       goto small_bitmap;
 
       /* probably a slow-entry point return address: */
diff --git a/ghc/rts/StgStdThunks.hc b/ghc/rts/StgStdThunks.hc
index b7cac13f6adc..9af09771a4c9 100644
--- a/ghc/rts/StgStdThunks.hc
+++ b/ghc/rts/StgStdThunks.hc
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: StgStdThunks.hc,v 1.3 1999/02/05 16:03:00 simonm Exp $
+ * $Id: StgStdThunks.hc,v 1.4 1999/03/26 10:29:05 simonm Exp $
  *
  * (c) The GHC Team, 1998-1999
  *
@@ -145,6 +145,8 @@ FN_(__ap_6_upd_entry);
 FN_(__ap_7_upd_entry);
 FN_(__ap_8_upd_entry);
 
+#define UF_SIZE (sizeofW(StgUpdateFrame))
+
 /* __ap_1_upd_info is a bit redundant, but there appears to be a bug
  * in the compiler that means __ap_1 is generated occasionally (ToDo)
  */
diff --git a/ghc/rts/Updates.hc b/ghc/rts/Updates.hc
index e0dd5c28a0ec..f5f692811f71 100644
--- a/ghc/rts/Updates.hc
+++ b/ghc/rts/Updates.hc
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: Updates.hc,v 1.12 1999/03/25 13:14:08 simonm Exp $
+ * $Id: Updates.hc,v 1.13 1999/03/26 10:29:06 simonm Exp $
  *
  * (c) The GHC Team, 1998-1999
  *
@@ -227,11 +227,7 @@ EXTFUN(stg_update_PAP)
 
 #if defined(PROFILING)
     /* set "CC_pap" to go in the updatee (see Sansom thesis, p 183) */
-
-    CCS_pap = (CostCentreStack *) Fun->header.prof.ccs;
-    if (IS_CAF_OR_SUB_CCS(CCS_pap)) {
-	CCS_pap = CCCS;
-    }
+    CCS_pap = Fun->header.prof.ccs;
 #endif
 
     if (Words == 0) { 
@@ -467,7 +463,7 @@ SEQ_FRAME_ENTRY_TEMPLATE(seq_frame_5_entry,ENTRY_CODE(Sp[0]));
 SEQ_FRAME_ENTRY_TEMPLATE(seq_frame_6_entry,ENTRY_CODE(Sp[0]));
 SEQ_FRAME_ENTRY_TEMPLATE(seq_frame_7_entry,ENTRY_CODE(Sp[0]));
 
-VEC_POLY_INFO_TABLE(seq_frame,1, NULL/*srt*/, 0/*srt_off*/, 0/*srt_len*/, SEQ_FRAME);
+VEC_POLY_INFO_TABLE(seq_frame, UPD_FRAME_BITMAP, NULL/*srt*/, 0/*srt_off*/, 0/*srt_len*/, SEQ_FRAME);
 
 /* -----------------------------------------------------------------------------
  * The seq infotable
@@ -485,7 +481,7 @@ STGFUN(seq_entry)
 {
   FB_
   STK_CHK_GEN(sizeofW(StgSeqFrame), NO_PTRS, seq_entry, );
-  Sp -= sizeof(StgSeqFrame);
+  Sp -= sizeofW(StgSeqFrame);
   PUSH_SEQ_FRAME(Sp);
   R1.cl = R1.cl->payload[0];
   JMP_(ENTRY_CODE(*R1.p));         
-- 
GitLab