summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Palka <patrick@parcs.ath.cx>2013-08-21 16:47:04 -0400
committerPatrick Palka <patrick@parcs.ath.cx>2013-08-26 22:21:16 -0400
commit27d189a7fa833cb6bb33ff001d5472fbf1f589f1 (patch)
tree0d64cd0a361058b3bbeba5dfe9af91a5f724653c
parent74762a5c4db32f7ce549dd4883f08267cc7eab4b (diff)
downloadhaskell-27d189a7fa833cb6bb33ff001d5472fbf1f589f1.tar.gz
TidyPgm: Atomically update the NameCache in tidyTopName
-rw-r--r--compiler/main/TidyPgm.lhs10
1 files changed, 3 insertions, 7 deletions
diff --git a/compiler/main/TidyPgm.lhs b/compiler/main/TidyPgm.lhs
index be4c683276..174054ee61 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"