YhcSource codeContentsIndex
ByteCode.Type
Contents
Data Types
Top-level bytecode declarations
Constant tables
Code representations
Use sets
Constants
Synopsis
data BCModule = BCModule {
bcmModule :: String
bcmDecls :: [BCDecl]
}
data BCDecl
= Fun {
fName :: String
fPos :: Pos
fArity :: Int
fArgs :: [String]
fCode :: Code
fConsts :: ConstTable
fIsPrim :: Bool
fStack :: Int
fNumDictArgs :: Int
fFlags :: [LambdaFlags]
}
| Con {
cName :: String
cPos :: Pos
cSize :: Int
cTag :: Int
}
| Prim {
pName :: String
pPos :: Pos
}
| External {
xName :: String
xPos :: Pos
xArity :: Int
xCName :: String
xCallConv :: String
xArgsTypes :: [String]
}
type ConstTable = Map CRef ConstItem
data ConstItem
= CGlobal String GType
| CInt Int
| CInteger Integer
| CFloat Float
| CDouble Double
| CString String
| CPos Pos
| CVarDesc String Pos
data GType
= GCAF
| GFUN
| GFUN0
| GCON
| GZCON
| GPRIM
| GEXT
type CRef = Int
data Code
= CLinear [(Ins, UseSet)]
| CGraph GLabel Graph Jumpers
| CWrites [Write]
data GraphNode
= GLinear [UseIns] Bool GLabel
| GCase Bool [(Tag, GLabel)] (Maybe GLabel)
| GIf GLabel GLabel
| GReturn
| GDead
type Graph = Map GLabel GraphNode
type Jumpers = Map GLabel (Set GLabel)
data GLabel = GLabel Label
data Write
= WUByte Int
| WUShort Int
| WLabel Int Label
| WByte Int
| WShort Int
data Ins
= END_CODE
| START_FUN
| NEED_STACK Int
| NEED_HEAP Int
| PUSH Int
| PUSH_ZAP Int
| ZAP_STACK Int
| PUSH_ARG Int
| PUSH_ZAP_ARG Int
| ZAP_ARG Int
| PUSH_INT Int
| PUSH_CHAR Int
| PUSH_CONST CRef
| MK_AP CRef Int
| MK_PAP CRef Int
| MK_CON CRef Int
| APPLY Int
| UNPACK Int
| SLIDE Int
| POP Int
| ALLOC Int
| UPDATE Int
| RETURN
| EVAL
| RETURN_EVAL
| NOP
| P_ADD PrimOp
| P_SUB PrimOp
| P_MUL PrimOp
| P_DIV PrimOp
| P_MOD PrimOp
| P_CMP_EQ PrimOp
| P_CMP_NE PrimOp
| P_CMP_LE PrimOp
| P_CMP_LT PrimOp
| P_CMP_GE PrimOp
| P_CMP_GT PrimOp
| P_NEG PrimOp
| P_STRING
| P_FROM_ENUM
| CASE Bool [(Tag, Label)] (Maybe Label)
| STOP
| TABLE_SWITCH [Label]
| LOOKUP_SWITCH [(Tag, Label)] Label
| INT_SWITCH [(Tag, Label)] Label
| JUMP_FALSE Label
| JUMP Label
| LABEL Label
| PRIMITIVE
| EXTERNAL
| SELECTOR_EVAL
| SELECT Int
| TAP CRef
| TCON CRef
| TPRIMCON CRef
| TAPPLY CRef Int
| TIF CRef
| TGUARD CRef
| TCASE CRef
| TRETURN
| TPRIMAP CRef Int
| TPRIMRESULT CRef
| TPUSH
| TPUSHVAR CRef
| TPROJECT CRef
| COMMENT String
data PrimOp
= OpWord
| OpFloat
| OpDouble
type Tag = Int
type Label = Int
data UseSet = UseSet {
useDepth :: Int
useGive :: [String]
useNeed :: (Set String)
}
emptyUS :: UseSet
type UseIns = (Ins, UseSet)
xFlNone :: Int
xFlVoid :: Int
fNone :: Int
fInvisible :: Int
fLambda :: Int
intFlags :: [LambdaFlags] -> Int
frameSize :: Int
calcHeapExtra :: Flags -> Int
splitQualified :: String -> (String, String)
Data Types
Top-level bytecode declarations
data BCModule
A bytecode program
Constructors
BCModule
bcmModule :: String
bcmDecls :: [BCDecl]
data BCDecl
A Declaration is a top level bcode entry
Constructors
Fun
fName :: String
fPos :: Pos
fArity :: Int
fArgs :: [String]
fCode :: Code
fConsts :: ConstTable
fIsPrim :: Bool
fStack :: Int
fNumDictArgs :: Int
fFlags :: [LambdaFlags]
Con
cName :: String
cPos :: Pos
cSize :: Int
cTag :: Int
Prim
pName :: String
pPos :: Pos
External
xName :: String
xPos :: Pos
xArity :: Int
xCName :: String
xCallConv :: String
xArgsTypes :: [String]
Constant tables
type ConstTable = Map CRef ConstItem
A constant table maps constant references to constant items
data ConstItem
A constant in the constant table
Constructors
CGlobal String GType
CInt Int
CInteger Integer
CFloat Float
CDouble Double
CString String
CPos Pos
CVarDesc String Pos
show/hide Instances
data GType
Common applicative form, function info, node for non-CAF, constructor info, node for zero arity constructor, primitive function info
Constructors
GCAF
GFUN
GFUN0
GCON
GZCON
GPRIM
GEXT
show/hide Instances
Eq GType
Ord GType
Show GType
type CRef = Int
Code representations
data Code
Code can be several things; either a simple list of instructions or a code flow graph
Constructors
CLinear [(Ins, UseSet)]
CGraph GLabel Graph Jumpers
CWrites [Write]
data GraphNode

a graph node is either:

  •  GLinear is eval next
                 is   = the linear sequence of instructions
                 eval = whether this block has an EVAL at the end
                 next = the label of the next block
    
  •  GCase int alts default
                 int     = true if this is a case over integers
                 alts    = the alternatives of the case
                 default = the default branch of the case, if any
    
  •  GIf true false
                 true    = the true label of the if
                 false   = the false label of the if
    
  •  GReturn
                 terminal node in the graph
    
Constructors
GLinear [UseIns] Bool GLabel
GCase Bool [(Tag, GLabel)] (Maybe GLabel)
GIf GLabel GLabel
GReturn
GDead
type Graph = Map GLabel GraphNode
A graph associates labels with graph nodes
type Jumpers = Map GLabel (Set GLabel)
Jumpers lists for each label all the graph nodes that might jump to it
data GLabel
A graph label, just wraps a label, helps with typechecking and we can sort the other way round
Constructors
GLabel Label
show/hide Instances
Eq GLabel
Ord GLabel
Show GLabel
data Write
A write is a data section that should be written to the final bytecode file, Label is used as a placeholder
Constructors
WUByte Int
WUShort Int
WLabel Int Label
WByte Int
WShort Int
data Ins
The instructions
Constructors
END_CODE
START_FUNnever appears just used in zap analysis
NEED_STACK Int
NEED_HEAP Int
PUSH Int
PUSH_ZAP Int
ZAP_STACK Int
PUSH_ARG Intis this supposed to be an Int or an Id? [SamB] ^ Int, first argument = 0, second = 1, etc [TomS]
PUSH_ZAP_ARG Int
ZAP_ARG Int
PUSH_INT Int
PUSH_CHAR Int
PUSH_CONST CRef
MK_AP CRef Int
MK_PAP CRef Int
MK_CON CRef Int
APPLY Int
UNPACK Int
SLIDE Int
POP Int
ALLOC Int
UPDATE Int
RETURN
EVAL
RETURN_EVAL
NOP
P_ADD PrimOp
P_SUB PrimOp
P_MUL PrimOp
P_DIV PrimOp
P_MOD PrimOp
P_CMP_EQ PrimOp
P_CMP_NE PrimOp
P_CMP_LE PrimOp
P_CMP_LT PrimOp
P_CMP_GE PrimOp
P_CMP_GT PrimOp
P_NEG PrimOp
P_STRING
P_FROM_ENUM
CASE Bool [(Tag, Label)] (Maybe Label)
STOP
TABLE_SWITCH [Label]
LOOKUP_SWITCH [(Tag, Label)] Label
INT_SWITCH [(Tag, Label)] Label
JUMP_FALSE Label
JUMP Label
LABEL Label
PRIMITIVE
EXTERNAL
SELECTOR_EVAL
SELECT Int
TAP CRef
TCON CRef
TPRIMCON CRef
TAPPLY CRef Int
TIF CRef
TGUARD CRef
TCASE CRef
TRETURN
TPRIMAP CRef Int
TPRIMRESULT CRef
TPUSH
TPUSHVAR CRef
TPROJECT CRef
COMMENT String
show/hide Instances
Eq Ins
Ord Ins
Show Ins
data PrimOp
Constructors
OpWord
OpFloat
OpDouble
show/hide Instances
Eq PrimOp
Ord PrimOp
Show PrimOp
type Tag = Int
type Label = Int
Use sets
data UseSet
The use set for an instruction lists the variables that the instructions gives as well as those that it needs, from this we can calculate what should be zapped.
Constructors
UseSet
useDepth :: Int
useGive :: [String]
useNeed :: (Set String)
emptyUS :: UseSet
Create an empty use set
type UseIns = (Ins, UseSet)
A bytecode instruction paired with its use set
Constants
xFlNone :: Int
xFlVoid :: Int
fNone :: Int
fInvisible :: Int
fLambda :: Int
intFlags :: [LambdaFlags] -> Int
frameSize :: Int
calcHeapExtra :: Flags -> Int
splitQualified :: String -> (String, String)
split a qualified name into (module,item)
Produced by Haddock version 0.8