summaryrefslogtreecommitdiff
path: root/libraries
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2023-03-30 09:58:40 +0100
committerMatthew Pickering <matthewtpickering@gmail.com>2023-03-30 09:58:40 +0100
commit98b5cf67f8428b0daefcbf5df121df0b8a126654 (patch)
treed173213b91f93bd1758c276a6504bb494834fa34 /libraries
parenta5360490949533933dc8d76237ea87d920d7e311 (diff)
downloadhaskell-98b5cf67f8428b0daefcbf5df121df0b8a126654.tar.gz
Revert "ghc-heap: remove wrong Addr# coercion (#23181)"
This reverts commit f4f1f14f8009c3c120b8b963ec130cbbc774ec02. This fails to build with GHC-9.2 as a boot compiler. See #23195 for tracking this issue.
Diffstat (limited to 'libraries')
-rw-r--r--libraries/ghc-heap/GHC/Exts/Heap.hs6
-rw-r--r--libraries/ghc-heap/GHC/Exts/Heap/Closures.hs2
-rw-r--r--libraries/ghc-heap/tests/heap_all.hs19
3 files changed, 14 insertions, 13 deletions
diff --git a/libraries/ghc-heap/GHC/Exts/Heap.hs b/libraries/ghc-heap/GHC/Exts/Heap.hs
index 173eca29e4..ac954bba8b 100644
--- a/libraries/ghc-heap/GHC/Exts/Heap.hs
+++ b/libraries/ghc-heap/GHC/Exts/Heap.hs
@@ -112,15 +112,15 @@ instance Word# ~ a => HasHeapRep (a :: TYPE 'WordRep) where
instance Int64# ~ a => HasHeapRep (a :: TYPE 'Int64Rep) where
getClosureData x = return $
- Int64Closure { ptipe = PInt64, int64Val = I64# x }
+ Int64Closure { ptipe = PInt64, int64Val = I64# (unsafeCoerce# x) }
instance Word64# ~ a => HasHeapRep (a :: TYPE 'Word64Rep) where
getClosureData x = return $
- Word64Closure { ptipe = PWord64, word64Val = W64# x }
+ Word64Closure { ptipe = PWord64, word64Val = W64# (unsafeCoerce# x) }
instance Addr# ~ a => HasHeapRep (a :: TYPE 'AddrRep) where
getClosureData x = return $
- AddrClosure { ptipe = PAddr, addrVal = Ptr x }
+ AddrClosure { ptipe = PAddr, addrVal = I# (unsafeCoerce# 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 a65eb9cbed..6078a927bf 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 :: !(Ptr ()) }
+ , addrVal :: !Int }
-- | Primitive Float
| FloatClosure
diff --git a/libraries/ghc-heap/tests/heap_all.hs b/libraries/ghc-heap/tests/heap_all.hs
index 8cc9afce95..ac8953b5d2 100644
--- a/libraries/ghc-heap/tests/heap_all.hs
+++ b/libraries/ghc-heap/tests/heap_all.hs
@@ -12,7 +12,6 @@ import GHC.Int
import GHC.IO
import GHC.IORef
import GHC.MVar
-import GHC.Ptr
import GHC.Stack
import GHC.STRef
import GHC.Weak
@@ -177,7 +176,7 @@ exWord64Closure = Word64Closure
exAddrClosure :: Closure
exAddrClosure = AddrClosure
- { ptipe = PAddr, addrVal = nullPtr `plusPtr` 42 }
+ { ptipe = PAddr, addrVal = 42 }
exFloatClosure :: Closure
exFloatClosure = FloatClosure
@@ -317,17 +316,19 @@ main = do
assertClosuresEq exWordClosure
-- Primitive Int64
- let (I64# v) = 42
- getClosureData v >>=
- assertClosuresEq exInt64Closure
+ -- FAILING: On 64-bit platforms, v is a regular Int
+ -- let (I64# v) = 42
+ -- getClosureData v >>=
+ -- assertClosuresEq exInt64Closure
-- Primitive Word64
- let (W64# v) = 42
- getClosureData v >>=
- assertClosuresEq exWord64Closure
+ -- FAILING: On 64-bit platforms, v is a regular Word
+ -- let (W64# v) = 42
+ -- getClosureData v >>=
+ -- assertClosuresEq exWord64Closure
-- Primitive Addr
- let (Ptr v) = nullPtr `plusPtr` 42
+ let v = unsafeCoerce# 42# :: Addr#
getClosureData v >>=
assertClosuresEq exAddrClosure