Wolfgang Jeltsch pushed to branch wip/jeltsch/textual-bytecode-output at Glasgow Haskell Compiler / GHC

Commits:

2 changed files:

Changes:

  • compiler/GHC/ByteCode/Show.hs
    ... ... @@ -15,7 +15,7 @@ import Data.Function (($), id, (.))
    15 15
     import Data.Tuple (fst, snd, uncurry)
    
    16 16
     import Data.Bool (Bool, otherwise, not, (&&))
    
    17 17
     import Data.Int (Int)
    
    18
    -import Data.Word (Word, Word16)
    
    18
    +import Data.Word (Word)
    
    19 19
     import Data.Maybe (Maybe, maybe)
    
    20 20
     import Data.Either (Either, either)
    
    21 21
     import Data.List (length, (++), map, zipWith, take, drop, replicate)
    
    ... ... @@ -24,12 +24,10 @@ import Data.ByteString (ByteString, unpack)
    24 24
     import Data.ByteString.Short (ShortByteString)
    
    25 25
     import Data.IntMap (IntMap)
    
    26 26
     import Data.IntMap qualified as IntMap (toList)
    
    27
    -import Data.Array.IArray (IArray, bounds, indices, elems)
    
    28
    -import Data.Array.Unboxed (UArray)
    
    27
    +import Data.Array (bounds, indices, elems)
    
    29 28
     import Numeric (showHex)
    
    30 29
     import Text.Show (show)
    
    31 30
     import System.IO (IO, FilePath)
    
    32
    -import Foreign.Storable (Storable)
    
    33 31
     import GHC.Data.Strict qualified as Strict (Maybe, maybe)
    
    34 32
     import GHC.Data.FastString (unpackFS)
    
    35 33
     import GHC.Data.FlatBag (FlatBag, elemsFlatBag)
    
    ... ... @@ -78,7 +76,6 @@ import GHC.ByteCode.Breakpoints
    78 76
     import GHC.ByteCode.Binary (OnDiskModuleByteCode (..))
    
    79 77
     import GHC.ByteCode.Serialize (readOnDiskModuleByteCode)
    
    80 78
     import GHC.Driver.Env.Types (HscEnv)
    
    81
    -import GHCi.ResolvedBCO (BCOByteArray, fromBCOByteArray)
    
    82 79
     import GHCi.FFI (FFIType)
    
    83 80
     import GHCi.Message (ConInfoTable (..))
    
    84 81
     
    
    ... ... @@ -132,8 +129,6 @@ pprByteCodeObject currentModule byteCodeObject = case byteCodeObject of
    132 129
             -> entry (text "ordinary object" <+> ppr unlinkedBCOName <> text ":") $
    
    133 130
                vcat [
    
    134 131
                         pprArity                  $ unlinkedBCOArity,
    
    135
    -                    pprInstructions           $ unlinkedBCOInstrs,
    
    136
    -                    pprBitmap                 $ unlinkedBCOBitmap,
    
    137 132
                         pprLiterals currentModule $ unlinkedBCOLits,
    
    138 133
                         pprPointers currentModule $ unlinkedBCOPtrs
    
    139 134
                     ]
    
    ... ... @@ -155,14 +150,6 @@ pprByteCodeObject currentModule byteCodeObject = case byteCodeObject of
    155 150
     pprArity :: Int -> SDoc
    
    156 151
     pprArity = entry (text "arity:") . ppr
    
    157 152
     
    
    158
    --- | […]
    
    159
    -pprInstructions :: BCOByteArray Word16 -> SDoc
    
    160
    -pprInstructions = entry (text "instructions:") . pprBCOByteArray
    
    161
    -
    
    162
    --- | […]
    
    163
    -pprBitmap :: BCOByteArray Word -> SDoc
    
    164
    -pprBitmap = entry (text "bitmap:") . pprBCOByteArray
    
    165
    -
    
    166 153
     -- | […]
    
    167 154
     pprDataConstructorName :: Name -> SDoc
    
    168 155
     pprDataConstructorName = entry (text "data constructor name:") . ppr
    
    ... ... @@ -530,11 +517,6 @@ pprObjectFileContent ix = entry (text "file" <+> ppr ix <> text ":") .
    530 517
     pprByteString :: ByteString -> SDoc
    
    531 518
     pprByteString = pprFixedSizeNaturalList . unpack
    
    532 519
     
    
    533
    --- | […]
    
    534
    -pprBCOByteArray :: (Integral a, FiniteBits a, Storable a, IArray UArray a) =>
    
    535
    -                   BCOByteArray a -> SDoc
    
    536
    -pprBCOByteArray = pprFixedSizeNaturalList . elems . fromBCOByteArray
    
    537
    -
    
    538 520
     -- | […]
    
    539 521
     pprFixedSizeNaturalList :: (Integral a, FiniteBits a) => [a] -> SDoc
    
    540 522
     pprFixedSizeNaturalList []   = text "<empty>"
    

  • libraries/ghci/GHCi/ResolvedBCO.hs
    ... ... @@ -7,7 +7,6 @@ module GHCi.ResolvedBCO
    7 7
       , isLittleEndian
    
    8 8
       , BCOByteArray(..)
    
    9 9
       , mkBCOByteArray
    
    10
    -  , fromBCOByteArray
    
    11 10
       ) where
    
    12 11
     
    
    13 12
     #include "MachDeps.h"
    
    ... ... @@ -21,6 +20,7 @@ import GHCi.BreakArray
    21 20
     import Control.Monad
    
    22 21
     import Data.Array.Base (foldrArray, listArray)
    
    23 22
     import Data.ByteString.Builder.Extra
    
    23
    +import Foreign.Storable
    
    24 24
     #endif
    
    25 25
     
    
    26 26
     import Data.Binary (Binary(..))
    
    ... ... @@ -32,7 +32,6 @@ import GHC.Generics
    32 32
     
    
    33 33
     import GHC.Exts
    
    34 34
     import Data.Array.Base (UArray(..))
    
    35
    -import Foreign.Storable
    
    36 35
     import qualified GHC.Exts.Heap as Heap
    
    37 36
     
    
    38 37
     #include "MachDeps.h"
    
    ... ... @@ -92,11 +91,13 @@ data BCOByteArray a
    92 91
             getBCOByteArray :: !ByteArray#
    
    93 92
       }
    
    94 93
     
    
    94
    +#if SIZEOF_HSWORD == 4
    
    95 95
     fromBCOByteArray :: forall a . Storable a => BCOByteArray a -> UArray Int a
    
    96 96
     fromBCOByteArray (BCOByteArray ba#) = UArray 0 (n - 1) n ba#
    
    97 97
       where
    
    98 98
         len# = sizeofByteArray# ba#
    
    99 99
         n = (I# len#) `div` sizeOf (undefined :: a)
    
    100
    +#endif
    
    100 101
     
    
    101 102
     mkBCOByteArray :: UArray Int a -> BCOByteArray a
    
    102 103
     mkBCOByteArray (UArray _ _ _ arr) = BCOByteArray arr