summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorZubin Duggal <zubin.duggal@gmail.com>2023-05-04 05:30:13 +0530
committerMarge Bot <ben+marge-bot@smart-cactus.org>2023-05-16 14:00:00 -0400
commit90e69d5d167b9d6cd63b04e42f8af375dc4b307f (patch)
tree8ce2679872dbc4c4a5cc60025fe9564d36fc7772 /testsuite
parent5e3f9bb57680a40f6a9531e41dc2617c5f028e5c (diff)
downloadhaskell-90e69d5d167b9d6cd63b04e42f8af375dc4b307f.tar.gz
compiler: Use compact representation for SourceText
SourceText is serialized along with INLINE pragmas into interface files. Many of these SourceTexts are identical, for example "{-# INLINE#". When deserialized, each such SourceText was previously expanded out into a [Char], which is highly wasteful of memory, and each such instance of the text would allocate an independent list with its contents as deserializing breaks any sharing that might have existed. Instead, we use a `FastString` to represent these, so that each instance unique text will be interned and stored in a memory efficient manner.
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/ghc-api/annotations-literals/parsed.hs25
1 files changed, 13 insertions, 12 deletions
diff --git a/testsuite/tests/ghc-api/annotations-literals/parsed.hs b/testsuite/tests/ghc-api/annotations-literals/parsed.hs
index 06fa9ea60d..9e9ae93c29 100644
--- a/testsuite/tests/ghc-api/annotations-literals/parsed.hs
+++ b/testsuite/tests/ghc-api/annotations-literals/parsed.hs
@@ -3,6 +3,7 @@
-- argument.
module Main where
+import GHC.Data.FastString
import GHC.Types.Basic
import GHC.Types.SourceText
import Data.Data
@@ -46,32 +47,32 @@ testOneFile libdir fileName = do
doHsLit :: HsLit GhcPs -> [String]
doHsLit (HsChar (SourceText src) c)
- = ["HsChar [" ++ src ++ "] " ++ show c]
+ = ["HsChar [" ++ unpackFS src ++ "] " ++ show c]
doHsLit (HsCharPrim (SourceText src) c)
- = ["HsCharPrim [" ++ src ++ "] " ++ show c]
+ = ["HsCharPrim [" ++ unpackFS src ++ "] " ++ show c]
doHsLit (HsString (SourceText src) c)
- = ["HsString [" ++ src ++ "] " ++ show c]
+ = ["HsString [" ++ unpackFS src ++ "] " ++ show c]
doHsLit (HsStringPrim (SourceText src) c)
- = ["HsStringPrim [" ++ src ++ "] " ++ show c]
+ = ["HsStringPrim [" ++ unpackFS src ++ "] " ++ show c]
doHsLit (HsInt _ (IL (SourceText src) _ c))
- = ["HsInt [" ++ src ++ "] " ++ show c]
+ = ["HsInt [" ++ unpackFS src ++ "] " ++ show c]
doHsLit (HsIntPrim (SourceText src) c)
- = ["HsIntPrim [" ++ src ++ "] " ++ show c]
+ = ["HsIntPrim [" ++ unpackFS src ++ "] " ++ show c]
doHsLit (HsWordPrim (SourceText src) c)
- = ["HsWordPrim [" ++ src ++ "] " ++ show c]
+ = ["HsWordPrim [" ++ unpackFS src ++ "] " ++ show c]
doHsLit (HsInt64Prim (SourceText src) c)
- = ["HsInt64Prim [" ++ src ++ "] " ++ show c]
+ = ["HsInt64Prim [" ++ unpackFS src ++ "] " ++ show c]
doHsLit (HsWord64Prim (SourceText src) c)
- = ["HsWord64Prim [" ++ src ++ "] " ++ show c]
+ = ["HsWord64Prim [" ++ unpackFS src ++ "] " ++ show c]
doHsLit (HsInteger (SourceText src) c _)
- = ["HsInteger [" ++ src ++ "] " ++ show c]
+ = ["HsInteger [" ++ unpackFS src ++ "] " ++ show c]
doHsLit _ = []
doOverLit :: OverLitVal -> [String]
doOverLit (HsIntegral (IL (SourceText src) _ c))
- = ["HsIntegral [" ++ src ++ "] " ++ show c]
+ = ["HsIntegral [" ++ unpackFS src ++ "] " ++ show c]
doOverLit (HsIsString (SourceText src) c)
- = ["HsIsString [" ++ src ++ "] " ++ show c]
+ = ["HsIsString [" ++ unpackFS src ++ "] " ++ show c]
doOverLit _ = []
pp a = showPprUnsafe a