%
-% (c) The University of Glasgow 2000
+% (c) The University of Glasgow 2000-2006
%
-\section[ByteCodeLink]{Bytecode assembler and linker}
+ByteCodeLink: Bytecode assembler and linker
\begin{code}
-
{-# OPTIONS -optc-DNON_POSIX_SOURCE #-}
module ByteCodeLink (
HValue,
ClosureEnv, emptyClosureEnv, extendClosureEnv,
linkBCO, lookupStaticPtr
+ ,lookupIE
) where
#include "HsVersions.h"
-import ByteCodeItbls ( ItblEnv, ItblPtr )
-import ByteCodeAsm ( UnlinkedBCO(..), BCOPtr(..), sizeSS, ssElts )
-import ObjLink ( lookupSymbol )
+import ByteCodeItbls
+import ByteCodeAsm
+import ObjLink
-import Name ( Name, nameModule, nameOccName )
+import Name
import NameEnv
-import OccName ( occNameFS )
-import PrimOp ( PrimOp, primOpOcc )
+import OccName
+import PrimOp
import Module
-import PackageConfig ( mainPackageId, packageIdFS )
-import FastString ( FastString(..), unpackFS, zEncodeFS )
-import Panic ( GhcException(..) )
+import PackageConfig
+import FastString
+import Panic
+import Breakpoints
#ifdef DEBUG
-import Name ( isExternalName )
import Outputable
#endif
import GHC.Arr ( Array(..) )
import GHC.IOBase ( IO(..) )
-import GHC.Ptr ( Ptr(..) )
+import GHC.Ptr ( Ptr(..), castPtr )
import GHC.Base ( writeArray#, RealWorld, Int(..) )
\end{code}
ptrs_parr = case ptrs_arr of Array lo hi parr -> parr
itbls_arr = listArray (0, n_itbls-1) linked_itbls
- :: UArray Int ItblPtr
+
itbls_barr = case itbls_arr of UArray lo hi barr -> barr
literals_arr = listArray (0, n_literals-1) linked_literals
newtype IOArray i e = IOArray (STArray RealWorld i e)
-instance HasBounds IOArray where
- bounds (IOArray marr) = bounds marr
-
instance MArray IOArray e IO where
+ getBounds (IOArray marr) = stToIO $ getBounds marr
newArray lu init = stToIO $ do
marr <- newArray lu init; return (IOArray marr)
newArray_ lu = stToIO $ do
lookupName ce nm
= case lookupNameEnv ce nm of
Just (_,aa) -> return aa
+ Nothing | Just bk <- lookupBogusBreakpointVal nm
+ -> return bk
Nothing
-> ASSERT2(isExternalName nm, ppr nm)
do let sym_to_find = nameToCLabel nm "closure"
lookupIE :: ItblEnv -> Name -> IO (Ptr a)
lookupIE ie con_nm
= case lookupNameEnv ie con_nm of
- Just (_, Ptr a) -> return (Ptr a)
+ Just (_, a) -> return (castPtr (itblCode a))
Nothing
-> do -- try looking up in the object files.
let sym_to_find1 = nameToCLabel con_nm "con_info"