Commit 2f29ebbb authored by thomie's avatar thomie Committed by Ben Gamari
Browse files

Refactor: delete most of the module FastTypes

This reverses some of the work done in #1405, and goes back to the
assumption that the bootstrap compiler understands GHC-haskell.

In particular:
  * use MagicHash instead of _ILIT and _CLIT
  * pattern matching on I# if possible, instead of using iUnbox
    unnecessarily
  * use Int#/Char#/Addr# instead of the following type synonyms:
    - type FastInt   = Int#
    - type FastChar  = Char#
    - type FastPtr a = Addr#
  * inline the following functions:
    - iBox           = I#
    - cBox           = C#
    - fastChr        = chr#
    - fastOrd        = ord#
    - eqFastChar     = eqChar#
    - shiftLFastInt  = uncheckedIShiftL#
    - shiftR_FastInt = uncheckedIShiftRL#
    - shiftRLFastInt = uncheckedIShiftRL#
  * delete the following unused functions:
    - minFastInt
    - maxFastInt
    - uncheckedIShiftRA#
    - castFastPtr
    - panicDocFastInt and pprPanicFastInt
  * rename panicFastInt back to panic#

These functions remain, since they actually do something:
  * iUnbox
  * bitAndFastInt
  * bitOrFastInt

Test Plan: validate

Reviewers: austin, bgamari

Subscribers: rwbarton

Differential Revision: https://phabricator.haskell.org/D1141

GHC Trac Issues: #1405
parent 3452473b
...@@ -48,7 +48,6 @@ import PrelNames ...@@ -48,7 +48,6 @@ import PrelNames
import Type import Type
import TyCon import TyCon
import Outputable import Outputable
import FastTypes
import FastString import FastString
import BasicTypes import BasicTypes
import Binary import Binary
...@@ -422,21 +421,21 @@ cmpLit (MachFloat a) (MachFloat b) = a `compare` b ...@@ -422,21 +421,21 @@ cmpLit (MachFloat a) (MachFloat b) = a `compare` b
cmpLit (MachDouble a) (MachDouble b) = a `compare` b cmpLit (MachDouble a) (MachDouble b) = a `compare` b
cmpLit (MachLabel a _ _) (MachLabel b _ _) = a `compare` b cmpLit (MachLabel a _ _) (MachLabel b _ _) = a `compare` b
cmpLit (LitInteger a _) (LitInteger b _) = a `compare` b cmpLit (LitInteger a _) (LitInteger b _) = a `compare` b
cmpLit lit1 lit2 | litTag lit1 <# litTag lit2 = LT cmpLit lit1 lit2 | litTag lit1 < litTag lit2 = LT
| otherwise = GT | otherwise = GT
litTag :: Literal -> FastInt litTag :: Literal -> Int
litTag (MachChar _) = _ILIT(1) litTag (MachChar _) = 1
litTag (MachStr _) = _ILIT(2) litTag (MachStr _) = 2
litTag (MachNullAddr) = _ILIT(3) litTag (MachNullAddr) = 3
litTag (MachInt _) = _ILIT(4) litTag (MachInt _) = 4
litTag (MachWord _) = _ILIT(5) litTag (MachWord _) = 5
litTag (MachInt64 _) = _ILIT(6) litTag (MachInt64 _) = 6
litTag (MachWord64 _) = _ILIT(7) litTag (MachWord64 _) = 7
litTag (MachFloat _) = _ILIT(8) litTag (MachFloat _) = 8
litTag (MachDouble _) = _ILIT(9) litTag (MachDouble _) = 9
litTag (MachLabel _ _ _) = _ILIT(10) litTag (MachLabel _ _ _) = 10
litTag (LitInteger {}) = _ILIT(11) litTag (LitInteger {}) = 11
{- {-
Printing Printing
...@@ -535,4 +534,4 @@ hashInteger i = 1 + abs (fromInteger (i `rem` 10000)) ...@@ -535,4 +534,4 @@ hashInteger i = 1 + abs (fromInteger (i `rem` 10000))
-- since we use * to combine hash values -- since we use * to combine hash values
hashFS :: FastString -> Int hashFS :: FastString -> Int
hashFS s = iBox (uniqueOfFS s) hashFS s = uniqueOfFS s
...@@ -86,7 +86,6 @@ import Util ...@@ -86,7 +86,6 @@ import Util
import Maybes import Maybes
import Binary import Binary
import DynFlags import DynFlags
import FastTypes
import FastString import FastString
import Outputable import Outputable
...@@ -105,8 +104,7 @@ import Data.Data ...@@ -105,8 +104,7 @@ import Data.Data
data Name = Name { data Name = Name {
n_sort :: NameSort, -- What sort of name it is n_sort :: NameSort, -- What sort of name it is
n_occ :: !OccName, -- Its occurrence name n_occ :: !OccName, -- Its occurrence name
n_uniq :: FastInt, -- UNPACK doesn't work, recursive type n_uniq :: {-# UNPACK #-} !Int,
--(note later when changing Int# -> FastInt: is that still true about UNPACK?)
n_loc :: !SrcSpan -- Definition site n_loc :: !SrcSpan -- Definition site
} }
deriving Typeable deriving Typeable
...@@ -184,7 +182,7 @@ nameModule :: Name -> Module ...@@ -184,7 +182,7 @@ nameModule :: Name -> Module
nameSrcLoc :: Name -> SrcLoc nameSrcLoc :: Name -> SrcLoc
nameSrcSpan :: Name -> SrcSpan nameSrcSpan :: Name -> SrcSpan
nameUnique name = mkUniqueGrimily (iBox (n_uniq name)) nameUnique name = mkUniqueGrimily (n_uniq name)
nameOccName name = n_occ name nameOccName name = n_occ name
nameSrcLoc name = srcSpanStart (n_loc name) nameSrcLoc name = srcSpanStart (n_loc name)
nameSrcSpan name = n_loc name nameSrcSpan name = n_loc name
...@@ -309,7 +307,7 @@ isSystemName _ = False ...@@ -309,7 +307,7 @@ isSystemName _ = False
-- | Create a name which is (for now at least) local to the current module and hence -- | Create a name which is (for now at least) local to the current module and hence
-- does not need a 'Module' to disambiguate it from other 'Name's -- does not need a 'Module' to disambiguate it from other 'Name's
mkInternalName :: Unique -> OccName -> SrcSpan -> Name mkInternalName :: Unique -> OccName -> SrcSpan -> Name
mkInternalName uniq occ loc = Name { n_uniq = getKeyFastInt uniq mkInternalName uniq occ loc = Name { n_uniq = getKey uniq
, n_sort = Internal , n_sort = Internal
, n_occ = occ , n_occ = occ
, n_loc = loc } , n_loc = loc }
...@@ -324,12 +322,12 @@ mkInternalName uniq occ loc = Name { n_uniq = getKeyFastInt uniq ...@@ -324,12 +322,12 @@ mkInternalName uniq occ loc = Name { n_uniq = getKeyFastInt uniq
mkClonedInternalName :: Unique -> Name -> Name mkClonedInternalName :: Unique -> Name -> Name
mkClonedInternalName uniq (Name { n_occ = occ, n_loc = loc }) mkClonedInternalName uniq (Name { n_occ = occ, n_loc = loc })
= Name { n_uniq = getKeyFastInt uniq, n_sort = Internal = Name { n_uniq = getKey uniq, n_sort = Internal
, n_occ = occ, n_loc = loc } , n_occ = occ, n_loc = loc }
mkDerivedInternalName :: (OccName -> OccName) -> Unique -> Name -> Name mkDerivedInternalName :: (OccName -> OccName) -> Unique -> Name -> Name
mkDerivedInternalName derive_occ uniq (Name { n_occ = occ, n_loc = loc }) mkDerivedInternalName derive_occ uniq (Name { n_occ = occ, n_loc = loc })
= Name { n_uniq = getKeyFastInt uniq, n_sort = Internal = Name { n_uniq = getKey uniq, n_sort = Internal
, n_occ = derive_occ occ, n_loc = loc } , n_occ = derive_occ occ, n_loc = loc }
-- | Create a name which definitely originates in the given module -- | Create a name which definitely originates in the given module
...@@ -338,13 +336,13 @@ mkExternalName :: Unique -> Module -> OccName -> SrcSpan -> Name ...@@ -338,13 +336,13 @@ mkExternalName :: Unique -> Module -> OccName -> SrcSpan -> Name
-- (see Note [The Name Cache] in IfaceEnv), so don't just call mkExternalName -- (see Note [The Name Cache] in IfaceEnv), so don't just call mkExternalName
-- with some fresh unique without populating the Name Cache -- with some fresh unique without populating the Name Cache
mkExternalName uniq mod occ loc mkExternalName uniq mod occ loc
= Name { n_uniq = getKeyFastInt uniq, n_sort = External mod, = Name { n_uniq = getKey uniq, n_sort = External mod,
n_occ = occ, n_loc = loc } n_occ = occ, n_loc = loc }
-- | Create a name which is actually defined by the compiler itself -- | Create a name which is actually defined by the compiler itself
mkWiredInName :: Module -> OccName -> Unique -> TyThing -> BuiltInSyntax -> Name mkWiredInName :: Module -> OccName -> Unique -> TyThing -> BuiltInSyntax -> Name
mkWiredInName mod occ uniq thing built_in mkWiredInName mod occ uniq thing built_in
= Name { n_uniq = getKeyFastInt uniq, = Name { n_uniq = getKey uniq,
n_sort = WiredIn mod thing built_in, n_sort = WiredIn mod thing built_in,
n_occ = occ, n_loc = wiredInSrcSpan } n_occ = occ, n_loc = wiredInSrcSpan }
...@@ -353,7 +351,7 @@ mkSystemName :: Unique -> OccName -> Name ...@@ -353,7 +351,7 @@ mkSystemName :: Unique -> OccName -> Name
mkSystemName uniq occ = mkSystemNameAt uniq occ noSrcSpan mkSystemName uniq occ = mkSystemNameAt uniq occ noSrcSpan
mkSystemNameAt :: Unique -> OccName -> SrcSpan -> Name mkSystemNameAt :: Unique -> OccName -> SrcSpan -> Name
mkSystemNameAt uniq occ loc = Name { n_uniq = getKeyFastInt uniq, n_sort = System mkSystemNameAt uniq occ loc = Name { n_uniq = getKey uniq, n_sort = System
, n_occ = occ, n_loc = loc } , n_occ = occ, n_loc = loc }
mkSystemVarName :: Unique -> FastString -> Name mkSystemVarName :: Unique -> FastString -> Name
...@@ -371,7 +369,7 @@ mkFCallName uniq str = mkInternalName uniq (mkVarOcc str) noSrcSpan ...@@ -371,7 +369,7 @@ mkFCallName uniq str = mkInternalName uniq (mkVarOcc str) noSrcSpan
-- able to change a Name's Unique to match the cached -- able to change a Name's Unique to match the cached
-- one in the thing it's the name of. If you know what I mean. -- one in the thing it's the name of. If you know what I mean.
setNameUnique :: Name -> Unique -> Name setNameUnique :: Name -> Unique -> Name
setNameUnique name uniq = name {n_uniq = getKeyFastInt uniq} setNameUnique name uniq = name {n_uniq = getKey uniq}
-- This is used for hsigs: we want to use the name of the originally exported -- This is used for hsigs: we want to use the name of the originally exported
-- entity, but edit the location to refer to the reexport site -- entity, but edit the location to refer to the reexport site
...@@ -410,7 +408,7 @@ mkLocalisedOccName this_mod mk_occ name = mk_occ origin (nameOccName name) ...@@ -410,7 +408,7 @@ mkLocalisedOccName this_mod mk_occ name = mk_occ origin (nameOccName name)
-} -}
cmpName :: Name -> Name -> Ordering cmpName :: Name -> Name -> Ordering
cmpName n1 n2 = iBox (n_uniq n1) `compare` iBox (n_uniq n2) cmpName n1 n2 = n_uniq n1 `compare` n_uniq n2
stableNameCmp :: Name -> Name -> Ordering stableNameCmp :: Name -> Name -> Ordering
-- Compare lexicographically -- Compare lexicographically
...@@ -505,7 +503,7 @@ pprName (Name {n_sort = sort, n_uniq = u, n_occ = occ}) ...@@ -505,7 +503,7 @@ pprName (Name {n_sort = sort, n_uniq = u, n_occ = occ})
External mod -> pprExternal sty uniq mod occ False UserSyntax External mod -> pprExternal sty uniq mod occ False UserSyntax
System -> pprSystem sty uniq occ System -> pprSystem sty uniq occ
Internal -> pprInternal sty uniq occ Internal -> pprInternal sty uniq occ
where uniq = mkUniqueGrimily (iBox u) where uniq = mkUniqueGrimily u
pprExternal :: PprStyle -> Unique -> Module -> OccName -> Bool -> BuiltInSyntax -> SDoc pprExternal :: PprStyle -> Unique -> Module -> OccName -> Bool -> BuiltInSyntax -> SDoc
pprExternal sty uniq mod occ is_wired is_builtin pprExternal sty uniq mod occ is_wired is_builtin
......
...@@ -25,12 +25,13 @@ module UniqSupply ( ...@@ -25,12 +25,13 @@ module UniqSupply (
) where ) where
import Unique import Unique
import FastTypes
import GHC.IO import GHC.IO
import MonadUtils import MonadUtils
import Control.Monad import Control.Monad
import Data.Bits
import Data.Char
{- {-
************************************************************************ ************************************************************************
...@@ -45,7 +46,7 @@ import Control.Monad ...@@ -45,7 +46,7 @@ import Control.Monad
-- also manufacture an arbitrary number of further 'UniqueSupply' values, -- also manufacture an arbitrary number of further 'UniqueSupply' values,
-- which will be distinct from the first and from all others. -- which will be distinct from the first and from all others.
data UniqSupply data UniqSupply
= MkSplitUniqSupply FastInt -- make the Unique with this = MkSplitUniqSupply {-# UNPACK #-} !Int -- make the Unique with this
UniqSupply UniqSupply UniqSupply UniqSupply
-- when split => these two supplies -- when split => these two supplies
...@@ -67,7 +68,7 @@ takeUniqFromSupply :: UniqSupply -> (Unique, UniqSupply) ...@@ -67,7 +68,7 @@ takeUniqFromSupply :: UniqSupply -> (Unique, UniqSupply)
-- ^ Obtain the 'Unique' from this particular 'UniqSupply', and a new supply -- ^ Obtain the 'Unique' from this particular 'UniqSupply', and a new supply
mkSplitUniqSupply c mkSplitUniqSupply c
= case fastOrd (cUnbox c) `shiftLFastInt` _ILIT(24) of = case ord c `shiftL` 24 of
mask -> let mask -> let
-- here comes THE MAGIC: -- here comes THE MAGIC:
...@@ -75,11 +76,11 @@ mkSplitUniqSupply c ...@@ -75,11 +76,11 @@ mkSplitUniqSupply c
mk_supply mk_supply
-- NB: Use unsafeInterleaveIO for thread-safety. -- NB: Use unsafeInterleaveIO for thread-safety.
= unsafeInterleaveIO ( = unsafeInterleaveIO (
genSym >>= \ u_ -> case iUnbox u_ of { u -> ( genSym >>= \ u ->
mk_supply >>= \ s1 -> mk_supply >>= \ s1 ->
mk_supply >>= \ s2 -> mk_supply >>= \ s2 ->
return (MkSplitUniqSupply (mask `bitOrFastInt` u) s1 s2) return (MkSplitUniqSupply (mask .|. u) s1 s2)
)}) )
in in
mk_supply mk_supply
...@@ -88,9 +89,9 @@ foreign import ccall unsafe "genSym" genSym :: IO Int ...@@ -88,9 +89,9 @@ foreign import ccall unsafe "genSym" genSym :: IO Int
splitUniqSupply (MkSplitUniqSupply _ s1 s2) = (s1, s2) splitUniqSupply (MkSplitUniqSupply _ s1 s2) = (s1, s2)
listSplitUniqSupply (MkSplitUniqSupply _ s1 s2) = s1 : listSplitUniqSupply s2 listSplitUniqSupply (MkSplitUniqSupply _ s1 s2) = s1 : listSplitUniqSupply s2
uniqFromSupply (MkSplitUniqSupply n _ _) = mkUniqueGrimily (iBox n) uniqFromSupply (MkSplitUniqSupply n _ _) = mkUniqueGrimily n
uniqsFromSupply (MkSplitUniqSupply n _ s2) = mkUniqueGrimily (iBox n) : uniqsFromSupply s2 uniqsFromSupply (MkSplitUniqSupply n _ s2) = mkUniqueGrimily n : uniqsFromSupply s2
takeUniqFromSupply (MkSplitUniqSupply n s1 _) = (mkUniqueGrimily (iBox n), s1) takeUniqFromSupply (MkSplitUniqSupply n s1 _) = (mkUniqueGrimily n, s1)
{- {-
************************************************************************ ************************************************************************
......
...@@ -28,7 +28,7 @@ module Unique ( ...@@ -28,7 +28,7 @@ module Unique (
pprUnique, pprUnique,
mkUniqueGrimily, -- Used in UniqSupply only! mkUniqueGrimily, -- Used in UniqSupply only!
getKey, getKeyFastInt, -- Used in Var, UniqFM, Name only! getKey, -- Used in Var, UniqFM, Name only!
mkUnique, unpkUnique, -- Used in BinIface only mkUnique, unpkUnique, -- Used in BinIface only
incrUnique, -- Used for renumbering incrUnique, -- Used for renumbering
...@@ -61,16 +61,15 @@ module Unique ( ...@@ -61,16 +61,15 @@ module Unique (
#include "HsVersions.h" #include "HsVersions.h"
import BasicTypes import BasicTypes
import FastTypes
import FastString import FastString
import Outputable import Outputable
-- import StaticFlags
import Util import Util
--just for implementing a fast [0,61) -> Char function -- just for implementing a fast [0,61) -> Char function
import GHC.Exts (indexCharOffAddr#, Char(..)) import GHC.Exts (indexCharOffAddr#, Char(..), Int(..))
import Data.Char ( chr, ord ) import Data.Char ( chr, ord )
import Data.Bits
{- {-
************************************************************************ ************************************************************************
...@@ -88,7 +87,7 @@ Fast comparison is everything on @Uniques@: ...@@ -88,7 +87,7 @@ Fast comparison is everything on @Uniques@:
-- | The type of unique identifiers that are used in many places in GHC -- | The type of unique identifiers that are used in many places in GHC
-- for fast ordering and equality tests. You should generate these with -- for fast ordering and equality tests. You should generate these with
-- the functions from the 'UniqSupply' module -- the functions from the 'UniqSupply' module
data Unique = MkUnique FastInt data Unique = MkUnique {-# UNPACK #-} !Int
{- {-
Now come the functions which construct uniques from their pieces, and vice versa. Now come the functions which construct uniques from their pieces, and vice versa.
...@@ -99,24 +98,21 @@ unpkUnique :: Unique -> (Char, Int) -- The reverse ...@@ -99,24 +98,21 @@ unpkUnique :: Unique -> (Char, Int) -- The reverse
mkUniqueGrimily :: Int -> Unique -- A trap-door for UniqSupply mkUniqueGrimily :: Int -> Unique -- A trap-door for UniqSupply
getKey :: Unique -> Int -- for Var getKey :: Unique -> Int -- for Var
getKeyFastInt :: Unique -> FastInt -- for Var
incrUnique :: Unique -> Unique incrUnique :: Unique -> Unique
deriveUnique :: Unique -> Int -> Unique deriveUnique :: Unique -> Int -> Unique
newTagUnique :: Unique -> Char -> Unique newTagUnique :: Unique -> Char -> Unique
mkUniqueGrimily x = MkUnique (iUnbox x) mkUniqueGrimily = MkUnique
{-# INLINE getKey #-} {-# INLINE getKey #-}
getKey (MkUnique x) = iBox x getKey (MkUnique x) = x
{-# INLINE getKeyFastInt #-}
getKeyFastInt (MkUnique x) = x
incrUnique (MkUnique i) = MkUnique (i +# _ILIT(1)) incrUnique (MkUnique i) = MkUnique (i + 1)
-- deriveUnique uses an 'X' tag so that it won't clash with -- deriveUnique uses an 'X' tag so that it won't clash with
-- any of the uniques produced any other way -- any of the uniques produced any other way
deriveUnique (MkUnique i) delta = mkUnique 'X' (iBox i + delta) deriveUnique (MkUnique i) delta = mkUnique 'X' (i + delta)
-- newTagUnique changes the "domain" of a unique to a different char -- newTagUnique changes the "domain" of a unique to a different char
newTagUnique u c = mkUnique c i where (_,i) = unpkUnique u newTagUnique u c = mkUnique c i where (_,i) = unpkUnique u
...@@ -131,17 +127,17 @@ mkUnique :: Char -> Int -> Unique -- Builds a unique from pieces ...@@ -131,17 +127,17 @@ mkUnique :: Char -> Int -> Unique -- Builds a unique from pieces
-- NOT EXPORTED, so that we can see all the Chars that -- NOT EXPORTED, so that we can see all the Chars that
-- are used in this one module -- are used in this one module
mkUnique c i mkUnique c i
= MkUnique (tag `bitOrFastInt` bits) = MkUnique (tag .|. bits)
where where
!tag = fastOrd (cUnbox c) `shiftLFastInt` _ILIT(24) tag = ord c `shiftL` 24
!bits = iUnbox i `bitAndFastInt` _ILIT(16777215){-``0x00ffffff''-} bits = i .&. 16777215 {-``0x00ffffff''-}
unpkUnique (MkUnique u) unpkUnique (MkUnique u)
= let = let
-- as long as the Char may have its eighth bit set, we -- as long as the Char may have its eighth bit set, we
-- really do need the logical right-shift here! -- really do need the logical right-shift here!
tag = cBox (fastChr (u `shiftRLFastInt` _ILIT(24))) tag = chr (u `shiftR` 24)
i = iBox (u `bitAndFastInt` _ILIT(16777215){-``0x00ffffff''-}) i = u .&. 16777215 {-``0x00ffffff''-}
in in
(tag, i) (tag, i)
...@@ -161,7 +157,7 @@ hasKey :: Uniquable a => a -> Unique -> Bool ...@@ -161,7 +157,7 @@ hasKey :: Uniquable a => a -> Unique -> Bool
x `hasKey` k = getUnique x == k x `hasKey` k = getUnique x == k
instance Uniquable FastString where instance Uniquable FastString where
getUnique fs = mkUniqueGrimily (iBox (uniqueOfFS fs)) getUnique fs = mkUniqueGrimily (uniqueOfFS fs)
instance Uniquable Int where instance Uniquable Int where
getUnique i = mkUniqueGrimily i getUnique i = mkUniqueGrimily i
...@@ -179,13 +175,13 @@ use `deriving' because we want {\em precise} control of ordering ...@@ -179,13 +175,13 @@ use `deriving' because we want {\em precise} control of ordering
-} -}
eqUnique, ltUnique, leUnique :: Unique -> Unique -> Bool eqUnique, ltUnique, leUnique :: Unique -> Unique -> Bool
eqUnique (MkUnique u1) (MkUnique u2) = u1 ==# u2 eqUnique (MkUnique u1) (MkUnique u2) = u1 == u2
ltUnique (MkUnique u1) (MkUnique u2) = u1 <# u2 ltUnique (MkUnique u1) (MkUnique u2) = u1 < u2
leUnique (MkUnique u1) (MkUnique u2) = u1 <=# u2 leUnique (MkUnique u1) (MkUnique u2) = u1 <= u2
cmpUnique :: Unique -> Unique -> Ordering cmpUnique :: Unique -> Unique -> Ordering
cmpUnique (MkUnique u1) (MkUnique u2) cmpUnique (MkUnique u1) (MkUnique u2)
= if u1 ==# u2 then EQ else if u1 <# u2 then LT else GT = if u1 == u2 then EQ else if u1 < u2 then LT else GT
instance Eq Unique where instance Eq Unique where
a == b = eqUnique a b a == b = eqUnique a b
...@@ -239,20 +235,18 @@ Code stolen from Lennart. ...@@ -239,20 +235,18 @@ Code stolen from Lennart.
iToBase62 :: Int -> String iToBase62 :: Int -> String
iToBase62 n_ iToBase62 n_
= ASSERT(n_ >= 0) go (iUnbox n_) "" = ASSERT(n_ >= 0) go n_ ""
where where
go n cs | n <# _ILIT(62) go n cs | n < 62
= case chooseChar62 n of { c -> c `seq` (c : cs) } = let !c = chooseChar62 n in c : cs
| otherwise | otherwise
= case (quotRem (iBox n) 62) of { (q_, r_) -> = go q (c : cs) where (q, r) = quotRem n 62
case iUnbox q_ of { q -> case iUnbox r_ of { r -> !c = chooseChar62 r
case (chooseChar62 r) of { c -> c `seq`
(go q (c : cs)) }}}} chooseChar62 :: Int -> Char
chooseChar62 :: FastInt -> Char
{-# INLINE chooseChar62 #-} {-# INLINE chooseChar62 #-}
chooseChar62 n = C# (indexCharOffAddr# chars62 n) chooseChar62 (I# n) = C# (indexCharOffAddr# chars62 n)
!chars62 = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"# chars62 = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"#
{- {-
************************************************************************ ************************************************************************
...@@ -345,7 +339,7 @@ mkCostCentreUnique = mkUnique 'C' ...@@ -345,7 +339,7 @@ mkCostCentreUnique = mkUnique 'C'
mkVarOccUnique, mkDataOccUnique, mkTvOccUnique, mkTcOccUnique :: FastString -> Unique mkVarOccUnique, mkDataOccUnique, mkTvOccUnique, mkTcOccUnique :: FastString -> Unique
-- See Note [The Unique of an OccName] in OccName -- See Note [The Unique of an OccName] in OccName
mkVarOccUnique fs = mkUnique 'i' (iBox (uniqueOfFS fs)) mkVarOccUnique fs = mkUnique 'i' (uniqueOfFS fs)
mkDataOccUnique fs = mkUnique 'd' (iBox (uniqueOfFS fs)) mkDataOccUnique fs = mkUnique 'd' (uniqueOfFS fs)
mkTvOccUnique fs = mkUnique 'v' (iBox (uniqueOfFS fs)) mkTvOccUnique fs = mkUnique 'v' (uniqueOfFS fs)
mkTcOccUnique fs = mkUnique 'c' (iBox (uniqueOfFS fs)) mkTcOccUnique fs = mkUnique 'c' (uniqueOfFS fs)
...@@ -75,7 +75,6 @@ import {-# SOURCE #-} IdInfo( IdDetails, IdInfo, coVarDetails, vanillaIdInfo, ...@@ -75,7 +75,6 @@ import {-# SOURCE #-} IdInfo( IdDetails, IdInfo, coVarDetails, vanillaIdInfo,
import Name hiding (varName) import Name hiding (varName)
import Unique import Unique
import Util import Util
import FastTypes
import FastString import FastString
import Outputable import Outputable
...@@ -154,7 +153,8 @@ data Var ...@@ -154,7 +153,8 @@ data Var
= TyVar { -- Type and kind variables = TyVar { -- Type and kind variables
-- see Note [Kind and type variables] -- see Note [Kind and type variables]
varName :: !Name, varName :: !Name,
realUnique :: FastInt, -- Key for fast comparison realUnique :: {-# UNPACK #-} !Int,
-- ^ Key for fast comparison
-- Identical to the Unique in the name, -- Identical to the Unique in the name,
-- cached here for speed -- cached here for speed
varType :: Kind -- ^ The type or kind of the 'Var' in question varType :: Kind -- ^ The type or kind of the 'Var' in question
...@@ -164,13 +164,13 @@ data Var ...@@ -164,13 +164,13 @@ data Var
-- Used for kind variables during -- Used for kind variables during
-- inference, as well -- inference, as well
varName :: !Name, varName :: !Name,
realUnique :: FastInt, realUnique :: {-# UNPACK #-} !Int,
varType :: Kind, varType :: Kind,
tc_tv_details :: TcTyVarDetails } tc_tv_details :: TcTyVarDetails }
| Id { | Id {
varName :: !Name, varName :: !Name,
realUnique :: FastInt, realUnique :: {-# UNPACK #-} !Int,
varType :: Type, varType :: Type,
idScope :: IdScope, idScope :: IdScope,
id_details :: IdDetails, -- Stable, doesn't change id_details :: IdDetails, -- Stable, doesn't change
...@@ -228,13 +228,13 @@ instance Uniquable Var where ...@@ -228,13 +228,13 @@ instance Uniquable Var where
getUnique = varUnique getUnique = varUnique
instance Eq Var where instance Eq Var where
a == b = realUnique a ==# realUnique b a == b = realUnique a == realUnique b
instance Ord Var where instance Ord Var where
a <= b = realUnique a <=# realUnique b a <= b = realUnique a <= realUnique b
a < b = realUnique a <# realUnique b a < b = realUnique a < realUnique b
a >= b = realUnique a >=# realUnique b a >= b = realUnique a >= realUnique b
a > b = realUnique a ># realUnique b a > b = realUnique a > realUnique b
a `compare` b = varUnique a `compare` varUnique b a `compare` b = varUnique a `compare` varUnique b
instance Data Var where instance Data Var where
...@@ -244,16 +244,16 @@ instance Data Var where ...@@ -244,16 +244,16 @@ instance Data Var where
dataTypeOf _ = mkNoRepType "Var" dataTypeOf _ = mkNoRepType "Var"
varUnique :: Var -> Unique varUnique :: Var -> Unique