[project @ 2003-06-19 12:47:08 by simonmar]
authorsimonmar <unknown>
Thu, 19 Jun 2003 12:47:08 +0000 (12:47 +0000)
committersimonmar <unknown>
Thu, 19 Jun 2003 12:47:08 +0000 (12:47 +0000)
small optimisation: when evacuating a TSO, only copy the part of the
stack that is above the stack pointer and hence in use (doesn't apply
to most stacks, which are large objects and don't get copied anyhow).

ghc/rts/GC.c

index 3ab057a..567597c 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: GC.c,v 1.155 2003/05/14 09:13:59 simonmar Exp $
+ * $Id: GC.c,v 1.156 2003/06/19 12:47:08 simonmar Exp $
  *
  * (c) The GHC Team 1998-2003
  *
@@ -1930,8 +1930,18 @@ loop:
        * list it contains.  
        */
       {
-         StgTSO *new_tso = (StgTSO *)copy((StgClosure *)tso,tso_sizeW(tso),stp);
+         StgTSO *new_tso;
+         StgPtr p, q;
+
+         new_tso = (StgTSO *)copyPart((StgClosure *)tso,
+                                      tso_sizeW(tso),
+                                      sizeofW(StgTSO), stp);
          move_TSO(tso, new_tso);
+         for (p = tso->sp, q = new_tso->sp;
+              p < tso->stack+tso->stack_size;) {
+             *q++ = *p++;
+         }
+         
          return (StgClosure *)new_tso;
       }
     }
@@ -2165,7 +2175,7 @@ move_TSO (StgTSO *src, StgTSO *dest)
 {
     ptrdiff_t diff;
 
-    // relocate the stack pointers... 
+    // relocate the stack pointer... 
     diff = (StgPtr)dest - (StgPtr)src; // In *words* 
     dest->sp = (StgPtr)dest->sp + diff;
 }