summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2023-03-27 13:00:49 +0200
committerMatthew Pickering <matthewtpickering@gmail.com>2023-03-30 10:02:27 +0100
commit6e11395a774f0fd1ab4b33f145ce6aeadcdddeaf (patch)
tree00115a1c7bbe1c3aacee9bcd383213df2a9d0c61
parent98b5cf67f8428b0daefcbf5df121df0b8a126654 (diff)
downloadhaskell-wip/23181-2.tar.gz
ghc-heap: remove wrong Addr# coercion (#23181)wip/23181-2
Conversion from Addr# to I# isn't correct with the JS backend.
-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