UniqSupply: make mkSplitUniqSupply thread-safe
authorPatrick Palka <patrick@parcs.ath.cx>
Wed, 21 Aug 2013 19:25:18 +0000 (15:25 -0400)
committerPatrick Palka <patrick@parcs.ath.cx>
Tue, 27 Aug 2013 02:21:16 +0000 (22:21 -0400)
commit036910ad0d01cfd23fa53930fca2dd880faa6536
tree069d6bff28cde8dd1b09835972e299966f16fd3d
parent776cfe28cf089c24a56a288f2f0c49494f7d9e47
UniqSupply: make mkSplitUniqSupply thread-safe

unsafeInterleaveIO is used instead of unsafeDupableInterleaveIO because
a mk_supply thunk that is simultaneously entered by two threads should
evaluate to the same UniqSupply.

The UniqSupply counter is now incremented atomically using the RTS's
atomic_inc().

To mitigate the extra overhead of unsafeInterleaveIO in the
single-threaded compiler, noDuplicate# is changed to exit early when
n_capabilities == 1.
compiler/basicTypes/UniqSupply.lhs
compiler/cbits/genSym.c
compiler/ghc.mk
rts/PrimOps.cmm