diff options
author | Ian Lynagh <ian@well-typed.com> | 2012-09-18 23:22:20 +0100 |
---|---|---|
committer | Ian Lynagh <ian@well-typed.com> | 2012-09-18 23:22:20 +0100 |
commit | a9b986e2fe285f844e42e573e4887a4e36ba92d4 (patch) | |
tree | 30509b6c6aa091125089208631c146ca72793758 /compiler/ghci | |
parent | 3a4c64c1a2953bbc759a6f5c99dad31ab50dc96b (diff) | |
download | haskell-a9b986e2fe285f844e42e573e4887a4e36ba92d4.tar.gz |
Make StgWord a portable type too
StgWord is a newtyped Word64, as it needed to be something that
has a UArray instance.
Diffstat (limited to 'compiler/ghci')
-rw-r--r-- | compiler/ghci/ByteCodeAsm.lhs | 8 | ||||
-rw-r--r-- | compiler/ghci/ByteCodeInstr.lhs | 2 | ||||
-rw-r--r-- | compiler/ghci/DebuggerUtils.hs | 15 |
3 files changed, 17 insertions, 8 deletions
diff --git a/compiler/ghci/ByteCodeAsm.lhs b/compiler/ghci/ByteCodeAsm.lhs index 15c41d044e..f00e45c6b6 100644 --- a/compiler/ghci/ByteCodeAsm.lhs +++ b/compiler/ghci/ByteCodeAsm.lhs @@ -166,7 +166,7 @@ assembleBCO dflags (ProtoBCO nm instrs bitmap bsize arity _origin _malloced) = d insns_arr = listArray (0, n_insns - 1) asm_insns !insns_barr = barr insns_arr - bitmap_arr = mkBitmapArray bsize bitmap + bitmap_arr = mkBitmapArray dflags bsize bitmap !bitmap_barr = barr bitmap_arr ul_bco = UnlinkedBCO nm arity insns_barr bitmap_barr final_lits final_ptrs @@ -178,9 +178,9 @@ assembleBCO dflags (ProtoBCO nm instrs bitmap bsize arity _origin _malloced) = d return ul_bco -mkBitmapArray :: Word16 -> [StgWord] -> UArray Int StgWord -mkBitmapArray bsize bitmap - = listArray (0, length bitmap) (fromIntegral bsize : bitmap) +mkBitmapArray :: DynFlags -> Word16 -> [StgWord] -> UArray Int StgWord +mkBitmapArray dflags bsize bitmap + = listArray (0, length bitmap) (toStgWord dflags (toInteger bsize) : bitmap) -- instrs nonptrs ptrs type AsmState = (SizedSeq Word16, diff --git a/compiler/ghci/ByteCodeInstr.lhs b/compiler/ghci/ByteCodeInstr.lhs index ada0be6f0f..ed49960709 100644 --- a/compiler/ghci/ByteCodeInstr.lhs +++ b/compiler/ghci/ByteCodeInstr.lhs @@ -178,7 +178,7 @@ instance Outputable a => Outputable (ProtoBCO a) where Left alts -> vcat (zipWith (<+>) (char '{' : repeat (char ';')) (map (pprCoreAltShort.deAnnAlt) alts)) <+> char '}' Right rhs -> pprCoreExprShort (deAnnotate rhs)) - $$ nest 3 (text "bitmap: " <+> text (show bsize) <+> text (show bitmap)) + $$ nest 3 (text "bitmap: " <+> text (show bsize) <+> ppr bitmap) $$ nest 3 (vcat (map ppr instrs)) -- Print enough of the Core expression to enable the reader to find diff --git a/compiler/ghci/DebuggerUtils.hs b/compiler/ghci/DebuggerUtils.hs index ab7fcd1764..b1688d85f8 100644 --- a/compiler/ghci/DebuggerUtils.hs +++ b/compiler/ghci/DebuggerUtils.hs @@ -9,11 +9,11 @@ import TcRnTypes import TcRnMonad import IfaceEnv import CgInfoTbls -import SMRep import Module import OccName import Name import Outputable +import Platform import Util import Data.Char @@ -93,8 +93,17 @@ dataConInfoPtrToName x = do getConDescAddress :: DynFlags -> Ptr StgInfoTable -> IO (Ptr Word8) getConDescAddress dflags ptr | ghciTablesNextToCode = do - offsetToString <- peek $ ptr `plusPtr` (- wORD_SIZE dflags) - return $ (ptr `plusPtr` stdInfoTableSizeB dflags) `plusPtr` (fromIntegral (offsetToString :: StgWord)) + let ptr' = ptr `plusPtr` (- wORD_SIZE dflags) + -- offsetToString is really an StgWord, but we have to jump + -- through some hoops due to the way that our StgWord Haskell + -- type is the same on 32 and 64bit platforms + offsetToString <- case platformWordSize (targetPlatform dflags) of + 4 -> do w <- peek ptr' + return (fromIntegral (w :: Word32)) + 8 -> do w <- peek ptr' + return (fromIntegral (w :: Word64)) + w -> panic ("getConDescAddress: Unknown platformWordSize: " ++ show w) + return $ (ptr `plusPtr` stdInfoTableSizeB dflags) `plusPtr` offsetToString | otherwise = peek $ intPtrToPtr $ ptrToIntPtr ptr + fromIntegral (stdInfoTableSizeB dflags) -- parsing names is a little bit fiddly because we have a string in the form: |