-- unsafePerformIO (print "↓" >> pClosure any) `seq`
pad_out (showHex addr "") ++ (if tag>0 then "/" ++ show tag else "") ++ rs
where
- ptr = W# (int2Word# (aToInt# any))
+ ptr = W# (aToWord# any)
tag = ptr .&. fromIntegral tAG_MASK -- ((1 `shiftL` TAG_BITS) -1)
addr = ptr - tag
-- want 0s prefixed to pad it out to a fixed length.
allPtrs (FunClosure {..}) = ptrArgs
allPtrs (OtherClosure {..}) = hvalues
+
+
#ifdef PRIM_SUPPORTS_ANY
-foreign import prim "aToInt" aToInt# :: Any -> Int#
+foreign import prim "aToWordzh" aToWord# :: Any -> Word#
foreign import prim "slurpClosurezh" slurpClosure# :: Any -> (# Addr#, ByteArray#, Array# b #)
#else
-- Workd-around code until http://hackage.haskell.org/trac/ghc/ticket/5931 was
-- accepted
-foreign import prim "aToInt" aToInt'# :: Addr# -> Int#
+foreign import prim "aToWordzh" aToWord'# :: Addr# -> Word#
foreign import prim "slurpClosurezh" slurpClosure'# :: Addr# -> (# Addr#, ByteArray#, Array# b #)
-- This is a datatype that has the same layout as Ptr, so that by
-- unsafeCoerce'ing, we obtain the Addr of the wrapped value
data Ptr' a = Ptr' a
-aToInt# :: Any -> Int#
-aToInt# a = case Ptr' a of mb@(Ptr' _) -> case unsafeCoerce# mb :: Ptr () of Ptr addr -> aToInt'# addr
+addrOf# :: Any -> Addr#
+addrOf# a = case Ptr' a of mb@(Ptr' _) -> case unsafeCoerce# mb :: Ptr () of Ptr addr -> addr
+
+aToWord# :: Any -> Word#
+aToWord# a = aToWord'# (addrOf# a)
slurpClosure# :: Any -> (# Addr#, ByteArray#, Array# b #)
-slurpClosure# a = case Ptr' a of mb@(Ptr' _) -> case unsafeCoerce# mb :: Ptr () of Ptr addr -> slurpClosure'# addr
+slurpClosure# a = slurpClosure'# (addrOf# a)
#endif
--pClosure x = do