[Git][ghc/ghc][wip/T22264] nonmoving: Allow pinned gen0 objects to be WEAK keys

Ben Gamari (@bgamari) gitlab at gitlab.haskell.org
Wed Dec 21 23:32:49 UTC 2022



Ben Gamari pushed to branch wip/T22264 at Glasgow Haskell Compiler / GHC


Commits:
46a50843 by Ben Gamari at 2022-12-19T21:59:13-05:00
nonmoving: Allow pinned gen0 objects to be WEAK keys

- - - - -


1 changed file:

- rts/sm/NonMovingMark.c


Changes:

=====================================
rts/sm/NonMovingMark.c
=====================================
@@ -1915,16 +1915,26 @@ static bool nonmovingIsNowAlive (StgClosure *p)
 
     bdescr *bd = Bdescr((P_)p);
 
-    // All non-static objects in the non-moving heap should be marked as
-    // BF_NONMOVING
-    ASSERT(bd->flags & BF_NONMOVING);
+    const uint16_t flags = bd->flags;
+    if (flags & BF_LARGE) {
+        if (flags & BF_PINNED && !(flags & BF_NONMOVING)) {
+            // In this case we have a pinned object living in a non-full
+            // accumulator block which was not promoted to the nonmoving
+            // generation. Assume that the object is alive.
+            // See #22014.
+            return true;
+        }
 
-    if (bd->flags & BF_LARGE) {
+        ASSERT(bd->flags & BF_NONMOVING);
         return (bd->flags & BF_NONMOVING_SWEEPING) == 0
                    // the large object wasn't in the snapshot and therefore wasn't marked
             || (bd->flags & BF_MARKED) != 0;
                    // The object was marked
     } else {
+        // All non-static objects in the non-moving heap should be marked as
+        // BF_NONMOVING.
+        ASSERT(bd->flags & BF_NONMOVING);
+
         struct NonmovingSegment *seg = nonmovingGetSegment((StgPtr) p);
         StgClosure *snapshot_loc =
           (StgClosure *) nonmovingSegmentGetBlock(seg, nonmovingSegmentInfo(seg)->next_free_snap);



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/46a5084349b7fcb6ad602308c07e32aa07cc2787

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/46a5084349b7fcb6ad602308c07e32aa07cc2787
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20221221/01509760/attachment-0001.html>


More information about the ghc-commits mailing list