[commit: ghc] master: Fix gcCAFs() (e431d75)

git at git.haskell.org git at git.haskell.org
Fri Jul 27 17:43:36 UTC 2018


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

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

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

commit e431d75f8350f25159f9aaa49fe9a504e94bc0a4
Author: Simon Marlow <marlowsd at gmail.com>
Date:   Thu Jul 26 17:19:54 2018 -0400

    Fix gcCAFs()
    
    The test here should have been changed after D1106.  It was harmless
    but we caught fewer GC'd CAFs than we should have.
    
    Test Plan:
    Using `nofib/imaginary/primes` compiled with `-debug`.
    
    Before:
    ```
    > ./primes 100 +RTS -G1 -A32k -DG
    CAF gc'd at 0x0x7b0960
    CAF gc'd at 0x0x788728
    CAF gc'd at 0x0x790db0
    CAF gc'd at 0x0x790de0
    12 CAFs live
    CAF gc'd at 0x0x788880
    12 CAFs live
    12 CAFs live
    12 CAFs live
    12 CAFs live
    12 CAFs live
    12 CAFs live
    12 CAFs live
    12 CAFs live
    12 CAFs live
    12 CAFs live
    12 CAFs live
    547
    CAF gc'd at 0x0x7995c8
    13 CAFs live
    ```
    
    After:
    
    ```
    > ./primes 100 +RTS -G1 -A32k -DG
    CAF gc'd at 0x0x7b0960
    CAF gc'd at 0x0x788728
    CAF gc'd at 0x0x790db0
    CAF gc'd at 0x0x790de0
    12 CAFs live
    CAF gc'd at 0x0x788880
    12 CAFs live
    12 CAFs live
    12 CAFs live
    12 CAFs live
    12 CAFs live
    12 CAFs live
    12 CAFs live
    12 CAFs live
    12 CAFs live
    12 CAFs live
    12 CAFs live
    547
    CAF gc'd at 0x0x7995c8
    CAF gc'd at 0x0x790ea0
    12 CAFs live
    ```
    
    Reviewers: bgamari, osa1, erikd, noamz
    
    Reviewed By: bgamari
    
    Subscribers: rwbarton, thomie, carter
    
    Differential Revision: https://phabricator.haskell.org/D4963


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

e431d75f8350f25159f9aaa49fe9a504e94bc0a4
 rts/sm/GC.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/rts/sm/GC.c b/rts/sm/GC.c
index 67eba93..742ae36 100644
--- a/rts/sm/GC.c
+++ b/rts/sm/GC.c
@@ -1846,7 +1846,10 @@ static void gcCAFs(void)
         info = get_itbl((StgClosure*)p);
         ASSERT(info->type == IND_STATIC);
 
-        if (p->static_link == NULL) {
+        // See Note [STATIC_LINK fields] in Storage.h
+        // This condition identifies CAFs that have just been GC'd and
+        // don't have static_link==3 which means they should be ignored.
+        if ((((StgWord)(p->static_link)&STATIC_BITS) | prev_static_flag) != 3) {
             debugTrace(DEBUG_gccafs, "CAF gc'd at 0x%p", p);
             SET_INFO((StgClosure*)p,&stg_GCD_CAF_info); // stub it
             if (prev == NULL) {



More information about the ghc-commits mailing list