summaryrefslogtreecommitdiff
path: root/compiler/GHC/Parser
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2021-10-12 10:31:42 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-10-14 14:34:42 -0400
commit481e6b546cdbcb646086cd66f22f588c47e66151 (patch)
treee62eec6512ba6036f49826ee317e7ddd12f9703e /compiler/GHC/Parser
parent8b7f5424c67b5ec005e061db87d30e124cf7234d (diff)
downloadhaskell-481e6b546cdbcb646086cd66f22f588c47e66151.tar.gz
Some extra strictness in annotation fields
Locations can be quite long-lived so it's important that things which live in locations, such as annotations are forced promptly. Otherwise they end up retaining the entire PState, as evidenced by this retainer trace: ``` PState 0x4277ce6cd8 0x4277ce6d00 0x7f61f12d37d8 0x7f61f12d37d8 0x7f61f135ef78 0x4277ce6d48 0x4277ce6d58 0x4277ce6d70 0x4277ce6d58 0x4277ce6d88 0x4277ce6da0 0x7f61f29782f0 0x7f61cd16b440 0x7f61cd16b440 0x7f61d00f8d18 0x7f61f296d290 0x7f61cd16b440 0x7f61d00f8d18 0x7f61cd16b4a8 0x7f61f135ef78 0x4277ce6db8 0x4277ce6dd0 0x7f61f134f358 0 3 <PState:GHC.Parser.Lexer:_build-ipe/stage1/compiler/build/GHC/Parser/Lexer.hs:3779:46> _thunk( ) 0x4277ce6280 0x4277ce68a0 <([LEpaComment], [LEpaComment]):GHC.Parser.Lexer:> _thunk( ) 0x4277ce6568 <EpAnnComments:GHC.Parser.Lexer:compiler/GHC/Parser/Lexer.x:2306:19-40> _thunk( ) 0x4277ce62b0 0x4277ce62c0 0x4277ce6280 0x7f61f287fc58 <EpAnn AnnList:GHC.Parser:_build-ipe/stage1/compiler/build/GHC/Parser.hs:12664:13-32> SrcSpanAnn 0x4277ce6060 0x4277ce6048 <SrcSpanAnn':GHC.Parser:_build-ipe/stage1/compiler/build/GHC/Parser.hs:12664:3-35> L 0x4277ce4e70 0x428f8c9158 <GenLocated:GHC.Data.BooleanFormula:compiler/GHC/Data/BooleanFormula.hs:40:23-29> 0x428f8c8318 : 0x428f8c8300 <[]:GHC.Base:libraries/base/GHC/Base.hs:1316:16-29> Or 0x428f8c7890 <BooleanFormula:GHC.Data.BooleanFormula:compiler/GHC/Data/BooleanFormula.hs:40:23-29> IfConcreteClass 0x7f61cd16b440 0x7f61cd16b440 0x428f8c7018 0x428f8c7030 <IfaceClassBody:GHC.Iface.Make:compiler/GHC/Iface/Make.hs:(640,12)-(645,13)> ``` Making these few places strict is sufficient for now but there are perhaps more places which will need strictifying in future. ------------------------- Metric Increase: parsing001 -------------------------
Diffstat (limited to 'compiler/GHC/Parser')
-rw-r--r--compiler/GHC/Parser/Annotation.hs11
1 files changed, 7 insertions, 4 deletions
diff --git a/compiler/GHC/Parser/Annotation.hs b/compiler/GHC/Parser/Annotation.hs
index 9555291530..abe5cdd731 100644
--- a/compiler/GHC/Parser/Annotation.hs
+++ b/compiler/GHC/Parser/Annotation.hs
@@ -499,11 +499,11 @@ instance Ord AddEpAnn where
-- new AST fragments out of old ones, and have them still printed out
-- in a precise way.
data EpAnn ann
- = EpAnn { entry :: Anchor
+ = EpAnn { entry :: !Anchor
-- ^ Base location for the start of the syntactic element
-- holding the annotations.
- , anns :: ann -- ^ Annotations added by the Parser
- , comments :: EpAnnComments
+ , anns :: !ann -- ^ Annotations added by the Parser
+ , comments :: !EpAnnComments
-- ^ Comments enclosed in the SrcSpan of the element
-- this `EpAnn` is attached to
}
@@ -570,7 +570,10 @@ emptyComments = EpaComments []
-- | The 'SrcSpanAnn\'' type wraps a normal 'SrcSpan', together with
-- an extra annotation type. This is mapped to a specific `GenLocated`
-- usage in the AST through the `XRec` and `Anno` type families.
-data SrcSpanAnn' a = SrcSpanAnn { ann :: a, locA :: SrcSpan }
+
+-- Important that the fields are strict as these live inside L nodes which
+-- are live for a long time.
+data SrcSpanAnn' a = SrcSpanAnn { ann :: !a, locA :: !SrcSpan }
deriving (Data, Eq)
-- See Note [XRec and Anno in the AST]