[commit: ghc] master: Use UniqFM for SigOf (586d558)

git at git.haskell.org git at git.haskell.org
Mon Jun 13 18:31:42 UTC 2016


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/586d55815401c54f4687d053fb033e53865e0bf1/ghc

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

commit 586d55815401c54f4687d053fb033e53865e0bf1
Author: Bartosz Nitka <niteria at gmail.com>
Date:   Mon Jun 13 07:35:32 2016 -0700

    Use UniqFM for SigOf
    
    Summary:
    The Ord instance for ModuleName is currently implemented in
    terms of Uniques causing potential determinism problems.
    I plan to change it to use the actual FastStrings and in
    preparation for that I'm switching to UniqFM where it's
    possible (you need *one* Unique per key, and you can't get
    the keys back), so that the performance doesn't suffer.
    
    Test Plan: ./validate
    
    Reviewers: simonmar, austin, ezyang, bgamari
    
    Reviewed By: bgamari
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D2320
    
    GHC Trac Issues: #4012


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

586d55815401c54f4687d053fb033e53865e0bf1
 compiler/main/DynFlags.hs | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index 5515b8c..ffb5b33 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -164,6 +164,7 @@ import CmdLineParser
 import Constants
 import Panic
 import Util
+import UniqFM
 import Maybes
 import MonadUtils
 import qualified Pretty
@@ -633,10 +634,10 @@ instance Show SafeHaskellMode where
 instance Outputable SafeHaskellMode where
     ppr = text . show
 
-type SigOf = Map ModuleName Module
+type SigOf = ModuleNameEnv Module
 
 getSigOf :: DynFlags -> ModuleName -> Maybe Module
-getSigOf dflags n = Map.lookup n (sigOf dflags)
+getSigOf dflags n = lookupUFM (sigOf dflags) n
 
 -- | Contains not only a collection of 'GeneralFlag's but also a plethora of
 -- information relating to the compilation of a single file or GHC session
@@ -1442,7 +1443,7 @@ defaultDynFlags mySettings =
         ghcMode                 = CompManager,
         ghcLink                 = LinkBinary,
         hscTarget               = defaultHscTarget (sTargetPlatform mySettings),
-        sigOf                   = Map.empty,
+        sigOf                   = emptyUFM,
         verbosity               = 0,
         optLevel                = 0,
         debugLevel              = 0,
@@ -1991,7 +1992,7 @@ parseSigOf :: String -> SigOf
 parseSigOf str = case filter ((=="").snd) (readP_to_S parse str) of
     [(r, "")] -> r
     _ -> throwGhcException $ CmdLineError ("Can't parse -sig-of: " ++ str)
-  where parse = Map.fromList <$> sepBy parseEntry (R.char ',')
+  where parse = listToUFM <$> sepBy parseEntry (R.char ',')
         parseEntry = do
             n <- tok $ parseModuleName
             -- ToDo: deprecate this 'is' syntax?



More information about the ghc-commits mailing list