[project @ 2002-12-10 02:34:21 by igloo]
[ghc-hetmet.git] / ghc / compiler / ghci / ByteCodeInstr.lhs
index dcc96d9..05b8a1a 100644 (file)
@@ -19,8 +19,7 @@ import PrimRep                ( PrimRep )
 import DataCon         ( DataCon )
 import VarSet          ( VarSet )
 import PrimOp          ( PrimOp )
-import Foreign         ( Addr )
-
+import GHC.Ptr
 \end{code}
 
 %************************************************************************
@@ -37,7 +36,7 @@ data ProtoBCO a
                                        -- what the BCO came from
               (Either [AnnAlt Id VarSet]
                       (AnnExpr Id VarSet))
-              [Addr]                   -- malloc'd; free when BCO is GCd
+              [Ptr ()]                 -- malloc'd; free when BCO is GCd
 
 nameOfProtoBCO (ProtoBCO nm insns origin malloced) = nm
 
@@ -57,7 +56,7 @@ data BCInstr
    | PUSH_AS   Name PrimRep    -- push alts and BCO_ptr_ret_info
                                -- PrimRep so we know which itbl
    -- Pushing literals
-   | PUSH_UBX  (Either Literal Addr)
+   | PUSH_UBX  (Either Literal (Ptr ()))
                Int      -- push this int/float/double/addr, NO TAG, on the stack
                        -- Int is # of words to copy from literal pool
                         -- Eitherness reflects the difficulty of dealing with 
@@ -100,7 +99,9 @@ data BCInstr
    | JMP              LocalLabel
 
    -- For doing calls to C (via glue code generated by ByteCodeFFI)
-   | CCALL            Addr     -- of the glue code
+   | CCALL            (Ptr ()) -- of the glue code
+   | SWIZZLE          Int Int  -- to the ptr N words down the stack,
+                               -- add M (interpreted as a signed 16-bit entity)
 
    -- To Infinity And Beyond
    | ENTER
@@ -124,7 +125,7 @@ instance Outputable BCInstr where
    ppr (PUSH_LL o1 o2)       = text "PUSH_LL " <+> int o1 <+> int o2
    ppr (PUSH_LLL o1 o2 o3)   = text "PUSH_LLL" <+> int o1 <+> int o2 <+> int o3
    ppr (PUSH_G (Left nm))    = text "PUSH_G  " <+> ppr nm
-   ppr (PUSH_G (Right op))   = text "PUSH_G  " <+> text "PrelPrimopWrappers." 
+   ppr (PUSH_G (Right op))   = text "PUSH_G  " <+> text "GHC.PrimopWrappers." 
                                                <> ppr op
    ppr (PUSH_AS nm pk)       = text "PUSH_AS " <+> ppr nm <+> ppr pk
 
@@ -156,6 +157,8 @@ instance Outputable BCInstr where
    ppr (RETURN pk)           = text "RETURN  " <+> ppr pk
    ppr (CCALL marshall_addr) = text "CCALL   " <+> text "marshall code at" 
                                                <+> text (show marshall_addr)
+   ppr (SWIZZLE stkoff n)    = text "SWIZZLE " <+> text "stkoff" <+> int stkoff 
+                                               <+> text "by" <+> int n 
 
 -- The stack use, in words, of each bytecode insn.  These _must_ be
 -- correct, or overestimates of reality, to be safe.
@@ -186,6 +189,7 @@ bciStackUse (JMP lab)             = 0
 bciStackUse ENTER                 = 0
 bciStackUse (RETURN pk)           = 0
 bciStackUse (CCALL marshall_addr) = 0
+bciStackUse (SWIZZLE stkoff n)    = 0
 
 -- These insns actually reduce stack use, but we need the high-tide level,
 -- so can't use this info.  Not that it matters much.