[project @ 2002-03-12 11:50:02 by simonmar]
[ghc-hetmet.git] / ghc / rts / Updates.hc
index 4e3b046..45e00de 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: Updates.hc,v 1.30 2000/11/14 12:47:38 simonmar Exp $
+ * $Id: Updates.hc,v 1.37 2001/11/28 14:29:33 simonmar Exp $
  *
  * (c) The GHC Team, 1998-1999
  *
@@ -7,10 +7,10 @@
  *
  * ---------------------------------------------------------------------------*/
 
+#include "Stg.h"
 #include "Rts.h"
 #include "RtsUtils.h"
 #include "RtsFlags.h"
-#include "HeapStackCheck.h"
 #include "Storage.h"
 #if defined(GRAN) || defined(PAR)
 # include "FetchMe.h"
@@ -117,8 +117,8 @@ UPD_FRAME_ENTRY_TEMPLATE(stg_upd_frame_7_entry,RET_VEC(Sp[0],7));
   return size!
   */
 
-#ifdef PROFILING
-#define UPD_FRAME_BITMAP 3
+#if defined(PROFILING)
+#define UPD_FRAME_BITMAP 7
 #else
 #define UPD_FRAME_BITMAP 1
 #endif
@@ -207,6 +207,7 @@ STGFUN(stg_PAP_entry)
   Sp -= Words;
 
   TICK_ENT_PAP(pap);
+  LDV_ENTER(pap);
 
   /* Enter PAP cost centre -- lexical scoping only */
   ENTER_CCS_PAP_CL(pap);
@@ -229,7 +230,7 @@ STGFUN(stg_PAP_entry)
    This function is called whenever an argument satisfaction check fails.
    -------------------------------------------------------------------------- */
 
-EXTFUN(stg_update_PAP)
+EXTFUN(__stg_update_PAP)
 {
   nat Words, PapSize;
 #ifdef PROFILING
@@ -286,15 +287,14 @@ EXTFUN(stg_update_PAP)
         * such as removing the update frame.
         */
        if ((Hp += PapSize) > HpLim) {
+         HpAlloc = PapSize;
          Sp -= 1;
          Sp[0] = (W_)Fun;          
          JMP_(stg_gc_entertop);
        }
 
        TICK_ALLOC_UPD_PAP(1/*fun*/ + Words, 0);
-#ifdef PROFILING
        CCS_ALLOC(CCS_pap, PapSize);
-#endif
 
        PapClosure = (StgPAP *)(Hp + 1 - PapSize); /* The new PapClosure */
 
@@ -305,7 +305,7 @@ EXTFUN(stg_update_PAP)
        /* Now fill in the closure fields */
 
        p = Hp;
-        for (i = Words-1; i >= 0; i--) {
+        for (i = Words; --i >= 0; ) {
           *p-- = (W_) Sp[i];
        }
     }
@@ -351,7 +351,7 @@ EXTFUN(stg_update_PAP)
       
       Updatee = Su->updatee; 
 
-#if defined(PROFILING)
+#if defined(PROFILING) 
       if (Words != 0) {
         UPD_IND(Updatee,PapClosure);
        TICK_UPD_PAP_IN_NEW(Words+1);
@@ -383,7 +383,7 @@ EXTFUN(stg_update_PAP)
       /* 
        * Squeeze out update frame from stack.
        */
-      for (i = Words-1; i >= 0; i--) {
+      for (i = Words; --i >= 0; ) {
        Sp[i+(sizeofW(StgUpdateFrame))] = Sp[i];
       }
       Sp += sizeofW(StgUpdateFrame);
@@ -430,12 +430,13 @@ STGFUN(stg_AP_UPD_entry)
   /* 
    * Check for stack overflow.
    */
-  STK_CHK(Words+sizeofW(StgUpdateFrame),stg_AP_UPD_entry,R2.p,1,);
+  STK_CHK_GEN(Words+sizeofW(StgUpdateFrame), R1_PTR, stg_AP_UPD_entry, );
 
   PUSH_UPD_FRAME(R1.p, 0);
   Sp -= sizeofW(StgUpdateFrame) + Words;
 
   TICK_ENT_AP_UPD(ap);
+  LDV_ENTER(ap);
 
   /* Enter PAP cost centre -- lexical scoping only */
   ENTER_CCS_PAP_CL(ap);   /* ToDo: ENTER_CC_AP_UPD_CL */