[commit: ghc] master: Give the Unique generated by strings a tag '$', fixes #9413. (4855be0)
git at git.haskell.org
git at git.haskell.org
Thu Aug 7 13:09:58 UTC 2014
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/4855be0d0d1ac90f836a6fb54f4034f478e38fd8/ghc
>---------------------------------------------------------------
commit 4855be0d0d1ac90f836a6fb54f4034f478e38fd8
Author: Edward Z. Yang <ezyang at cs.stanford.edu>
Date: Wed Aug 6 11:55:06 2014 +0100
Give the Unique generated by strings a tag '$', fixes #9413.
Summary:
Previously, we allocated uniques for strings starting at zero, which
means the tag bits in the unique are zero, which means that printing a
Unique for a string will start with a null byte. This is bad. So
instead, start our numbering with the tag byte as '$' (as in $tring).
This is hard coded so we don't have to worry about the optimizer
reducing the expression.
Signed-off-by: Edward Z. Yang <ezyang at cs.stanford.edu>
Test Plan: validate
Reviewers: hvr, simonmar, austin
Subscribers: simonmar, relrod, ezyang, carter
Differential Revision: https://phabricator.haskell.org/D123
GHC Trac Issues: #9413
>---------------------------------------------------------------
4855be0d0d1ac90f836a6fb54f4034f478e38fd8
compiler/utils/FastString.lhs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/compiler/utils/FastString.lhs b/compiler/utils/FastString.lhs
index 0396c02..157e5f0 100644
--- a/compiler/utils/FastString.lhs
+++ b/compiler/utils/FastString.lhs
@@ -239,7 +239,7 @@ data FastStringTable =
string_table :: FastStringTable
{-# NOINLINE string_table #-}
string_table = unsafePerformIO $ do
- uid <- newIORef 0
+ uid <- newIORef 603979776 -- ord '$' * 0x01000000
tab <- IO $ \s1# -> case newArray# hASH_TBL_SIZE_UNBOXED (panic "string_table") s1# of
(# s2#, arr# #) ->
(# s2#, FastStringTable uid arr# #)
More information about the ghc-commits
mailing list