[Git][ghc/ghc][wip/T18078] Optimisation in Unique.Supply
Simon Peyton Jones
gitlab at gitlab.haskell.org
Fri May 22 23:15:05 UTC 2020
Simon Peyton Jones pushed to branch wip/T18078 at Glasgow Haskell Compiler / GHC
Commits:
69c0e16e by Simon Peyton Jones at 2020-05-23T00:14:17+01:00
Optimisation in Unique.Supply
Will need a proper Note; putting it up for CI for now
- - - - -
1 changed file:
- compiler/GHC/Types/Unique/Supply.hs
Changes:
=====================================
compiler/GHC/Types/Unique/Supply.hs
=====================================
@@ -3,6 +3,7 @@
(c) The GRASP/AQUA Project, Glasgow University, 1992-1998
-}
+{-# OPTIONS_GHC -fno-state-hack #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE PatternSynonyms #-}
@@ -89,21 +90,18 @@ uniqFromMask mask
; return $! mkUnique mask uqNum }
mkSplitUniqSupply c
- = case ord c `shiftL` uNIQUE_BITS of
- !mask -> let
- -- here comes THE MAGIC:
+ = mk_supply
+ where
+ !mask = ord c `shiftL` uNIQUE_BITS
+ -- Here comes THE MAGIC:
-- This is one of the most hammered bits in the whole compiler
- mk_supply
- -- NB: Use unsafeInterleaveIO for thread-safety.
- = unsafeInterleaveIO (
- genSym >>= \ u ->
- mk_supply >>= \ s1 ->
- mk_supply >>= \ s2 ->
- return (MkSplitUniqSupply (mask .|. u) s1 s2)
- )
- in
- mk_supply
+ -- NB: Use unsafeInterleaveIO for thread-safety.
+ mk_supply = unsafeInterleaveIO $
+ genSym >>= \ u ->
+ mk_supply >>= \ s1 ->
+ mk_supply >>= \ s2 ->
+ return (MkSplitUniqSupply (mask .|. u) s1 s2)
foreign import ccall unsafe "genSym" genSym :: IO Int
foreign import ccall unsafe "initGenSym" initUniqSupply :: Int -> Int -> IO ()
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/69c0e16e9ce9fe045851c09425956fa3407824ae
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/69c0e16e9ce9fe045851c09425956fa3407824ae
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20200522/b5466301/attachment-0001.html>
More information about the ghc-commits
mailing list