diff options
author | Bartosz Nitka <niteria@gmail.com> | 2016-06-02 11:36:44 -0700 |
---|---|---|
committer | Bartosz Nitka <niteria@gmail.com> | 2016-06-02 12:49:29 -0700 |
commit | d753ea2a546733cb29c2970232ac870023aee22f (patch) | |
tree | a4f7bf1f3899298c74630884ee3ddf1ac9de651e /compiler/ghci | |
parent | dad39ff04a6585ab9cf3a2572ea922e309e6385f (diff) | |
download | haskell-d753ea2a546733cb29c2970232ac870023aee22f.tar.gz |
Use UniqDSet for finding free names in the Linker
This is not necessary for determinism, but it's a choice
between making this deterministic and using `nonDetEltsUFM`
and a comment explaining that it doesn't matter.
Test Plan: ./validate
Reviewers: austin, hvr, bgamari, simonmar
Reviewed By: simonmar
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2295
GHC Trac Issues: #4012
Diffstat (limited to 'compiler/ghci')
-rw-r--r-- | compiler/ghci/ByteCodeAsm.hs | 11 | ||||
-rw-r--r-- | compiler/ghci/Linker.hs | 7 |
2 files changed, 10 insertions, 8 deletions
diff --git a/compiler/ghci/ByteCodeAsm.hs b/compiler/ghci/ByteCodeAsm.hs index f765a7d2f4..817e379003 100644 --- a/compiler/ghci/ByteCodeAsm.hs +++ b/compiler/ghci/ByteCodeAsm.hs @@ -34,6 +34,7 @@ import Outputable import Platform import Util import Unique +import UniqDSet -- From iserv import SizedSeq @@ -65,14 +66,14 @@ import qualified Data.Map as Map -- | Finds external references. Remember to remove the names -- defined by this group of BCOs themselves -bcoFreeNames :: UnlinkedBCO -> NameSet +bcoFreeNames :: UnlinkedBCO -> UniqDSet Name bcoFreeNames bco - = bco_refs bco `minusNameSet` mkNameSet [unlinkedBCOName bco] + = bco_refs bco `uniqDSetMinusUniqSet` mkNameSet [unlinkedBCOName bco] where bco_refs (UnlinkedBCO _ _ _ _ nonptrs ptrs) - = unionNameSets ( - mkNameSet [ n | BCOPtrName n <- ssElts ptrs ] : - mkNameSet [ n | BCONPtrItbl n <- ssElts nonptrs ] : + = unionManyUniqDSets ( + mkUniqDSet [ n | BCOPtrName n <- ssElts ptrs ] : + mkUniqDSet [ n | BCONPtrItbl n <- ssElts nonptrs ] : map bco_refs [ bco | BCOPtrBCO bco <- ssElts ptrs ] ) diff --git a/compiler/ghci/Linker.hs b/compiler/ghci/Linker.hs index 5042136ce3..0f15ea2877 100644 --- a/compiler/ghci/Linker.hs +++ b/compiler/ghci/Linker.hs @@ -37,7 +37,6 @@ import Finder import HscTypes import Name import NameEnv -import NameSet import UniqFM import Module import ListSetOps @@ -50,6 +49,7 @@ import ErrUtils import SrcLoc import qualified Maybes import UniqSet +import UniqDSet import FastString import Platform import SysTools @@ -504,7 +504,7 @@ linkExpr hsc_env span root_ul_bco ; return (pls, fhv) }}} where - free_names = nameSetElems (bcoFreeNames root_ul_bco) + free_names = uniqDSetToList (bcoFreeNames root_ul_bco) needed_mods :: [Module] needed_mods = [ nameModule n | n <- free_names, @@ -730,7 +730,8 @@ linkDecls hsc_env span cbc@CompiledByteCode{..} = do , itbl_env = ie } return (pls2, ()) where - free_names = concatMap (nameSetElems . bcoFreeNames) bc_bcos + free_names = uniqDSetToList $ + foldr (unionUniqDSets . bcoFreeNames) emptyUniqDSet bc_bcos needed_mods :: [Module] needed_mods = [ nameModule n | n <- free_names, |