[commit: ghc] ghc-parmake-gsoc: TidyPgm: Atomically update the NameCache in tidyTopName (27d189a)

git at git.haskell.org git at git.haskell.org
Tue Aug 27 16:11:38 CEST 2013


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

On branch  : ghc-parmake-gsoc
Link       : http://ghc.haskell.org/trac/ghc/changeset/27d189a7fa833cb6bb33ff001d5472fbf1f589f1/ghc

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

commit 27d189a7fa833cb6bb33ff001d5472fbf1f589f1
Author: Patrick Palka <patrick at parcs.ath.cx>
Date:   Wed Aug 21 16:47:04 2013 -0400

    TidyPgm: Atomically update the NameCache in tidyTopName


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

27d189a7fa833cb6bb33ff001d5472fbf1f589f1
 compiler/main/TidyPgm.lhs |   10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/compiler/main/TidyPgm.lhs b/compiler/main/TidyPgm.lhs
index be4c683..174054e 100644
--- a/compiler/main/TidyPgm.lhs
+++ b/compiler/main/TidyPgm.lhs
@@ -58,7 +58,7 @@ import qualified ErrUtils as Err
 import Control.Monad
 import Data.Function
 import Data.List        ( sortBy )
-import Data.IORef       ( readIORef, writeIORef )
+import Data.IORef       ( atomicModifyIORef )
 \end{code}
 
 
@@ -857,9 +857,7 @@ tidyTopName mod nc_var maybe_ref occ_env id
   -- Now we get to the real reason that all this is in the IO Monad:
   -- we have to update the name cache in a nice atomic fashion
 
-  | local  && internal = do { nc <- readIORef nc_var
-                            ; let (nc', new_local_name) = mk_new_local nc
-                            ; writeIORef nc_var nc'
+  | local  && internal = do { new_local_name <- atomicModifyIORef nc_var mk_new_local
                             ; return (occ_env', new_local_name) }
         -- Even local, internal names must get a unique occurrence, because
         -- if we do -split-objs we externalise the name later, in the code generator
@@ -867,9 +865,7 @@ tidyTopName mod nc_var maybe_ref occ_env id
         -- Similarly, we must make sure it has a system-wide Unique, because
         -- the byte-code generator builds a system-wide Name->BCO symbol table
 
-  | local  && external = do { nc <- readIORef nc_var
-                            ; let (nc', new_external_name) = mk_new_external nc
-                            ; writeIORef nc_var nc'
+  | local  && external = do { new_external_name <- atomicModifyIORef nc_var mk_new_external
                             ; return (occ_env', new_external_name) }
 
   | otherwise = panic "tidyTopName"





More information about the ghc-commits mailing list