summaryrefslogtreecommitdiff
path: root/compiler/codeGen
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2019-01-17 13:34:32 +0100
committerBen Gamari <ben@smart-cactus.org>2019-01-31 12:46:51 -0500
commit4fa32293c9d2658ce504b8fe6d909db2acf59983 (patch)
tree6c7519fd6a320cbaf2264c2cbfdfe1eef0d70acc /compiler/codeGen
parentdeab6d64eac085b2e0ec68bfb3eeeda608dfb85a (diff)
downloadhaskell-4fa32293c9d2658ce504b8fe6d909db2acf59983.tar.gz
Use ByteString to represent Cmm string literals (#16198)
Also used ByteString in some other relevant places
Diffstat (limited to 'compiler/codeGen')
-rw-r--r--compiler/codeGen/StgCmm.hs3
-rw-r--r--compiler/codeGen/StgCmmClosure.hs10
-rw-r--r--compiler/codeGen/StgCmmUtils.hs10
3 files changed, 11 insertions, 12 deletions
diff --git a/compiler/codeGen/StgCmm.hs b/compiler/codeGen/StgCmm.hs
index acd2aee5f4..ff63b555ac 100644
--- a/compiler/codeGen/StgCmm.hs
+++ b/compiler/codeGen/StgCmm.hs
@@ -50,7 +50,6 @@ import VarSet ( isEmptyDVarSet )
import OrdList
import MkGraph
-import qualified Data.ByteString as BS
import Data.IORef
import Control.Monad (when,void)
import Util
@@ -141,7 +140,7 @@ cgTopBinding dflags (StgTopLifted (StgRec pairs))
cgTopBinding dflags (StgTopStringLit id str)
= do { id' <- maybeExternaliseId dflags id
; let label = mkBytesLabel (idName id')
- ; let (lit, decl) = mkByteStringCLit label (BS.unpack str)
+ ; let (lit, decl) = mkByteStringCLit label str
; emitDecl decl
; addBindC (litIdInfo dflags id' mkLFStringLit lit)
}
diff --git a/compiler/codeGen/StgCmmClosure.hs b/compiler/codeGen/StgCmmClosure.hs
index 65e7cf7dab..8ad8951a21 100644
--- a/compiler/codeGen/StgCmmClosure.hs
+++ b/compiler/codeGen/StgCmmClosure.hs
@@ -91,6 +91,7 @@ import DynFlags
import Util
import Data.Coerce (coerce)
+import qualified Data.ByteString.Char8 as BS8
-----------------------------------------------------------------------------
-- Data types and synonyms
@@ -916,10 +917,9 @@ enterIdLabel dflags id c
mkProfilingInfo :: DynFlags -> Id -> String -> ProfilingInfo
mkProfilingInfo dflags id val_descr
| not (gopt Opt_SccProfilingOn dflags) = NoProfilingInfo
- | otherwise = ProfilingInfo ty_descr_w8 val_descr_w8
+ | otherwise = ProfilingInfo ty_descr_w8 (BS8.pack val_descr)
where
- ty_descr_w8 = stringToWord8s (getTyDescription (idType id))
- val_descr_w8 = stringToWord8s val_descr
+ ty_descr_w8 = BS8.pack (getTyDescription (idType id))
getTyDescription :: Type -> String
getTyDescription ty
@@ -966,8 +966,8 @@ mkDataConInfoTable dflags data_con is_static ptr_wds nonptr_wds
prof | not (gopt Opt_SccProfilingOn dflags) = NoProfilingInfo
| otherwise = ProfilingInfo ty_descr val_descr
- ty_descr = stringToWord8s $ occNameString $ getOccName $ dataConTyCon data_con
- val_descr = stringToWord8s $ occNameString $ getOccName data_con
+ ty_descr = BS8.pack $ occNameString $ getOccName $ dataConTyCon data_con
+ val_descr = BS8.pack $ occNameString $ getOccName data_con
-- We need a black-hole closure info to pass to @allocDynClosure@ when we
-- want to allocate the black hole on entry to a CAF.
diff --git a/compiler/codeGen/StgCmmUtils.hs b/compiler/codeGen/StgCmmUtils.hs
index 4a6135607e..64af5c579c 100644
--- a/compiler/codeGen/StgCmmUtils.hs
+++ b/compiler/codeGen/StgCmmUtils.hs
@@ -71,12 +71,12 @@ import FastString
import Outputable
import RepType
-import qualified Data.ByteString as BS
+import Data.ByteString (ByteString)
+import qualified Data.ByteString.Char8 as BS8
import qualified Data.Map as M
import Data.Char
import Data.List
import Data.Ord
-import Data.Word
-------------------------------------------------------------------------
@@ -86,7 +86,7 @@ import Data.Word
-------------------------------------------------------------------------
cgLit :: Literal -> FCode CmmLit
-cgLit (LitString s) = newByteStringCLit (BS.unpack s)
+cgLit (LitString s) = newByteStringCLit s
-- not unpackFS; we want the UTF-8 byte stream.
cgLit other_lit = do dflags <- getDynFlags
return (mkSimpleLit dflags other_lit)
@@ -320,9 +320,9 @@ emitRODataLits lbl lits = emitDecl (mkRODataLits lbl lits)
newStringCLit :: String -> FCode CmmLit
-- Make a global definition for the string,
-- and return its label
-newStringCLit str = newByteStringCLit (map (fromIntegral . ord) str)
+newStringCLit str = newByteStringCLit (BS8.pack str)
-newByteStringCLit :: [Word8] -> FCode CmmLit
+newByteStringCLit :: ByteString -> FCode CmmLit
newByteStringCLit bytes
= do { uniq <- newUnique
; let (lit, decl) = mkByteStringCLit (mkStringLitLabel uniq) bytes