[Git][ghc/ghc][wip/decode_cloned_stack] CLeanup / Formatting

Sven Tennie (@supersven) gitlab at gitlab.haskell.org
Sat Nov 26 11:25:31 UTC 2022



Sven Tennie pushed to branch wip/decode_cloned_stack at Glasgow Haskell Compiler / GHC


Commits:
30a01042 by Sven Tennie at 2022-11-26T11:25:02+00:00
CLeanup / Formatting

- - - - -


1 changed file:

- libraries/ghc-heap/tests/stack_comparison.hs


Changes:

=====================================
libraries/ghc-heap/tests/stack_comparison.hs
=====================================
@@ -4,12 +4,12 @@
 
 module Main where
 
+import Data.Array.Byte
+import GHC.Exts
 import GHC.Exts.DecodeStack
+import GHC.Exts.Heap
 import GHC.Stack.CloneStack
 import TestUtils
-import GHC.Exts
-import Data.Array.Byte
-import GHC.Exts.Heap
 
 foreign import ccall "foldStackToArrayClosure" foldStackToArrayClosure# :: StackSnapshot# -> ByteArray#
 
@@ -22,25 +22,21 @@ main = do
   let ba = foldStackToArrayClosure stack
   let s = I# (sizeofByteArray# b#)
       (ByteArray b#) = ba
---  print $ "ByteArray size" ++ show (I# (sizeofByteArray# b#))
---  print $ "indices " ++ show [0..((wds s) -1)]
   print . show . toClosureTypes . toWords $ ba
 
-maxWordIndex :: ByteArray -> Int
-maxWordIndex (ByteArray ba#) =
-  let s = I# (sizeofByteArray# ba#)
-      words = s `div` 8
-  in
-    case words of
-      w | w == 0 -> error "ByteArray contains no content!"
-      w -> w - 1
-
 toWords :: ByteArray -> [Word]
 toWords ba@(ByteArray b#) =
   let s = I# (sizeofByteArray# b#)
-  in
-    -- TODO: Adjust 8 to machine word size
-    [ W# (indexWordArray# b# (toInt# i)) | i <- [0..maxWordIndex(ba)] ]
+   in -- TODO: Adjust 8 to machine word size
+      [W# (indexWordArray# b# (toInt# i)) | i <- [0 .. maxWordIndex (ba)]]
+  where
+    maxWordIndex :: ByteArray -> Int
+    maxWordIndex (ByteArray ba#) =
+      let s = I# (sizeofByteArray# ba#)
+          words = s `div` 8
+       in case words of
+            w | w == 0 -> error "ByteArray contains no content!"
+            w -> w - 1
 
 toClosureTypes :: [Word] -> [ClosureType]
 toClosureTypes = map (toEnum . fromIntegral)



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/30a01042dfb407eb7079a7441cb18a5b336215fb

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/30a01042dfb407eb7079a7441cb18a5b336215fb
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/20221126/779c3706/attachment-0001.html>


More information about the ghc-commits mailing list