[Git][ghc/ghc][master] ghc-heap: remove wrong Addr# coercion (#23181)
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Thu Mar 30 05:41:05 UTC 2023
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
f4f1f14f by Sylvain Henry at 2023-03-30T01:40:49-04:00
ghc-heap: remove wrong Addr# coercion (#23181)
Conversion from Addr# to I# isn't correct with the JS backend.
Also used the opportunity to reenable 64-bit Word/Int tests
- - - - -
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# (unsafeCoerce# x) }
+ Int64Closure { ptipe = PInt64, int64Val = I64# x }
instance Word64# ~ a => HasHeapRep (a :: TYPE 'Word64Rep) where
getClosureData x = return $
- Word64Closure { ptipe = PWord64, word64Val = W64# (unsafeCoerce# x) }
+ Word64Closure { ptipe = PWord64, word64Val = W64# x }
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 $
=====================================
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
=====================================
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
@@ -316,19 +317,17 @@ main = do
assertClosuresEq exWordClosure
-- Primitive Int64
- -- FAILING: On 64-bit platforms, v is a regular Int
- -- let (I64# v) = 42
- -- getClosureData v >>=
- -- assertClosuresEq exInt64Closure
+ let (I64# v) = 42
+ getClosureData v >>=
+ assertClosuresEq exInt64Closure
-- Primitive Word64
- -- FAILING: On 64-bit platforms, v is a regular Word
- -- let (W64# v) = 42
- -- getClosureData v >>=
- -- assertClosuresEq exWord64Closure
+ let (W64# v) = 42
+ getClosureData v >>=
+ assertClosuresEq exWord64Closure
-- Primitive Addr
- let v = unsafeCoerce# 42# :: Addr#
+ let (Ptr v) = nullPtr `plusPtr` 42
getClosureData v >>=
assertClosuresEq exAddrClosure
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f4f1f14f8009c3c120b8b963ec130cbbc774ec02
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f4f1f14f8009c3c120b8b963ec130cbbc774ec02
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/9984053b/attachment-0001.html>
More information about the ghc-commits
mailing list