summaryrefslogtreecommitdiff
path: root/compiler/nativeGen/X86/Ppr.hs
diff options
context:
space:
mode:
authorPeter Trommler <ptrommler@acm.org>2019-01-13 16:36:07 -0500
committerPeter Trommler <ptrommler@acm.org>2019-01-13 16:36:07 -0500
commit4ad9ffd3897924313fb509515c60b4f09429e5cf (patch)
tree1ccda69aad63a1f348369a88a1277f3649edf95e /compiler/nativeGen/X86/Ppr.hs
parenta34ee61545930d569d0dbafb3a4a5db3a7a711e5 (diff)
downloadhaskell-4ad9ffd3897924313fb509515c60b4f09429e5cf.tar.gz
PPC NCG: Reduce memory consumption emitting string literals
Diffstat (limited to 'compiler/nativeGen/X86/Ppr.hs')
-rw-r--r--compiler/nativeGen/X86/Ppr.hs41
1 files changed, 0 insertions, 41 deletions
diff --git a/compiler/nativeGen/X86/Ppr.hs b/compiler/nativeGen/X86/Ppr.hs
index 141e781cc6..bf449d044e 100644
--- a/compiler/nativeGen/X86/Ppr.hs
+++ b/compiler/nativeGen/X86/Ppr.hs
@@ -48,8 +48,6 @@ import Outputable
import Data.Word
-import Data.Char
-
import Data.Bits
-- -----------------------------------------------------------------------------
@@ -243,45 +241,6 @@ pprLabel lbl = pprGloblDecl lbl
$$ pprTypeDecl lbl
$$ (ppr lbl <> char ':')
-{-
-Note [Pretty print ASCII when AsmCodeGen]
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Previously, when generating assembly code, we created SDoc with
-`(ptext . sLit)` for every bytes in literal bytestring, then
-combine them using `hcat`.
-
-When handling literal bytestrings with millions of bytes,
-millions of SDoc would be created and to combine, leading to
-high memory usage.
-
-Now we escape the given bytestring to string directly and construct
-SDoc only once. This improvement could dramatically decrease the
-memory allocation from 4.7GB to 1.3GB when embedding a 3MB literal
-string in source code. See Trac #14741 for profiling results.
--}
-
-pprASCII :: [Word8] -> SDoc
-pprASCII str
- -- Transform this given literal bytestring to escaped string and construct
- -- the literal SDoc directly.
- -- See Trac #14741
- -- and Note [Pretty print ASCII when AsmCodeGen]
- = ptext $ sLit $ foldr (\w s -> (do1 . fromIntegral) w ++ s) "" str
- where
- do1 :: Int -> String
- do1 w | '\t' <- chr w = "\\t"
- | '\n' <- chr w = "\\n"
- | '"' <- chr w = "\\\""
- | '\\' <- chr w = "\\\\"
- | isPrint (chr w) = [chr w]
- | otherwise = '\\' : octal w
-
- octal :: Int -> String
- octal w = [ chr (ord '0' + (w `div` 64) `mod` 8)
- , chr (ord '0' + (w `div` 8) `mod` 8)
- , chr (ord '0' + w `mod` 8)
- ]
-
pprAlign :: Int -> SDoc
pprAlign bytes
= sdocWithPlatform $ \platform ->