diff options
author | Patrick Palka <patrick@parcs.ath.cx> | 2013-08-21 15:25:18 -0400 |
---|---|---|
committer | Patrick Palka <patrick@parcs.ath.cx> | 2013-08-26 22:21:16 -0400 |
commit | 036910ad0d01cfd23fa53930fca2dd880faa6536 (patch) | |
tree | 069d6bff28cde8dd1b09835972e299966f16fd3d /compiler/cbits | |
parent | 776cfe28cf089c24a56a288f2f0c49494f7d9e47 (diff) | |
download | haskell-036910ad0d01cfd23fa53930fca2dd880faa6536.tar.gz |
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.
Diffstat (limited to 'compiler/cbits')
-rw-r--r-- | compiler/cbits/genSym.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/cbits/genSym.c b/compiler/cbits/genSym.c index 2d9779b898..8614e97e75 100644 --- a/compiler/cbits/genSym.c +++ b/compiler/cbits/genSym.c @@ -4,6 +4,10 @@ static HsInt GenSymCounter = 0; HsInt genSym(void) { - return GenSymCounter++; + if (n_capabilities == 1) { + return GenSymCounter++; + } else { + return atomic_inc((StgWord *)&GenSymCounter); + } } |