Documentation ¶
Index ¶
- Constants
- type BasicBlock
- type CFGraph
- type FixupInfo
- type GasPolicy
- type Instr
- type InterpreterCode
- type Location
- type Module
- type SSAFunctionCompiler
- func (c *SSAFunctionCompiler) Compile(importTypeIDs []int)
- func (c *SSAFunctionCompiler) FilterFloatingPoint()
- func (c *SSAFunctionCompiler) FixupLocationRef(loc *Location, wasUnreachable bool)
- func (c *SSAFunctionCompiler) InsertGasCounters(gp GasPolicy)
- func (c *SSAFunctionCompiler) NGen(selfID uint64, numParams uint64, numLocals uint64, numGlobals uint64) string
- func (c *SSAFunctionCompiler) NewCFGraph() *CFGraph
- func (c *SSAFunctionCompiler) NextValueID() TyValueID
- func (c *SSAFunctionCompiler) PopStack(n int) []TyValueID
- func (c *SSAFunctionCompiler) PushStack(values ...TyValueID)
- func (c *SSAFunctionCompiler) RegAlloc() int
- func (c *SSAFunctionCompiler) Serialize() []byte
- type SimpleGasPolicy
- type TyJmpKind
- type TyValueID
Constants ¶
const NGEN_ENV_API_PREFIX = "wenv_"
const NGEN_FP_HEADER = `` /* 1043-byte string literal not displayed */
const NGEN_FUNCTION_PREFIX = "wasm_function_"
const NGEN_HEADER = `` /* 2018-byte string literal not displayed */
const NGEN_INS_LABEL_PREFIX = "ins"
const NGEN_LOCAL_PREFIX = "l"
const NGEN_VALUE_PREFIX = "v"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BasicBlock ¶
type CFGraph ¶
type CFGraph struct {
Blocks []BasicBlock
}
type Instr ¶
type Instr struct { Target TyValueID // the value id we are assigning to Op string Immediates []int64 Values []TyValueID }
Instr denotes a single instrution.
func (*Instr) BranchTargets ¶
type InterpreterCode ¶
type Module ¶
func LoadModule ¶
func (*Module) CompileForInterpreter ¶
func (m *Module) CompileForInterpreter(gp GasPolicy) (_retCode []InterpreterCode, retErr error)
type SSAFunctionCompiler ¶
type SSAFunctionCompiler struct { Module *wasm.Module Source *disasm.Disassembly Code []Instr Stack []TyValueID Locations []*Location CallIndexOffset int StackValueSets map[int][]TyValueID UsedValueIDs map[TyValueID]struct{} ValueID TyValueID }
SSAFunctionCompiler represents a compiler which translates a WebAssembly modules intepreted code into a Static-Single-Assignment-based intermediate representation.
func NewSSAFunctionCompiler ¶
func NewSSAFunctionCompiler(m *wasm.Module, d *disasm.Disassembly) *SSAFunctionCompiler
NewSSAFunctionCompiler instantiates a compiler which translates a WebAssembly modules intepreted code into a Static-Single-Assignment-based intermediate representation.
func (*SSAFunctionCompiler) Compile ¶
func (c *SSAFunctionCompiler) Compile(importTypeIDs []int)
Compile compiles an interpreted WebAssembly modules source code into a Static-Single-Assignment-based intermediate representation.
func (*SSAFunctionCompiler) FilterFloatingPoint ¶
func (c *SSAFunctionCompiler) FilterFloatingPoint()
func (*SSAFunctionCompiler) FixupLocationRef ¶
func (c *SSAFunctionCompiler) FixupLocationRef(loc *Location, wasUnreachable bool)
func (*SSAFunctionCompiler) InsertGasCounters ¶
func (c *SSAFunctionCompiler) InsertGasCounters(gp GasPolicy)
func (*SSAFunctionCompiler) NewCFGraph ¶
func (c *SSAFunctionCompiler) NewCFGraph() *CFGraph
func (*SSAFunctionCompiler) NextValueID ¶
func (c *SSAFunctionCompiler) NextValueID() TyValueID
func (*SSAFunctionCompiler) PopStack ¶
func (c *SSAFunctionCompiler) PopStack(n int) []TyValueID
func (*SSAFunctionCompiler) PushStack ¶
func (c *SSAFunctionCompiler) PushStack(values ...TyValueID)
func (*SSAFunctionCompiler) RegAlloc ¶
func (c *SSAFunctionCompiler) RegAlloc() int
FIXME: The current RegAlloc is based on wasm stack info and we probably want a real one (in addition to this) with liveness analysis. Returns the total number of registers used.
func (*SSAFunctionCompiler) Serialize ¶
func (c *SSAFunctionCompiler) Serialize() []byte
Serialize serializes a set of SSA-form instructions into a byte array for execution with an exec.VirtualMachine.
Instruction encoding: Value ID (4 bytes) | Opcode (1 byte) | Operands
Types are erased in the generated code. Example: float32/float64 are represented as uint32/uint64 respectively.
type SimpleGasPolicy ¶
type SimpleGasPolicy struct {
GasPerInstruction int64
}
func (*SimpleGasPolicy) GetCost ¶
func (p *SimpleGasPolicy) GetCost(key string) int64