[Git][ghc/ghc][wip/js-staging] Fix InterlockedExchange primops (cgrun080)
Sylvain Henry (@hsyl20)
gitlab at gitlab.haskell.org
Mon Oct 3 15:07:36 UTC 2022
Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC
Commits:
8913653a by Sylvain Henry at 2022-10-03T17:10:46+02:00
Fix InterlockedExchange primops (cgrun080)
- - - - -
1 changed file:
- compiler/GHC/StgToJS/Prim.hs
Changes:
=====================================
compiler/GHC/StgToJS/Prim.hs
=====================================
@@ -1200,14 +1200,28 @@ genPrim prof ty op = case op of
FetchOrAddrOp_Word -> \[r] [a,o,v] -> PrimInline $ fetchOpAddr BOr r a o v
FetchXorAddrOp_Word -> \[r] [a,o,v] -> PrimInline $ fetchOpAddr BXor r a o v
- InterlockedExchange_Addr -> \[r_a,r_o] [a1,o1,a2,o2] -> PrimInline $
- mconcat [ r_a |= a1
- , r_o |= o1
- , a1 .! o1 |= a2 .! o2
- , o1 |= o2
- ]
+ InterlockedExchange_Addr -> \[r_a,r_o] [a1,o1,_a2,o2] -> PrimInline $
+ -- this primop can't be implemented
+ -- correctly because we don't store
+ -- the array reference part of an Addr#,
+ -- only the offset part.
+ --
+ -- So let's assume that all the array
+ -- references are the same...
+ --
+ -- Note: we could generate an assert
+ -- that checks that a1 === a2. However
+ -- we can't check that the Addr# read
+ -- at Addr# a2[o2] also comes from this
+ -- a1/a2 array.
+ mconcat [ r_a |= a1 -- might be wrong (see above)
+ , r_o |= dv_u32 a1 o1
+ -- TODO (see above)
+ -- assert that a1 === a2
+ , dv_s_u32 a1 o1 o2
+ ]
InterlockedExchange_Word -> \[r] [a,o,w] -> PrimInline $
- mconcat [ r |= a .! o
+ mconcat [ r |= dv_u32 a o
, dv_s_u32 a o w
]
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8913653ab076b3e1f24dca2e6d276f1d14a2b6f5
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8913653ab076b3e1f24dca2e6d276f1d14a2b6f5
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/20221003/e73dc408/attachment-0001.html>
More information about the ghc-commits
mailing list