diff options
author | Ben Gamari <bgamari.foss@gmail.com> | 2017-07-11 20:50:38 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-07-12 08:55:00 -0400 |
commit | 7ae4a28f6a09a0540aab59f5a03fdbcd46a99f17 (patch) | |
tree | e7f80cad2050ade539329caef63cd7aeba9d9487 /compiler/ghci | |
parent | 60ec8f74d32a9976ac8ddf6fd366218283fcac3e (diff) | |
download | haskell-7ae4a28f6a09a0540aab59f5a03fdbcd46a99f17.tar.gz |
[iserv] Fixing the word size for RemotePtr and toWordArray
When we load non absolute pathed .so's this usually implies that we
expect the system to have them in place already, and hence we should not
need to ship them. Without the absolute path to the library, we are
also unable to open and send said library. Thus we'll do library
shipping only for libraries with absolute paths.
When dealing with a host and target of different word size (say host
hast 64bit, target has 32bit), we need to fix the RemotePtr size and the
toWordArray function, as they are part of the iserv ResolvedBCO binary
protocol. This needs to be word size independent. The choice for
RemotePtr to 64bit was made to ensure we can store 64bit pointers when
targeting 64bit. The choice for 32bit word arrays was made wrt.
encoding/decoding on the potentially slower device.
The efficient serialization code has been graciously provided by
@bgamari.
Reviewers: bgamari, simonmar, austin, hvr
Reviewed By: bgamari
Subscribers: Ericson2314, rwbarton, thomie, ryantrinkle
Differential Revision: https://phabricator.haskell.org/D3443
Diffstat (limited to 'compiler/ghci')
-rw-r--r-- | compiler/ghci/ByteCodeAsm.hs | 2 | ||||
-rw-r--r-- | compiler/ghci/ByteCodeLink.hs | 18 | ||||
-rw-r--r-- | compiler/ghci/ByteCodeTypes.hs | 2 |
3 files changed, 6 insertions, 16 deletions
diff --git a/compiler/ghci/ByteCodeAsm.hs b/compiler/ghci/ByteCodeAsm.hs index 9eb730ff1a..a7395221ce 100644 --- a/compiler/ghci/ByteCodeAsm.hs +++ b/compiler/ghci/ByteCodeAsm.hs @@ -194,7 +194,7 @@ assembleBCO dflags (ProtoBCO nm instrs bitmap bsize arity _origin _malloced) = d return ul_bco -mkBitmapArray :: Word16 -> [StgWord] -> UArray Int Word +mkBitmapArray :: Word16 -> [StgWord] -> UArray Int Word64 -- Here the return type must be an array of Words, not StgWords, -- because the underlying ByteArray# will end up as a component -- of a BCO object. diff --git a/compiler/ghci/ByteCodeLink.hs b/compiler/ghci/ByteCodeLink.hs index 40f7341d32..e865590f2b 100644 --- a/compiler/ghci/ByteCodeLink.hs +++ b/compiler/ghci/ByteCodeLink.hs @@ -28,7 +28,6 @@ import SizedSeq import GHCi import ByteCodeTypes import HscTypes -import DynFlags import Name import NameEnv import PrimOp @@ -40,8 +39,6 @@ import Util -- Standard libraries import Data.Array.Unboxed -import Data.Array.Base -import Data.Word import Foreign.Ptr import GHC.IO ( IO(..) ) import GHC.Exts @@ -69,21 +66,14 @@ linkBCO -> IO ResolvedBCO linkBCO hsc_env ie ce bco_ix breakarray (UnlinkedBCO _ arity insns bitmap lits0 ptrs0) = do - lits <- mapM (lookupLiteral hsc_env ie) (ssElts lits0) + -- fromIntegral Word -> Word64 should be a no op if Word is Word64 + -- otherwise it will result in a cast to longlong on 32bit systems. + lits <- mapM (fmap fromIntegral . lookupLiteral hsc_env ie) (ssElts lits0) ptrs <- mapM (resolvePtr hsc_env ie ce bco_ix breakarray) (ssElts ptrs0) - let dflags = hsc_dflags hsc_env - return (ResolvedBCO arity (toWordArray dflags insns) bitmap + return (ResolvedBCO isLittleEndian arity insns bitmap (listArray (0, fromIntegral (sizeSS lits0)-1) lits) (addListToSS emptySS ptrs)) --- Turn the insns array from a Word16 array into a Word array. The --- latter is much faster to serialize/deserialize. Assumes the input --- array is zero-indexed. -toWordArray :: DynFlags -> UArray Int Word16 -> UArray Int Word -toWordArray dflags (UArray _ _ n arr) = UArray 0 (n'-1) n' arr - where n' = (n + w16s_per_word - 1) `quot` w16s_per_word - w16s_per_word = wORD_SIZE dflags `quot` 2 - lookupLiteral :: HscEnv -> ItblEnv -> BCONPtr -> IO Word lookupLiteral _ _ (BCONPtrWord lit) = return lit lookupLiteral hsc_env _ (BCONPtrLbl sym) = do diff --git a/compiler/ghci/ByteCodeTypes.hs b/compiler/ghci/ByteCodeTypes.hs index ec962c886b..1318a47ef4 100644 --- a/compiler/ghci/ByteCodeTypes.hs +++ b/compiler/ghci/ByteCodeTypes.hs @@ -80,7 +80,7 @@ data UnlinkedBCO unlinkedBCOName :: !Name, unlinkedBCOArity :: {-# UNPACK #-} !Int, unlinkedBCOInstrs :: !(UArray Int Word16), -- insns - unlinkedBCOBitmap :: !(UArray Int Word), -- bitmap + unlinkedBCOBitmap :: !(UArray Int Word64), -- bitmap unlinkedBCOLits :: !(SizedSeq BCONPtr), -- non-ptrs unlinkedBCOPtrs :: !(SizedSeq BCOPtr) -- ptrs } |