[commit: ghc] master: Use UniqDSet for finding free names in the Linker (d753ea2)
git at git.haskell.org
git at git.haskell.org
Thu Jun 2 19:46:43 UTC 2016
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/d753ea2a546733cb29c2970232ac870023aee22f/ghc
>---------------------------------------------------------------
commit d753ea2a546733cb29c2970232ac870023aee22f
Author: Bartosz Nitka <niteria at gmail.com>
Date: Thu Jun 2 11:36:44 2016 -0700
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
>---------------------------------------------------------------
d753ea2a546733cb29c2970232ac870023aee22f
compiler/ghci/ByteCodeAsm.hs | 11 ++++++-----
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 f765a7d..817e379 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 5042136..0f15ea2 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 at 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,
More information about the ghc-commits
mailing list