Documentation
¶
Overview ¶
Package bytecode defines ixgo's process-independent instruction descriptions.
Its codec reads and writes the versioned disk format and validates structural references without importing the interpreter. It also converts go/types graphs and debug declarations to and from wire descriptions. Runtime reflect-type mapping, host linking and executor binding remain in package ixgo.
This package is available without build tags. Its exported names form a bridge within the module, not a public compatibility commitment.
Index ¶
- Constants
- Variables
- func Constant(expr ast.Expr) (out constant.Value)
- func DecodeDebugObject(obj DebugObject, typ types.Type) (types.Object, error)
- func DecodeFileSet(data []byte) (*token.FileSet, error)
- func Encode(p *Program) ([]byte, error)
- func EncodeFileSet(fs *token.FileSet) ([]byte, error)
- func Marshal(p *Program) ([]byte, error)
- func ParseConstant(text string) (constant.Value, error)
- func RuntimeType(t types.Type) bool
- func Validate(p *Program) error
- func ValidateProgram(p *Program) error
- type Aux
- func (a Aux) BasicBool() bool
- func (a Aux) Blocking() bool
- func (a Aux) Cached() bool
- func (a Aux) CommaOk() bool
- func (a Aux) Condition() bool
- func (a Aux) Constant() [2]bool
- func (a Aux) Global() bool
- func (a Aux) Heap() bool
- func (a Aux) IsAddr() bool
- func (a Aux) IsString() bool
- func (a Aux) MakeSliceCheck() bool
- func (a *Aux) SetBasicBool(value bool)
- func (a *Aux) SetBlocking(value bool)
- func (a *Aux) SetCached(value bool)
- func (a *Aux) SetCommaOk(value bool)
- func (a *Aux) SetCondition(value bool)
- func (a *Aux) SetConstant(values [2]bool)
- func (a *Aux) SetGlobal(value bool)
- func (a *Aux) SetHeap(value bool)
- func (a *Aux) SetIsAddr(value bool)
- func (a *Aux) SetIsString(value bool)
- func (a *Aux) SetMakeSliceCheck(value bool)
- type AuxFlags
- type AuxKind
- type Boundary
- type BuiltinRegisters
- type CallAux
- type CallRegisters
- type DebugObject
- type DebugObjectKind
- type External
- type Function
- type GCBlock
- type GCCapture
- type GCPlan
- type GCPoint
- type GCTransfer
- type Global
- type Instruction
- type Member
- type MemberKind
- type MemoDescription
- type MemoReceiver
- type MemoReceiverUpdate
- type Method
- type Mode
- type NumericInput
- type Package
- type PackedAssert
- type PackedAux
- type PackedBinary
- type PackedCall
- type PackedClosure
- type PackedConversion
- type PackedCreation
- type PackedDebug
- type PackedExtract
- type PackedField
- type PackedIf
- type PackedIndex
- type PackedJump
- type PackedLookup
- type PackedMap
- type PackedNext
- type PackedPanic
- type PackedPhi
- type PackedRange
- type PackedReturn
- type PackedSelect
- type PackedSend
- type PackedSlice
- type PackedStore
- type PackedUnary
- type Program
- type RuntimeName
- type SelectState
- type TypeDecoder
- type TypeEncoder
- type TypeID
- type TypeKind
- type TypeMethod
- type TypeNode
- type TypePackage
- type TypeTable
- type TypeVar
- type Value
- type ValueKind
Constants ¶
const MaxSize = 64 << 20
const Version = 1
Variables ¶
var Magic = [8]byte{'I', 'X', 'G', 'O', 'B', 'C', 0, Version}
Functions ¶
func DecodeDebugObject ¶
DecodeDebugObject restores a declaration using an already reconstructed type.
func DecodeFileSet ¶
DecodeFileSet validates all offsets before passing them to token's mutators.
func EncodeFileSet ¶
EncodeFileSet preserves complete physical lines and alternative positions. FileSet.Write is the only API that exposes //line mappings. Its exported snapshot fields are read reflectively, without accessing private memory.
func RuntimeType ¶
RuntimeType reports whether a type can occur as a runtime value.
func ValidateProgram ¶
ValidateProgram checks the description and complete type graph.
Types ¶
type Aux ¶
type Aux struct {
Kind AuxKind
Op token.Token
Type TypeID
RightType TypeID
Source TypeID
Target TypeID
Key TypeID
Element TypeID
Field TypeID
Chan TypeID
Address TypeID
Map TypeID
Signature TypeID
GoType TypeID
Flags AuxFlags
Values [2]Value
Preds []int32
Results int
Index int
Targets [2]int32
JumpTarget int32
Registers []obj.Register
RuntimeResults []obj.Register
Edges [][]obj.Register
RuntimeEdges [][]obj.Register
ReceiverCache obj.Register
RuntimeSource obj.Register
RuntimeKey obj.Register
RuntimeIndex obj.Register
RuntimeLow obj.Register
RuntimeHigh obj.Register
RuntimeMax obj.Register
RuntimeChan obj.Register
RuntimeValue obj.Register
RuntimeAddress obj.Register
Offset uintptr
States []SelectState
Body uint32
Call CallAux
Symbol string
Method string
Error string
InterfaceArgs []bool
BuiltinConstant uintptr
BuiltinRuntime BuiltinRegisters
Pos token.Pos
Object DebugObject
Expr string
}
Aux contains only data; Kind selects the fields used by an instruction. Slices deliberately have no omitempty tags: nil and empty are distinct.
func (Aux) MakeSliceCheck ¶
func (*Aux) SetBasicBool ¶
func (*Aux) SetBlocking ¶
func (*Aux) SetCommaOk ¶
func (*Aux) SetCondition ¶
func (*Aux) SetConstant ¶
func (*Aux) SetIsString ¶
func (*Aux) SetMakeSliceCheck ¶
type AuxFlags ¶
type AuxFlags uint16
AuxFlags stores independent instruction properties. Bit values are stable.
func AuxConstantFlags ¶
type AuxKind ¶
type AuxKind uint8
AuxKind is a stable wire tag. New kinds append to this list.
const ( AuxNone AuxKind = iota AuxBinaryOp AuxUnaryOp AuxPhi AuxJump AuxIf AuxReturn AuxExtract AuxNext AuxField AuxLookup AuxIndex AuxSlice AuxRange AuxTypeAssert AuxConversion AuxCreation AuxSend AuxStore AuxMapUpdate AuxPanic AuxClosure AuxCallSite AuxCall AuxDirectCall AuxExternalCall AuxDynamicCall AuxClosureCall AuxInvokeCall AuxBuiltinCall AuxBodyCall AuxSelect AuxInstructionDebugRef )
type BuiltinRegisters ¶
type CallRegisters ¶
type DebugObject ¶
type DebugObject struct {
Kind DebugObjectKind
Name, PackagePath, PackageName, Constant string
Pos token.Pos
Type TypeID
}
DebugObject preserves the basic declaration identity used by callbacks.
func EncodeDebugObject ¶
func EncodeDebugObject(obj types.Object, id TypeID) (DebugObject, error)
EncodeDebugObject preserves declaration identity using the supplied type ID.
type DebugObjectKind ¶
type DebugObjectKind uint8
DebugObjectKind is a stable wire tag. New kinds append to this list.
const ( DebugObjectNone DebugObjectKind = iota DebugObjectVar DebugObjectConst )
func (DebugObjectKind) String ¶
func (k DebugObjectKind) String() string
type Function ¶
type Function struct {
Memo *MemoDescription
InjectReturns []int
NamedResults []obj.Register
Name, Package, Member string
Signature TypeID
Args, Results, Env int
Stack []Value
Blocks []int
Code []Instruction
Recover bool
RecoverPC int32
CacheRegs []obj.Register
ClearRanges [][2]obj.Register
LocalRefs []obj.Register
ChildFrame obj.Register
HasGC bool
GCRegs [][]obj.Register
NameMetadata string
Entry token.Position
EntryPos token.Pos // Optional declaration position in FileSet.
Positions []token.Pos
InterfaceThunk bool
Numeric *NumericInput
GCPlan *GCPlan // Large functions materialize GCRegs on demand.
}
func (*Function) ValidateGC ¶
ValidateGC also protects the lazy runtime binder when other checks are disabled.
type GCPlan ¶
type GCPlan struct {
Registers, Uses, Recover []obj.Register
Blocks []GCBlock
Points []GCPoint
Captures []GCCapture
}
GCPlan describes SSA-free liveness transfers and their mapping to execution PCs.
type GCTransfer ¶
type Instruction ¶
type MemberKind ¶
type MemberKind uint8
MemberKind is a stable wire tag. New kinds append to this list.
const ( MemberInvalid MemberKind = iota MemberGlobal MemberConstant MemberType )
func (MemberKind) String ¶
func (k MemberKind) String() string
type MemoDescription ¶
type MemoDescription struct {
Kind uint8
Returns []int
Output int
State bool
Receiver *MemoReceiver
Updates []MemoReceiverUpdate
}
MemoDescription contains installation data, never live cache entries. Function IDs are supplied by the containing artifact's function table.
type MemoReceiver ¶
type MemoReceiverUpdate ¶
type NumericInput ¶
type PackedAssert ¶
type PackedAux ¶
PackedAux retains only fields used by an auxiliary kind. The codec expands one temporary descriptor at a time, preserving the on-disk schema.
type PackedBinary ¶
type PackedCall ¶
type PackedClosure ¶
type PackedConversion ¶
type PackedCreation ¶
type PackedDebug ¶
type PackedDebug struct {
Pos token.Pos
IsAddr bool
Expr string
Object DebugObject
}
type PackedExtract ¶
type PackedExtract struct {
Index int
}
type PackedField ¶
type PackedIndex ¶
type PackedJump ¶
type PackedJump struct {
JumpTarget int32
}
type PackedLookup ¶
type PackedNext ¶
type PackedNext struct {
IsString bool
}
type PackedPanic ¶
type PackedRange ¶
type PackedReturn ¶
type PackedSelect ¶
type PackedSelect struct {
Blocking bool
States []SelectState
}
type PackedSend ¶
type PackedSlice ¶
type PackedStore ¶
type PackedUnary ¶
type Program ¶
type RuntimeName ¶
type SelectState ¶
type TypeDecoder ¶
type TypeDecoder struct {
// contains filtered or unexported fields
}
func NewTypeDecoder ¶
func NewTypeDecoder(table TypeTable) (d *TypeDecoder, err error)
func ValidateTypes ¶
func ValidateTypes(p *Program) (*TypeDecoder, error)
ValidateTypes performs structural validation and returns the reconstructed type graph so callers can reuse it for binding without a second construction.
func (*TypeDecoder) EnsurePackage ¶
func (d *TypeDecoder) EnsurePackage(path, name string) *types.Package
type TypeEncoder ¶
type TypeEncoder struct {
// contains filtered or unexported fields
}
func NewTypeEncoder ¶
func NewTypeEncoder() *TypeEncoder
func (*TypeEncoder) Err ¶
func (e *TypeEncoder) Err() error
func (*TypeEncoder) Table ¶
func (e *TypeEncoder) Table() TypeTable
type TypeKind ¶
type TypeKind uint8
TypeKind is the stable wire tag for a type node. New kinds append to this list.
type TypeMethod ¶
type TypeNode ¶
type TypeNode struct {
Kind TypeKind
Name, Package string
// Scope is a per-object identity for local names; zero means package scope.
Scope TypeID
Basic int
Len int64
Dir int
Elem, Key, Underlying TypeID
Fields []TypeVar
Params, Results []TypeVar
Receiver *TypeVar
Variadic bool
Methods []TypeMethod
Embeddeds []TypeID
Implicit bool
}
type TypePackage ¶
type TypePackage struct{ Path, Name string }
type TypeTable ¶
type TypeTable struct {
Types []TypeNode
Packages []TypePackage
}
IDs are one-based indices into Types. The wire graph contains no Go objects.
type Value ¶
type Value struct {
Kind ValueKind
Type TypeID
Bits uint64
Imag uint64
Text string
Body uint32
Env []Value
}
Value contains only wire data, never interpreter objects or addresses.