[Git][ghc/ghc][wip/keepAlive-optionB] base: Make ForeignPtrContents of ForeignPtr strict

Ben Gamari gitlab at gitlab.haskell.org
Thu Sep 10 15:48:21 UTC 2020



Ben Gamari pushed to branch wip/keepAlive-optionB at Glasgow Haskell Compiler / GHC


Commits:
03b1daef by GHC GitLab CI at 2020-09-10T15:48:13+00:00
base: Make ForeignPtrContents of ForeignPtr strict

As mentioned in #17290, there are strong benefits to the
`ForeignPtrContents` field of `ForeignPtr` being strict. In particular,
when looking at the reproducer for #17746, I noticed that the
`ForeignPtrContents` was being allocated on every call to
`withForeignPtr` just to be `touch#`'d'. This is a pretty large
overhead for something like `withForeignPtr` that should be free.

This required updating the `bytestring` submodule to avoid a bottoming
`ForeignPtrContents` in `Data.ByteString.Internal`

Fixes #17290.

- - - - -


2 changed files:

- libraries/base/GHC/ForeignPtr.hs
- libraries/bytestring


Changes:

=====================================
libraries/base/GHC/ForeignPtr.hs
=====================================
@@ -83,7 +83,7 @@ import Unsafe.Coerce    ( unsafeCoerce, unsafeCoerceUnlifted )
 -- type argument of 'ForeignPtr' should normally be an instance of
 -- class 'Storable'.
 --
-data ForeignPtr a = ForeignPtr Addr# ForeignPtrContents
+data ForeignPtr a = ForeignPtr Addr# !ForeignPtrContents
         -- The Addr# in the ForeignPtr object is intentionally stored
         -- separately from the finalizer. The primary aim of the
         -- representation is to make withForeignPtr efficient; in fact,


=====================================
libraries/bytestring
=====================================
@@ -1 +1 @@
-Subproject commit e6cb01e2ec0bfdd19298418c85f220925a9fa307
+Subproject commit cff1ad3422ed463cf92ea996b276da9156200bbf



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/03b1daef7b206c7ad66b8a417381a90b0070d28e

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/03b1daef7b206c7ad66b8a417381a90b0070d28e
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/20200910/5118e407/attachment-0001.html>


More information about the ghc-commits mailing list