[commit: ghc] master, wip/T11371: TH: support raw bytes literals (#14741) (224a6b8)

git at git.haskell.org git at git.haskell.org
Sat Mar 9 07:09:12 UTC 2019


Repository : ssh://git@git.haskell.org/ghc

On branches: master,wip/T11371
Link       : http://ghc.haskell.org/trac/ghc/changeset/224a6b864c6aa0d851fcbf79469e5702b1116dbc/ghc

>---------------------------------------------------------------

commit 224a6b864c6aa0d851fcbf79469e5702b1116dbc
Author: Sylvain Henry <sylvain at haskus.fr>
Date:   Fri Jan 18 12:30:31 2019 +0100

    TH: support raw bytes literals (#14741)
    
    GHC represents String literals as ByteString internally for efficiency
    reasons. However, until now it wasn't possible to efficiently create
    large string literals with TH (e.g. to embed a file in a binary, cf #14741):
    TH code had to unpack the bytes into a [Word8] that GHC then had to re-pack
    into a ByteString.
    
    This patch adds the possibility to efficiently create a "string" literal
    from raw bytes. We get the following compile times for different sizes
    of TH created literals:
    
    || Size || Before || After  || Gain ||
    || 30K  || 2.307s || 2.299  || 0%   ||
    || 3M   || 3.073s || 2.400s || 21%  ||
    || 30M  || 8.517s || 3.390s || 60%  ||
    
    Ticket #14741 can be fixed if the original code uses this new TH feature.


>---------------------------------------------------------------

224a6b864c6aa0d851fcbf79469e5702b1116dbc
 compiler/basicTypes/Literal.hs                     | 14 +++++++++++
 compiler/hsSyn/Convert.hs                          |  8 +++++++
 libraries/ghci/GHCi/TH/Binary.hs                   |  8 +++++++
 .../template-haskell/Language/Haskell/TH/Lib.hs    | 18 +++++++++++++-
 .../Language/Haskell/TH/Lib/Internal.hs            |  2 ++
 .../template-haskell/Language/Haskell/TH/Ppr.hs    |  1 +
 .../template-haskell/Language/Haskell/TH/Syntax.hs | 20 ++++++++++++++++
 libraries/template-haskell/changelog.md            |  3 +++
 testsuite/tests/th/T14741.hs                       | 28 ++++++++++++++++++++++
 testsuite/tests/th/T14741.stdout                   |  1 +
 testsuite/tests/th/all.T                           |  1 +
 11 files changed, 103 insertions(+), 1 deletion(-)

Diff suppressed because of size. To see it, use:

    git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 224a6b864c6aa0d851fcbf79469e5702b1116dbc


More information about the ghc-commits mailing list