diff options
author | Peter Trommler <ptrommler@acm.org> | 2021-04-17 17:59:44 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-08-02 04:11:27 -0400 |
commit | b4d39adbb5884c764c6c11b2614a340c78cc078e (patch) | |
tree | 57eb45d9078c90c34f8743b961bf87789e292ae8 /rts | |
parent | 7e8c578ed9d3469d6a5c1481f9482982c42f10ea (diff) | |
download | haskell-b4d39adbb5884c764c6c11b2614a340c78cc078e.tar.gz |
PrimOps: Add CAS op for all int sizes
PPC NCG: Implement CAS inline for 32 and 64 bit
testsuite: Add tests for smaller atomic CAS
X86 NCG: Catch calls to CAS C fallback
Primops: Add atomicCasWord[8|16|32|64]Addr#
Add tests for atomicCasWord[8|16|32|64]Addr#
Add changelog entry for new primops
X86 NCG: Fix MO-Cmpxchg W64 on 32-bit arch
ghc-prim: 64-bit CAS C fallback on all archs
Diffstat (limited to 'rts')
-rw-r--r-- | rts/PrimOps.cmm | 52 | ||||
-rw-r--r-- | rts/RtsSymbols.c | 4 | ||||
-rw-r--r-- | rts/package.conf.in | 4 | ||||
-rw-r--r-- | rts/rts.cabal.in | 4 |
4 files changed, 58 insertions, 6 deletions
diff --git a/rts/PrimOps.cmm b/rts/PrimOps.cmm index 85c708cf92..8f99105b18 100644 --- a/rts/PrimOps.cmm +++ b/rts/PrimOps.cmm @@ -264,6 +264,58 @@ stg_casIntArrayzh( gcptr arr, W_ ind, W_ old, W_ new ) } +stg_casInt8Arrayzh( gcptr arr, W_ ind, I8 old, I8 new ) +/* MutableByteArray# s -> Int# -> Int8# -> Int8# -> State# s -> (# State# s, Int8# #) */ +{ + W_ p; + I8 h; + + p = arr + SIZEOF_StgArrBytes + ind; + (h) = prim %cmpxchg8(p, old, new); + + return(h); +} + + +stg_casInt16Arrayzh( gcptr arr, W_ ind, I16 old, I16 new ) +/* MutableByteArray# s -> Int# -> Int16# -> Int16# -> State# s -> (# State# s, Int16# #) */ +{ + W_ p; + I16 h; + + p = arr + SIZEOF_StgArrBytes + ind*2; + (h) = prim %cmpxchg16(p, old, new); + + return(h); +} + + +stg_casInt32Arrayzh( gcptr arr, W_ ind, I32 old, I32 new ) +/* MutableByteArray# s -> Int# -> Int32# -> Int32# -> State# s -> (# State# s, Int32# #) */ +{ + W_ p; + I32 h; + + p = arr + SIZEOF_StgArrBytes + ind*4; + (h) = prim %cmpxchg32(p, old, new); + + return(h); +} + + +stg_casInt64Arrayzh( gcptr arr, W_ ind, I64 old, I64 new ) +/* MutableByteArray# s -> Int# -> Int64# -> Int64# -> State# s -> (# State# s, Int64# #) */ +{ + W_ p; + I64 h; + + p = arr + SIZEOF_StgArrBytes + ind*8; + (h) = prim %cmpxchg64(p, old, new); + + return(h); +} + + stg_newArrayzh ( W_ n /* words */, gcptr init ) { W_ words, size, p; diff --git a/rts/RtsSymbols.c b/rts/RtsSymbols.c index 678527e328..38e1b8071c 100644 --- a/rts/RtsSymbols.c +++ b/rts/RtsSymbols.c @@ -721,6 +721,10 @@ SymI_HasProto(stg_newBCOzh) \ SymI_HasProto(stg_newByteArrayzh) \ SymI_HasProto(stg_casIntArrayzh) \ + SymI_HasProto(stg_casInt8Arrayzh) \ + SymI_HasProto(stg_casInt16Arrayzh) \ + SymI_HasProto(stg_casInt32Arrayzh) \ + SymI_HasProto(stg_casInt64Arrayzh) \ SymI_HasProto(stg_newMVarzh) \ SymI_HasProto(stg_newMutVarzh) \ SymI_HasProto(stg_newTVarzh) \ diff --git a/rts/package.conf.in b/rts/package.conf.in index 9bc48d57ca..b0796595ff 100644 --- a/rts/package.conf.in +++ b/rts/package.conf.in @@ -170,9 +170,7 @@ ld-options: , "-Wl,-u,_hs_cmpxchg8" , "-Wl,-u,_hs_cmpxchg16" , "-Wl,-u,_hs_cmpxchg32" -#if WORD_SIZE_IN_BITS == 64 , "-Wl,-u,_hs_cmpxchg64" -#endif , "-Wl,-u,_hs_xchg8" , "-Wl,-u,_hs_xchg16" , "-Wl,-u,_hs_xchg32" @@ -284,9 +282,7 @@ ld-options: , "-Wl,-u,hs_cmpxchg8" , "-Wl,-u,hs_cmpxchg16" , "-Wl,-u,hs_cmpxchg32" -#if WORD_SIZE_IN_BITS == 64 , "-Wl,-u,hs_cmpxchg64" -#endif , "-Wl,-u,hs_xchg8" , "-Wl,-u,hs_xchg16" , "-Wl,-u,hs_xchg32" diff --git a/rts/rts.cabal.in b/rts/rts.cabal.in index 3ceae1cbdc..a08e007c2a 100644 --- a/rts/rts.cabal.in +++ b/rts/rts.cabal.in @@ -220,7 +220,6 @@ library "-Wl,-u,_hs_atomic_nand64" "-Wl,-u,_hs_atomic_or64" "-Wl,-u,_hs_atomic_xor64" - "-Wl,-u,_hs_cmpxchg64" "-Wl,-u,_hs_atomicread64" "-Wl,-u,_hs_atomicwrite64" else @@ -231,7 +230,6 @@ library "-Wl,-u,hs_atomic_nand64" "-Wl,-u,hs_atomic_or64" "-Wl,-u,hs_atomic_xor64" - "-Wl,-u,hs_cmpxchg64" "-Wl,-u,hs_atomicread64" "-Wl,-u,hs_atomicwrite64" if flag(leading-underscore) @@ -299,6 +297,7 @@ library "-Wl,-u,_hs_cmpxchg8" "-Wl,-u,_hs_cmpxchg16" "-Wl,-u,_hs_cmpxchg32" + "-Wl,-u,_hs_cmpxchg64" "-Wl,-u,_hs_xchg8" "-Wl,-u,_hs_xchg16" "-Wl,-u,_hs_xchg32" @@ -380,6 +379,7 @@ library "-Wl,-u,hs_cmpxchg8" "-Wl,-u,hs_cmpxchg16" "-Wl,-u,hs_cmpxchg32" + "-Wl,-u,hs_cmpxchg64" "-Wl,-u,hs_xchg8" "-Wl,-u,hs_xchg16" "-Wl,-u,hs_xchg32" |