From: Simon Marlow Date: Fri, 21 Aug 2009 15:50:28 +0000 (+0000) Subject: Use explicit Word32/Int32 in place of Int in the on-disk .hi file X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=commitdiff_plain;h=1631a17da7e82f937e7ddbb49c747bc97d84ca69 Use explicit Word32/Int32 in place of Int in the on-disk .hi file For: FastStrings, Names, and Bin values. This makes .hi files smaller on 64-bit platforms, while also making the format a bit more robust. --- diff --git a/compiler/basicTypes/Name.lhs b/compiler/basicTypes/Name.lhs index 9f23f96..cb6785a 100644 --- a/compiler/basicTypes/Name.lhs +++ b/compiler/basicTypes/Name.lhs @@ -83,6 +83,7 @@ import FastString import Outputable import Data.Array +import Data.Word ( Word32 ) \end{code} %************************************************************************ @@ -368,7 +369,7 @@ instance Binary Name where get bh = do i <- get bh - return $! (ud_symtab (getUserData bh) ! i) + return $! (ud_symtab (getUserData bh) ! fromIntegral (i::Word32)) \end{code} %************************************************************************ diff --git a/compiler/iface/BinIface.hs b/compiler/iface/BinIface.hs index 864bbde..3cfb43d 100644 --- a/compiler/iface/BinIface.hs +++ b/compiler/iface/BinIface.hs @@ -287,13 +287,13 @@ putName BinSymbolTable{ = do symtab_map <- readIORef symtab_map_ref case lookupUFM symtab_map name of - Just (off,_) -> put_ bh off + Just (off,_) -> put_ bh (fromIntegral off :: Word32) Nothing -> do off <- readFastMutInt symtab_next writeFastMutInt symtab_next (off+1) writeIORef symtab_map_ref $! addToUFM symtab_map name (off,name) - put_ bh off + put_ bh (fromIntegral off :: Word32) data BinSymbolTable = BinSymbolTable { @@ -310,10 +310,10 @@ putFastString BinDictionary { bin_dict_next = j_r, out <- readIORef out_r let uniq = getUnique f case lookupUFM out uniq of - Just (j, _) -> put_ bh j + Just (j, _) -> put_ bh (fromIntegral j :: Word32) Nothing -> do j <- readFastMutInt j_r - put_ bh j + put_ bh (fromIntegral j :: Word32) writeFastMutInt j_r (j + 1) writeIORef out_r $! addToUFM out uniq (j, f) diff --git a/compiler/utils/Binary.hs b/compiler/utils/Binary.hs index e633f35..249480a 100644 --- a/compiler/utils/Binary.hs +++ b/compiler/utils/Binary.hs @@ -551,8 +551,8 @@ instance (Integral a, Binary a) => Binary (Ratio a) where #endif instance Binary (Bin a) where - put_ bh (BinPtr i) = put_ bh i - get bh = do i <- get bh; return (BinPtr i) + put_ bh (BinPtr i) = put_ bh (fromIntegral i :: Int32) + get bh = do i <- get bh; return (BinPtr (fromIntegral (i :: Int32))) -- ----------------------------------------------------------------------------- -- Instances for Data.Typeable stuff @@ -707,7 +707,7 @@ instance Binary FastString where get bh = do j <- get bh - return $! (ud_dict (getUserData bh) ! j) + return $! (ud_dict (getUserData bh) ! (fromIntegral (j :: Word32))) -- Here to avoid loop