[commit: ghc] master: Rts: Reuse scavenge_small_bitmap (#8742) (05fcc33)

git at git.haskell.org git at git.haskell.org
Tue Apr 29 19:35:20 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/05fcc3331622995015ccba17ae333b9a0fc9bb77/ghc

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

commit 05fcc3331622995015ccba17ae333b9a0fc9bb77
Author: Arash Rouhani <rarash at student.chalmers.se>
Date:   Thu Feb 6 09:10:03 2014 +0100

    Rts: Reuse scavenge_small_bitmap (#8742)
    
    The function was inlined at two places already. And the function is
    having the STATIC_INLINE annotation, so the assembly output should.
    be the same.
    
    To convince myself, I did diff the output of the object files before
    and after the patch and they matched on my 64-bit Ubuntu 13.10 machine,
    running gcc 4.8.1-10ubuntu9.
    
    Also, I had to move scavenge_small_bitmap up a bit since it's not in any
    .h-file.
    
    While I was at it, I also applied the analogous patch for Compact.c.
    Though I had to write `thread_small_bitmap` instead of just moving it.


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

05fcc3331622995015ccba17ae333b9a0fc9bb77
 rts/sm/Compact.c |   41 +++++++++++++++++------------------------
 rts/sm/Scav.c    |   45 ++++++++++++++++-----------------------------
 2 files changed, 33 insertions(+), 53 deletions(-)

diff --git a/rts/sm/Compact.c b/rts/sm/Compact.c
index 3731dd6..b07a886 100644
--- a/rts/sm/Compact.c
+++ b/rts/sm/Compact.c
@@ -248,6 +248,20 @@ thread_large_bitmap( StgPtr p, StgLargeBitmap *large_bitmap, StgWord size )
 }
 
 STATIC_INLINE StgPtr
+thread_small_bitmap (StgPtr p, StgWord size, StgWord bitmap)
+{
+    while (size > 0) {
+        if ((bitmap & 1) == 0) {
+            thread((StgClosure **)p);
+        }
+        p++;
+        bitmap = bitmap >> 1;
+        size--;
+    }
+    return p;
+}
+
+STATIC_INLINE StgPtr
 thread_arg_block (StgFunInfoTable *fun_info, StgClosure **args)
 {
     StgPtr p;
@@ -269,14 +283,7 @@ thread_arg_block (StgFunInfoTable *fun_info, StgClosure **args)
 	bitmap = BITMAP_BITS(stg_arg_bitmaps[fun_info->f.fun_type]);
 	size = BITMAP_SIZE(stg_arg_bitmaps[fun_info->f.fun_type]);
     small_bitmap:
-	while (size > 0) {
-	    if ((bitmap & 1) == 0) {
-		thread((StgClosure **)p);
-	    }
-	    p++;
-	    bitmap = bitmap >> 1;
-	    size--;
-	}
+        p = thread_small_bitmap(p, size, bitmap);
 	break;
     }
     return p;
@@ -315,14 +322,7 @@ thread_stack(StgPtr p, StgPtr stack_end)
 	    p++;
 	    // NOTE: the payload starts immediately after the info-ptr, we
 	    // don't have an StgHeader in the same sense as a heap closure.
-	    while (size > 0) {
-		if ((bitmap & 1) == 0) {
-		    thread((StgClosure **)p);
-		}
-		p++;
-		bitmap = bitmap >> 1;
-		size--;
-	    }
+            p = thread_small_bitmap(p, size, bitmap);
 	    continue;
 
 	case RET_BCO: {
@@ -394,14 +394,7 @@ thread_PAP_payload (StgClosure *fun, StgClosure **payload, StgWord size)
     default:
 	bitmap = BITMAP_BITS(stg_arg_bitmaps[fun_info->f.fun_type]);
     small_bitmap:
-	while (size > 0) {
-	    if ((bitmap & 1) == 0) {
-		thread((StgClosure **)p);
-	    }
-	    p++;
-	    bitmap = bitmap >> 1;
-	    size--;
-	}
+        p = thread_small_bitmap(p, size, bitmap);
 	break;
     }
 
diff --git a/rts/sm/Scav.c b/rts/sm/Scav.c
index 5cf4cfa..b9f8f12 100644
--- a/rts/sm/Scav.c
+++ b/rts/sm/Scav.c
@@ -168,6 +168,20 @@ static StgPtr scavenge_mut_arr_ptrs_marked (StgMutArrPtrs *a)
     return (StgPtr)a + mut_arr_ptrs_sizeW(a);
 }
 
+STATIC_INLINE StgPtr
+scavenge_small_bitmap (StgPtr p, StgWord size, StgWord bitmap)
+{
+    while (size > 0) {
+        if ((bitmap & 1) == 0) {
+            evacuate((StgClosure **)p);
+        }
+        p++;
+        bitmap = bitmap >> 1;
+        size--;
+    }
+    return p;
+}
+
 /* -----------------------------------------------------------------------------
    Blocks of function args occur on the stack (at the top) and
    in PAPs.
@@ -195,14 +209,7 @@ scavenge_arg_block (StgFunInfoTable *fun_info, StgClosure **args)
 	bitmap = BITMAP_BITS(stg_arg_bitmaps[fun_info->f.fun_type]);
 	size = BITMAP_SIZE(stg_arg_bitmaps[fun_info->f.fun_type]);
     small_bitmap:
-	while (size > 0) {
-	    if ((bitmap & 1) == 0) {
-		evacuate((StgClosure **)p);
-	    }
-	    p++;
-	    bitmap = bitmap >> 1;
-	    size--;
-	}
+        p = scavenge_small_bitmap(p, size, bitmap);
 	break;
     }
     return p;
@@ -234,14 +241,7 @@ scavenge_PAP_payload (StgClosure *fun, StgClosure **payload, StgWord size)
     default:
 	bitmap = BITMAP_BITS(stg_arg_bitmaps[fun_info->f.fun_type]);
     small_bitmap:
-	while (size > 0) {
-	    if ((bitmap & 1) == 0) {
-		evacuate((StgClosure **)p);
-	    }
-	    p++;
-	    bitmap = bitmap >> 1;
-	    size--;
-	}
+        p = scavenge_small_bitmap(p, size, bitmap);
 	break;
     }
     return p;
@@ -1765,19 +1765,6 @@ scavenge_large_bitmap( StgPtr p, StgLargeBitmap *large_bitmap, StgWord size )
     }
 }
 
-STATIC_INLINE StgPtr
-scavenge_small_bitmap (StgPtr p, StgWord size, StgWord bitmap)
-{
-    while (size > 0) {
-	if ((bitmap & 1) == 0) {
-	    evacuate((StgClosure **)p);
-	}
-	p++;
-	bitmap = bitmap >> 1;
-	size--;
-    }
-    return p;
-}
 
 /* -----------------------------------------------------------------------------
    scavenge_stack walks over a section of stack and evacuates all the



More information about the ghc-commits mailing list