[Git][ghc/ghc][master] Revert "ghc-heap: remove wrong Addr# coercion (#23181)"
Matthew Pickering (@mpickering)
gitlab at gitlab.haskell.org
Thu Mar 30 08:59:44 UTC 2023
Matthew Pickering pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
98b5cf67 by Matthew Pickering at 2023-03-30T09:58:40+01:00
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.
- - - - -
3 changed files:
- libraries/ghc-heap/GHC/Exts/Heap.hs
- libraries/ghc-heap/GHC/Exts/Heap/Closures.hs
- libraries/ghc-heap/tests/heap_all.hs
Changes:
=====================================
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 $
=====================================
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
=====================================
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
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/98b5cf67f8428b0daefcbf5df121df0b8a126654
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/98b5cf67f8428b0daefcbf5df121df0b8a126654
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/20230330/611b028e/attachment-0001.html>
More information about the ghc-commits
mailing list