diff options
Diffstat (limited to 'libraries/ghc-heap/tests/closure_size.hs')
-rw-r--r-- | libraries/ghc-heap/tests/closure_size.hs | 56 |
1 files changed, 1 insertions, 55 deletions
diff --git a/libraries/ghc-heap/tests/closure_size.hs b/libraries/ghc-heap/tests/closure_size.hs index f381a57521..d760f22efa 100644 --- a/libraries/ghc-heap/tests/closure_size.hs +++ b/libraries/ghc-heap/tests/closure_size.hs @@ -1,60 +1,12 @@ -{-# LANGUAGE BangPatterns #-} -{-# LANGUAGE TypeApplications #-} {-# LANGUAGE MagicHash #-} {-# LANGUAGE KindSignatures #-} {-# LANGUAGE UnboxedTuples #-} {-# LANGUAGE TypeInType #-} {-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE CPP #-} -import Control.Monad -import Type.Reflection import GHC.Exts -import GHC.Stack import GHC.IO - -import GHC.Exts.Heap.Closures - -assertSize - :: forall a. (HasCallStack, Typeable a) - => a -- ^ closure - -> Int -- ^ expected size in words - -> IO () -assertSize x = - assertSizeBox (asBox x) (typeRep @a) - -assertSizeUnlifted - :: forall (a :: TYPE 'UnliftedRep). (HasCallStack, Typeable a) - => a -- ^ closure - -> Int -- ^ expected size in words - -> IO () -assertSizeUnlifted x = - assertSizeBox (Box (unsafeCoerce# x)) (typeRep @a) - -assertSizeBox - :: forall a. (HasCallStack) - => Box -- ^ closure - -> TypeRep a - -> Int -- ^ expected size in words - -> IO () -assertSizeBox x ty expected = do - let !size = closureSize x - when (size /= expected') $ do - putStrLn $ "closureSize ("++show ty++") == "++show size++", expected "++show expected' - putStrLn $ prettyCallStack callStack - where expected' = expected + profHeaderSize -{-# NOINLINE assertSize #-} - -pap :: Int -> Char -> Int -pap x _ = x -{-# NOINLINE pap #-} - -profHeaderSize :: Int -#if PROFILING -profHeaderSize = 2 -#else -profHeaderSize = 0 -#endif +import ClosureSizeUtils data A = A (Array# Int) data MA = MA (MutableArray# RealWorld Int) @@ -72,12 +24,6 @@ main = do assertSize ((1,2) :: (Int,Int)) 3 assertSize ((1,2,3) :: (Int,Int,Int)) 4 - -- These depend too much upon the behavior of the simplifier to - -- test reliably. - --assertSize (id :: Int -> Int) 1 - --assertSize (fst :: (Int,Int) -> Int) 1 - --assertSize (pap 1) 2 - MA ma <- IO $ \s -> case newArray# 0# 0 s of (# s1, x #) -> (# s1, MA x #) |