diff options
author | Ömer Sinan Ağacan <omeragacan@gmail.com> | 2019-08-15 14:37:59 +0300 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-10-03 12:17:19 -0400 |
commit | 8a254d6bf46e93285894593da38ef8e5bb8bf206 (patch) | |
tree | 25c19eebf40c8100a4e36c0e568db0655841e1f0 /libraries/ghc-compact | |
parent | 3b9d4907582e6d167cb7e7a8b1011ad3b0bf646b (diff) | |
download | haskell-8a254d6bf46e93285894593da38ef8e5bb8bf206.tar.gz |
Fix new compact block allocation in allocateForCompact
allocateForCompact() is called when nursery of a compact region is
full, to add new blocks to the compact. New blocks added to an existing
region needs a StgCompactNFDataBlock header, not a StgCompactNFData.
This fixes allocateForCompact() so that it now correctly allocates space
for StgCompactNFDataBlock instead of StgCompactNFData as before.
Fixes #17044.
A regression test T17044 added.
Diffstat (limited to 'libraries/ghc-compact')
-rw-r--r-- | libraries/ghc-compact/tests/T17044.hs | 30 | ||||
-rw-r--r-- | libraries/ghc-compact/tests/all.T | 1 |
2 files changed, 31 insertions, 0 deletions
diff --git a/libraries/ghc-compact/tests/T17044.hs b/libraries/ghc-compact/tests/T17044.hs new file mode 100644 index 0000000000..1e4a73f5a6 --- /dev/null +++ b/libraries/ghc-compact/tests/T17044.hs @@ -0,0 +1,30 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE UnboxedTuples #-} + +import Data.Traversable (for) +import GHC.Compact +import GHC.Exts +import GHC.IO + +main :: IO () +main = do + c <- compact () + big <- newByteArray 1032128 + bigFrozen <- unsafeFreezeByteArray big + c' <- compactAdd c bigFrozen + + _placeholders <- for [0 :: Int .. 2044] $ \i -> do + getCompact <$> compactAdd c' i + + return () + +data ByteArray = ByteArray ByteArray# + +data MutableByteArray s = MutableByteArray (MutableByteArray# s) + +newByteArray :: Int -> IO (MutableByteArray RealWorld) +newByteArray (I# n#) = IO (\s# -> case newByteArray# n# s# of (# s'#, arr# #) -> (# s'#, MutableByteArray arr# #)) + +unsafeFreezeByteArray :: MutableByteArray RealWorld -> IO ByteArray +unsafeFreezeByteArray (MutableByteArray arr#) = IO (\s# -> case unsafeFreezeByteArray# arr# s# of (# s'#, arr'# #) -> (# s'#, ByteArray arr'# #)) diff --git a/libraries/ghc-compact/tests/all.T b/libraries/ghc-compact/tests/all.T index ec0d20fe05..4a1bab9336 100644 --- a/libraries/ghc-compact/tests/all.T +++ b/libraries/ghc-compact/tests/all.T @@ -21,3 +21,4 @@ test('compact_share', omit_ways(['ghci', 'profasm', 'profthreaded']), compile_and_run, ['']) test('compact_bench', [ ignore_stdout, extra_run_opts('100') ], compile_and_run, ['']) +test('T17044', normal, compile_and_run, ['']) |