[Git][ghc/ghc][master] 2 commits: Fix FastString lexicographic ordering (fix #18562)

Marge Bot gitlab at gitlab.haskell.org
Tue Sep 1 16:39:43 UTC 2020



 Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
884245dd by Sylvain Henry at 2020-09-01T12:39:36-04:00
Fix FastString lexicographic ordering (fix #18562)

- - - - -
4b4fbc58 by Sylvain Henry at 2020-09-01T12:39:36-04:00
Remove "Ord FastString" instance

FastStrings can be compared in 2 ways: by Unique or lexically. We don't
want to bless one particular way with an "Ord" instance because it leads
to bugs (#18562) or to suboptimal code (e.g. using lexical comparison
while a Unique comparison would suffice).

UTF-8 encoding has the advantage that sorting strings by their encoded
bytes also sorts them by their Unicode code points, without having to
decode the actual code points. BUT GHC uses Modified UTF-8 which
diverges from UTF-8 by encoding \0 as 0xC080 instead of 0x00 (to avoid
null bytes in the middle of a String so that the string can still be
null-terminated). This patch adds a new `utf8CompareShortByteString`
function that performs sorting by bytes but that also takes Modified
UTF-8 into account. It is much more performant than decoding the strings
into [Char] to perform comparisons (which we did in the previous patch).

Bump haddock submodule

- - - - -


30 changed files:

- compiler/GHC/Builtin/Types/Literals.hs
- compiler/GHC/Cmm/CLabel.hs
- compiler/GHC/Core/Coercion/Axiom.hs
- compiler/GHC/Core/Map.hs
- compiler/GHC/Core/Opt/Monad.hs
- compiler/GHC/Core/Rules.hs
- compiler/GHC/Core/TyCo/Rep.hs
- compiler/GHC/Data/FastString.hs
- compiler/GHC/Driver/Backpack.hs
- compiler/GHC/Hs/Lit.hs
- compiler/GHC/Iface/Ext/Ast.hs
- compiler/GHC/Iface/Ext/Debug.hs
- compiler/GHC/Iface/Ext/Types.hs
- compiler/GHC/Iface/Ext/Utils.hs
- compiler/GHC/Iface/Make.hs
- compiler/GHC/Iface/Recomp.hs
- compiler/GHC/IfaceToCore.hs
- compiler/GHC/Tc/Gen/Expr.hs
- compiler/GHC/Tc/TyCl.hs
- compiler/GHC/Types/CostCentre.hs
- compiler/GHC/Types/Literal.hs
- compiler/GHC/Types/Name/Occurrence.hs
- compiler/GHC/Types/SrcLoc.hs
- compiler/GHC/Unit/Info.hs
- compiler/GHC/Unit/Module/Name.hs
- compiler/GHC/Unit/State.hs
- compiler/GHC/Unit/Types.hs
- compiler/GHC/Utils/Binary.hs
- compiler/GHC/Utils/Encoding.hs
- compiler/GHC/Utils/Outputable.hs


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a8a2568b7b64e5b9fca5b12df7da759de4db39ae...4b4fbc58d37d37457144014ef82bdd928de175df

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a8a2568b7b64e5b9fca5b12df7da759de4db39ae...4b4fbc58d37d37457144014ef82bdd928de175df
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20200901/1df1e0b3/attachment.html>


More information about the ghc-commits mailing list