Documentation ¶
Overview ¶
Package disasm provides functions for disassembling WebAssembly bytecode.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrStackUnderflow = errors.New("disasm: stack underflow")
Functions ¶
func SetDebugMode ¶
func SetDebugMode(l bool)
Types ¶
type BlockInfo ¶
type BlockInfo struct { Start bool // If true, this instruction starts a block. Else this instruction ends it. Signature wasm.BlockType // The block signature // Indices to the accompanying control operator. // For 'if', this is the index to the 'else' operator. IfElseIndex int // For 'else', this is the index to the 'if' operator. ElseIfIndex int // The index to the `end' operator for if/else/loop/block. EndIndex int // For end, it is the index to the operator that starts the block. BlockStartIndex int }
BlockInfo stores details about a block created or ended by an instruction.
type Disassembly ¶
type Disassembly struct { Code []Instr MaxDepth int // The maximum stack depth that can be reached while executing this function }
Disassembly is the result of disassembling a WebAssembly function.
func NewDisassembly ¶
NewDisassembly disassembles the given function. It also takes the function's parent module as an argument for locating any other functions referenced by fn.
type Instr ¶
type Instr struct { Op ops.Op // Immediates are arguments to an operator in the bytecode stream itself. // Valid value types are: // - (u)(int/float)(32/64) // - wasm.BlockType Immediates []interface{} NewStack *StackInfo // non-nil if the instruction creates or unwinds a stack. Block *BlockInfo // non-nil if the instruction starts or ends a new block. Unreachable bool // whether the operator can be reached during execution // IsReturn is true if executing this instruction will result in the // function returning. This is true for branches (br, br_if) to // the depth <max_relative_depth> + 1, or the return operator itself. // If true, NewStack for this instruction is nil. IsReturn bool // If the operator is br_table (ops.BrTable), this is a list of StackInfo // fields for each of the blocks/branches referenced by the operator. Branches []StackInfo }
Instr describes an instruction, consisting of an operator, with its appropriate immediate value(s).
func Disassemble ¶
Disassemble disassembles a given function body into a set of instructions. It won't check operations for validity.
type StackInfo ¶
type StackInfo struct { StackTopDiff int64 // The difference between the stack depths at the end of the block PreserveTop bool // Whether the value on the top of the stack should be preserved while unwinding IsReturn bool // Whether the unwind is equivalent to a return }
StackInfo stores details about a new stack created or unwound by an instruction.
Click to show internal directories.
Click to hide internal directories.