summaryrefslogtreecommitdiff
path: root/compiler/GHC
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2021-02-02 14:41:41 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-02-05 19:12:01 -0500
commitfe789978453bfd4e5ff456a6be57fc8041664d75 (patch)
tree4be620f0225abd40ed292744cdeed6c17134b25c /compiler/GHC
parent003df39c8103823d8aac4b65f0e06cf49580f5e8 (diff)
downloadhaskell-fe789978453bfd4e5ff456a6be57fc8041664d75.tar.gz
IntVar: fix allocation size
As found by @phadej in https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4740/diffs#note_327510 Also fix FastMutInt which allocating the size in bits instead of bytes.
Diffstat (limited to 'compiler/GHC')
-rw-r--r--compiler/GHC/Data/FastMutInt.hs4
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/GHC/Data/FastMutInt.hs b/compiler/GHC/Data/FastMutInt.hs
index cc81b88b01..d7b8072b2c 100644
--- a/compiler/GHC/Data/FastMutInt.hs
+++ b/compiler/GHC/Data/FastMutInt.hs
@@ -34,7 +34,7 @@ data FastMutInt = FastMutInt (MutableByteArray# RealWorld)
newFastMutInt = IO $ \s ->
case newByteArray# size s of { (# s, arr #) ->
(# s, FastMutInt arr #) }
- where !(I# size) = finiteBitSize (0 :: Int)
+ where !(I# size) = finiteBitSize (0 :: Int) `unsafeShiftR` 3
readFastMutInt (FastMutInt arr) = IO $ \s ->
case readIntArray# arr 0# s of { (# s, i #) ->
@@ -50,7 +50,7 @@ newFastMutPtr = IO $ \s ->
case newByteArray# size s of { (# s, arr #) ->
(# s, FastMutPtr arr #) }
-- GHC assumes 'sizeof (Int) == sizeof (Ptr a)'
- where !(I# size) = finiteBitSize (0 :: Int)
+ where !(I# size) = finiteBitSize (0 :: Int) `unsafeShiftR` 3
readFastMutPtr (FastMutPtr arr) = IO $ \s ->
case readAddrArray# arr 0# s of { (# s, i #) ->