Commit 55945d0a authored by sewardj's avatar sewardj
Browse files

[project @ 2000-09-11 12:20:56 by sewardj]

First shot at a STG interpreter for GHCI.  Translates Stg syntax into a
form convenient for interpretation, and can then run that.  Most of the
translation stuff is there and works.  The interpreter framework is there
and partly filled in, and seems to work.  There are still quite a lot of
cases, etc, to fill in, but this should be straightforward given that
the framework exists.  This interpreter cannot handle (yet?) unboxed
tuples, but can deal with more or less everything else, including standard
unboxed Int, Double, etc, code.
parent d4993e8b
# -----------------------------------------------------------------------------
# $Id: Makefile,v 1.91 2000/08/22 10:08:14 simonmar Exp $
# $Id: Makefile,v 1.92 2000/09/11 12:20:56 sewardj Exp $
TOP = ..
include $(TOP)/mk/boilerplate.mk
......@@ -222,6 +222,8 @@ utils/PrimPacked_HC_OPTS = -fvia-C -monly-3-regs -optC-funfolding-interface-thre
# separate bugfix to the fixpoint finder.
simplStg/UpdAnal_HC_OPTS = -fno-strictness
stgSyn/StgInterp_HC_OPTS = -fvia-C
# ----------------------------------------------------------------------------
# C compilations
......
......@@ -1306,6 +1306,7 @@ pprUnionTag ThreadIdRep = char 't'
pprUnionTag ArrayRep = char 'p'
pprUnionTag ByteArrayRep = char 'b'
pprUnionTag BCORep = char 'p'
pprUnionTag _ = panic "pprUnionTag:Odd kind"
\end{code}
......
......@@ -46,6 +46,7 @@ import BSD
import IOExts ( unsafePerformIO )
import NativeInfo ( os, arch )
#endif
import StgInterp ( runStgI )
\end{code}
......@@ -173,11 +174,17 @@ doIt (core_cmds, stg_cmds)
in
-------------------------- Simplify STG code -------------------------------
show_pass "Stg2Stg" >>
show_pass "Stg2Stg" >>
_scc_ "Stg2Stg"
stg2stg stg_cmds this_mod st_uniqs stg_binds >>= \ (stg_binds2, cost_centre_info) ->
#ifdef GHCI
runStgI local_tycons local_classes
(map fst stg_binds2) >>= \ i_result ->
putStr ("\nANSWER = " ++ show i_result ++ "\n\n")
>>
#else
-------------------------- Interface file -------------------------------
-- Dump instance decls and type signatures into the interface file
_scc_ "Interface"
......@@ -211,6 +218,9 @@ doIt (core_cmds, stg_cmds)
-------------------------- Final report -------------------------------
reportCompile mod_name (showSDoc (ppSourceStats True rdr_module)) >>
#endif
ghcExit 0
} }
where
......
......@@ -543,7 +543,8 @@ getPrimOpResultInfo op
let rep = typePrimRep ty in
case rep of
PtrRep -> case splitAlgTyConApp_maybe ty of
Nothing -> panic "getPrimOpResultInfo"
Nothing -> pprPanic "getPrimOpResultInfo"
(ppr ty <+> ppr op)
Just (tc,_,_) -> ReturnsAlg tc
other -> ReturnsPrim other
\end{code}
......
......@@ -241,6 +241,7 @@ showPrimRep ThreadIdRep = "StgTSO*"
showPrimRep WeakPtrRep = "P_"
showPrimRep ForeignObjRep = "StgAddr"
showPrimRep VoidRep = "!!VOID_KIND!!"
showPrimRep BCORep = "P_" -- not sure -- JRS 000708
primRepString CharRep = "Char"
primRepString Int8Rep = "Char" -- To have names like newCharArray#
......
-----------------------------------------------------------------------
-- $Id: primops.txt,v 1.3 2000/09/11 11:17:09 sewardj Exp $
-- $Id: primops.txt,v 1.4 2000/09/11 12:20:57 sewardj Exp $
--
-- Primitive Operations
--
......@@ -982,12 +982,17 @@ primop NewBCOOp "newBCO#" GenPrimOp
Int# -> Int# -> Int# -> a -> State# RealWorld -> (# State# RealWorld, BCO# #)
with
has_side_effects = True
out_of_line = True
out_of_line = True
strictness = { \ arity -> StrictnessInfo
[wwPrim, wwPrim, wwPrim, wwLazy, wwPrim] False }
usage = { mangle NewBCOOp [mkP, mkP, mkP, mkM, mkP] mkR }
primop WriteBCOPtrOp "writeBCOPtr#" GenPrimOp
BCO# -> Int# -> o -> State# RealWorld -> State# RealWorld
with
usage = { mangle WriteBCOPtrOp [mkP, mkP, mkM] mkR }
usage = { mangle WriteBCOPtrOp [mkP, mkP, mkM, mkP] mkR }
strictness = { \ arity -> StrictnessInfo
[wwPrim, wwPrim, wwLazy, wwPrim] False }
has_side_effects = True
primop WriteBCONonPtrOp "writeBCONonPtr#" GenPrimOp
......@@ -1011,6 +1016,13 @@ primop ReadBCONonPtrOp "readBCONonPtr#" GenPrimOp
primop ReadBCOInstrOp "readBCOInstr#" GenPrimOp
BCO# -> Int# -> State# RealWorld -> (# State# RealWorld, Word# #)
primop SameBCOOp "sameBCO#" GenPrimOp
BCO# -> BCO# -> Bool
with
-- is this usage right?
usage = { mangle SameMutableArrayOp [mkP, mkP] mkM }
------------------------------------------------------------------------
--- Weak pointers ---
------------------------------------------------------------------------
......
__interface MCIzumakezuconstr 1 409 where
__export MCIzumakezuconstr
mcizumakezuconstrI
mcizumakezuconstr
mcizumakezuconstrP
mcizumakezuconstrPP
mcizumakezuconstrPPP ;
1 mcizumakezuconstrI
:: __forall [a] => PrelGHC.Addrzh -> PrelGHC.Intzh -> a ;
1 mcizumakezuconstr
:: __forall [a] => PrelGHC.Addrzh -> a ;
1 mcizumakezuconstrP
:: __forall [a a1] => PrelGHC.Addrzh -> a1 -> a ;
1 mcizumakezuconstrPP
:: __forall [a a1 a2] => PrelGHC.Addrzh -> a1 -> a2 -> a ;
1 mcizumakezuconstrPPP
:: __forall [a a1 a2 a3] => PrelGHC.Addrzh -> a1 -> a2 -> a3 -> a ;
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment