Skip to content

Commit

Permalink
Make sure that Pretty.text is inlined in stage 0,
Browse files Browse the repository at this point in the history
so that RULE text/str gets a chance to fire (Trac #7995).

And make sure that Outputable.text is inlined, so that the underlying
Pretty.text rule can fire.

The thing is that literal strings only turn into unpackCString#
in phase 1.
  • Loading branch information
Simon Peyton Jones committed Jun 24, 2013
1 parent 59d6942 commit d2c3630
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions compiler/utils/Outputable.lhs
Expand Up @@ -421,7 +421,10 @@ rational :: Rational -> SDoc
empty = docToSDoc $ Pretty.empty
char c = docToSDoc $ Pretty.char c
text s = docToSDoc $ Pretty.text s
{-# INLINE text #-} -- Inline so that the RULE Pretty.text will fire
ftext s = docToSDoc $ Pretty.ftext s
ptext s = docToSDoc $ Pretty.ptext s
ztext s = docToSDoc $ Pretty.ztext s
Expand Down
4 changes: 3 additions & 1 deletion compiler/utils/Pretty.lhs
Expand Up @@ -557,7 +557,9 @@ isEmpty _ = False
char c = textBeside_ (Chr c) (_ILIT(1)) Empty
text s = case iUnbox (length s) of {sl -> textBeside_ (Str s) sl Empty}
{-# NOINLINE [1] text #-} -- Give the RULE a chance to fire
{-# NOINLINE [0] text #-} -- Give the RULE a chance to fire
-- It must wait till after phase 1 when
-- the unpackCString first is manifested
ftext :: FastString -> Doc
ftext s = case iUnbox (lengthFS s) of {sl -> textBeside_ (PStr s) sl Empty}
Expand Down

0 comments on commit d2c3630

Please sign in to comment.