summaryrefslogtreecommitdiff
path: root/libraries
diff options
context:
space:
mode:
authorPeter Trommler <ptrommler@acm.org>2018-07-26 17:23:22 -0400
committerBen Gamari <ben@smart-cactus.org>2018-07-27 12:29:40 -0400
commitd7cb1bbc26719cf6082abe0d91d80be466e25bfc (patch)
tree035d527212e19c58a4f9cd204cd2b4c313feda1f /libraries
parent40e9ec982a6f133243ca74ac7353b9be39e18c72 (diff)
downloadhaskell-d7cb1bbc26719cf6082abe0d91d80be466e25bfc.tar.gz
Fix endian issues in ghc-heap
In test heap_all arity and n_args were swapped on big endian systems. Take care of endianness when reading parts of a machine word from a `Word`. This fixes one out of 36 failing tests reported in #15399. Test Plan: validate Reviewers: simonmar, bgamari, hvr, erikd Reviewed By: simonmar Subscribers: rwbarton, thomie, carter GHC Trac Issues: #15399 Differential Revision: https://phabricator.haskell.org/D5001
Diffstat (limited to 'libraries')
-rw-r--r--libraries/ghc-heap/GHC/Exts/Heap.hs17
1 files changed, 17 insertions, 0 deletions
diff --git a/libraries/ghc-heap/GHC/Exts/Heap.hs b/libraries/ghc-heap/GHC/Exts/Heap.hs
index 9dc1f94a67..535596fda5 100644
--- a/libraries/ghc-heap/GHC/Exts/Heap.hs
+++ b/libraries/ghc-heap/GHC/Exts/Heap.hs
@@ -62,6 +62,8 @@ import GHC.Exts
import GHC.Int
import GHC.Word
+#include "ghcconfig.h"
+
class HasHeapRep (a :: TYPE rep) where
getClosureData :: a -> IO Closure
@@ -169,8 +171,13 @@ getClosure x = do
fail $ "Expected at least 2 raw words to AP"
let splitWord = rawWds !! 0
pure $ APClosure itbl
+#if defined(WORDS_BIGENDIAN)
+ (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2))
+ (fromIntegral splitWord)
+#else
(fromIntegral splitWord)
(fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2))
+#endif
(head pts) (tail pts)
PAP -> do
@@ -181,8 +188,13 @@ getClosure x = do
fail "Expected at least 2 raw words to PAP"
let splitWord = rawWds !! 0
pure $ PAPClosure itbl
+#if defined(WORDS_BIGENDIAN)
+ (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2))
+ (fromIntegral splitWord)
+#else
(fromIntegral splitWord)
(fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2))
+#endif
(head pts) (tail pts)
AP_STACK -> do
@@ -214,8 +226,13 @@ getClosure x = do
++ show (length rawWds)
let splitWord = rawWds !! 3
pure $ BCOClosure itbl (pts !! 0) (pts !! 1) (pts !! 2)
+#if defined(WORDS_BIGENDIAN)
+ (fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2))
+ (fromIntegral splitWord)
+#else
(fromIntegral splitWord)
(fromIntegral $ shiftR splitWord (wORD_SIZE_IN_BITS `div` 2))
+#endif
(drop 4 rawWds)
ARR_WORDS -> do