Commit 9b01539f authored by Ben Gamari's avatar Ben Gamari 🐢
Browse files

Show: Activate literal rewrite rules in simplifier phase 1

When rewriting in a rule, GHC pretends that it is in the phase given by
the activation phase of the rule (see Note [Simplifying inside stable
unfoldings] in `SimplUtils` for rationale). This means that while
rewriting the text literal rules, the simplifier is effectively in phase
2 due to 86ddf8a9.

As it turns out, the `build` rule provided by `base` is also active in
phase 2, meaning it still competes with the literal rules (as 7.10.2
uses it to rewrite the LHS). For this reason, the previous change did
not resolve the performance issue in 7.10.2; something I did not
previously catch due to a rather silly issue in my test envirionment.

This issue is now properly resolved by activating the literal rewrite
rules only in phase 1, by which point the `build` rule is inactive. See
comments 22 through 25 in GHC Trac #10528 for details.
parent 53c968db
......@@ -50,19 +50,19 @@ unpackCString# :: Addr# -> Text
unpackCString# addr# = unstream (S.streamCString# addr#)
{-# NOINLINE unpackCString# #-}
{-# RULES "TEXT literal" [2] forall a.
{-# RULES "TEXT literal" [1] forall a.
unstream (S.map safe (S.streamList (GHC.unpackCString# a)))
= unpackCString# a #-}
{-# RULES "TEXT literal UTF8" [2] forall a.
{-# RULES "TEXT literal UTF8" [1] forall a.
unstream (S.map safe (S.streamList (GHC.unpackCStringUtf8# a)))
= unpackCString# a #-}
{-# RULES "TEXT empty literal" [2]
{-# RULES "TEXT empty literal" [1]
unstream (S.map safe (S.streamList []))
= empty_ #-}
{-# RULES "TEXT singleton literal" [2] forall a.
{-# RULES "TEXT singleton literal" [1] forall a.
unstream (S.map safe (S.streamList [a]))
= singleton_ a #-}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment