summaryrefslogtreecommitdiff
path: root/libraries
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2023-03-27 13:00:49 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2023-04-03 08:15:21 -0400
commitab9cd52d4fac34a2b37ce07bc9e9e2943c92d181 (patch)
tree08b3c17606c07d99dcee06b3e502656d3546d22e /libraries
parent43ebd5dcdb7ff65b6afccbdee22d2c27f9df6b1c (diff)
downloadhaskell-ab9cd52d4fac34a2b37ce07bc9e9e2943c92d181.tar.gz
ghc-heap: remove wrong Addr# coercion (#23181)
Conversion from Addr# to I# isn't correct with the JS backend.
Diffstat (limited to 'libraries')
-rw-r--r--libraries/ghc-heap/GHC/Exts/Heap.hs2
-rw-r--r--libraries/ghc-heap/GHC/Exts/Heap/Closures.hs2
-rw-r--r--libraries/ghc-heap/tests/heap_all.hs5
3 files changed, 5 insertions, 4 deletions
diff --git a/libraries/ghc-heap/GHC/Exts/Heap.hs b/libraries/ghc-heap/GHC/Exts/Heap.hs
index ac954bba8b..2652515af9 100644
--- a/libraries/ghc-heap/GHC/Exts/Heap.hs
+++ b/libraries/ghc-heap/GHC/Exts/Heap.hs
@@ -120,7 +120,7 @@ instance Word64# ~ a => HasHeapRep (a :: TYPE 'Word64Rep) where
instance Addr# ~ a => HasHeapRep (a :: TYPE 'AddrRep) where
getClosureData x = return $
- AddrClosure { ptipe = PAddr, addrVal = I# (unsafeCoerce# x) }
+ AddrClosure { ptipe = PAddr, addrVal = Ptr x }
instance Float# ~ a => HasHeapRep (a :: TYPE 'FloatRep) where
getClosureData x = return $
diff --git a/libraries/ghc-heap/GHC/Exts/Heap/Closures.hs b/libraries/ghc-heap/GHC/Exts/Heap/Closures.hs
index 6078a927bf..a65eb9cbed 100644
--- a/libraries/ghc-heap/GHC/Exts/Heap/Closures.hs
+++ b/libraries/ghc-heap/GHC/Exts/Heap/Closures.hs
@@ -329,7 +329,7 @@ data GenClosure b
-- | Primitive Addr
| AddrClosure
{ ptipe :: PrimType
- , addrVal :: !Int }
+ , addrVal :: !(Ptr ()) }
-- | Primitive Float
| FloatClosure
diff --git a/libraries/ghc-heap/tests/heap_all.hs b/libraries/ghc-heap/tests/heap_all.hs
index ac8953b5d2..482b424283 100644
--- a/libraries/ghc-heap/tests/heap_all.hs
+++ b/libraries/ghc-heap/tests/heap_all.hs
@@ -12,6 +12,7 @@ import GHC.Int
import GHC.IO
import GHC.IORef
import GHC.MVar
+import GHC.Ptr
import GHC.Stack
import GHC.STRef
import GHC.Weak
@@ -176,7 +177,7 @@ exWord64Closure = Word64Closure
exAddrClosure :: Closure
exAddrClosure = AddrClosure
- { ptipe = PAddr, addrVal = 42 }
+ { ptipe = PAddr, addrVal = nullPtr `plusPtr` 42 }
exFloatClosure :: Closure
exFloatClosure = FloatClosure
@@ -328,7 +329,7 @@ main = do
-- assertClosuresEq exWord64Closure
-- Primitive Addr
- let v = unsafeCoerce# 42# :: Addr#
+ let (Ptr v) = nullPtr `plusPtr` 42
getClosureData v >>=
assertClosuresEq exAddrClosure