Documentation
¶
Index ¶
- Constants
- Variables
- func IsCallOpcode(op Opcode) bool
- func IsConditionalJumpOpcode(op Opcode) bool
- func IsProtectedCall(op Opcode) bool
- func IsProtectedCallOpcode(op Opcode) bool
- func IsTerminatorOpcode(op Opcode) bool
- func IsUnconditionalJumpOpcode(op Opcode) bool
- func JumpTargetOperandIndex(op Opcode) int
- func ValidateProgram(program *Program) error
- func VisitCallArgumentRegisters(op Opcode, src1, src2 Operand, visit func(reg int))
- type AggregateKind
- type AggregatePlan
- type CallArgEncoding
- type CallKind
- type Catch
- type CollectorType
- type ControlFlowRole
- type Functions
- type Instruction
- type Metadata
- type Opcode
- type OpcodeClass
- type OpcodeInfo
- type Operand
- type Program
- type UDF
Constants ¶
const MaxCollectionPreallocation = 1 << 20
MaxCollectionPreallocation limits the preallocated capacity accepted for persisted OpLoadArray and OpLoadObject instructions. This prevents untrusted artifacts from forcing excessive upfront allocations during execution.
const MaxEncodedSortDirections = bits.UintSize - 1
MaxEncodedSortDirections limits the number of sort directions that can be encoded into OpDataSetMultiSorter using the current signed-int bit-packing. The highest bit must remain clear so the encoded operand stays non-negative, which caps the supported direction count at one less than the machine word size during persisted-program validation.
const NoopOperand = Operand(0)
NoopOperand is a reserved operand for no operation and final results.
const Version = 1
Variables ¶
var ( // ErrInvalidProgram reports that a program is structurally invalid for // persistence or validation. ErrInvalidProgram = errors.New("bytecode: invalid program") // ErrInvalidInstruction reports that a program contains an invalid or // unsupported instruction or operand. ErrInvalidInstruction = errors.New("bytecode: invalid instruction") // ErrInvalidConstant reports that a persisted constant frame is malformed or // uses an unsupported type. ErrInvalidConstant = errors.New("bytecode: invalid constant") )
Functions ¶
func IsCallOpcode ¶
func IsConditionalJumpOpcode ¶
func IsProtectedCall ¶
func IsProtectedCallOpcode ¶
func IsTerminatorOpcode ¶
func JumpTargetOperandIndex ¶
func ValidateProgram ¶
ValidateProgram checks that a bytecode program is structurally valid for persistence and later execution. ISA compatibility is validated separately by loaders and the VM.
Types ¶
type AggregateKind ¶
type AggregateKind int
const ( AggregateCount AggregateKind = iota AggregateSum AggregateMin AggregateMax AggregateAverage )
type AggregatePlan ¶
type AggregatePlan struct {
Index map[string]int `json:"index"`
Keys []runtime.String `json:"keys"`
Kinds []AggregateKind `json:"kinds"`
TrackGroupValues bool `json:"trackGroupValues,omitempty"`
}
func NewAggregatePlan ¶
func NewAggregatePlan(keys []runtime.String, kinds []AggregateKind, trackGroupValues bool) AggregatePlan
type CallArgEncoding ¶
type CallArgEncoding uint8
const ( CallArgEncodingNone CallArgEncoding = iota CallArgEncodingRegisterRange )
type Catch ¶
type Catch [3]int
Catch stores an inclusive instruction range [start, end] and an optional recovery jump target.
type CollectorType ¶
type CollectorType int
const ( CollectorTypeCounter CollectorType = iota CollectorTypeKey CollectorTypeKeyCounter CollectorTypeKeyGroup CollectorTypeAggregate CollectorTypeAggregateGroup )
type ControlFlowRole ¶
type ControlFlowRole uint8
const ( ControlFlowNone ControlFlowRole = iota ControlFlowJumpUnconditional ControlFlowJumpConditional ControlFlowTerminator )
type Functions ¶
type Functions struct {
Host map[string]int `json:"host,omitempty"`
UserDefined []UDF `json:"userDefined,omitempty"`
}
Functions groups host and user-defined function metadata required for execution.
type Instruction ¶
func NewInstruction ¶
func NewInstruction(opcode Opcode, operands ...Operand) Instruction
func (Instruction) String ¶
func (i Instruction) String() string
type Metadata ¶
type Metadata struct {
Labels map[int]string `json:"labels"`
CompilerVersion string `json:"compilerVersion"`
AggregatePlans []AggregatePlan `json:"aggregatePlans"`
AggregateSelectorSlots []int `json:"aggregateSelectorSlots,omitempty"`
MatchFailTargets []int `json:"matchFailTargets,omitempty"`
DebugSpans []file.Span `json:"debugSpans"`
OptimizationLevel int `json:"optimizationLevel"`
}
type Opcode ¶
type Opcode byte
const ( // Control Flow OpReturn Opcode = iota OpJump OpJumpIfFalse OpJumpIfTrue OpJumpIfNone // Register Operations OpMove // Plain register copy — no tracking // Tracked Register Operations OpMoveTracked // Tracked register copy — ownership-aware // Loading Operations OpLoadNone // Set None value to a register OpLoadBool // Set a boolean value to a register OpLoadZero // Set a zero value to a register OpLoadConst // Load a constant to a register or a global variable OpLoadParam // Load a parameter slot to a register A OpMakeCell // Create an internal mutable cell handle from a value OpLoadCell // Load the current value from an internal mutable cell OpStoreCell // Replace the current value in an internal mutable cell OpLoadArray // Create an array OpLoadObject // Create an object OpLoadRange // Create a range // Collection Access Operations OpLoadIndex // Load a value from a built-in Array to a register OpLoadIndexOptional // Load a value from a built-in Array to a register, if it exists OpLoadKey // Load a value from a built-in Object to a register OpLoadKeyOptional // Load a value from a built-in Object to a register, if it exists OpLoadProperty // Load a property from a map or list to a register OpLoadPropertyOptional // Load a property from a map or list to a register, if it exists OpLoadIndexConst // Load a value from a built-in Array to a register using a constant index OpLoadIndexOptionalConst OpLoadKeyConst // Load a value from a built-in Object to a register using a constant key OpLoadKeyOptionalConst OpLoadPropertyConst // Load a property from a map or list to a register using a constant key OpLoadPropertyOptionalConst OpMatchLoadPropertyConst // Load an object-pattern property or jump to the arm fail target // Integrated Query Operations OpQuery // Apply a query to a value // Arithmetic Operations OpAdd OpAddConst OpConcat OpSub OpMul OpDiv OpMod OpIncr OpDecr // Type Operations OpCastBool OpNegate OpFlipPositive OpFlipNegative // Comparison Operations OpCmp OpNot OpEq OpNe OpGt OpLt OpGte OpLte // Membership & Pattern Matching OpIn OpLike OpRegexp // Array Operations OpFlatten // Flattens nested arrays // Array Comparison Operations (do not swap order of EQ, GT, GTE, LT, LTE, IN. it must be equal to operators) OpAnyEq OpAnyNe OpAnyGt OpAnyGte OpAnyLt OpAnyLte OpAnyIn OpNoneEq OpNoneNe OpNoneGt OpNoneGte OpNoneLt OpNoneLte OpNoneIn OpAllEq OpAllNe OpAllGt OpAllGte OpAllLt OpAllLte OpAllIn // Utility Operations OpLength OpType OpClose OpSleep // Host Function Operations OpHCall OpProtectedHCall // UDF Operations OpCall OpProtectedCall OpTailCall // Dataset Operations OpDataSet OpDataSetCollector OpDataSetSorter OpDataSetMultiSorter OpPush // Adds a value to a generic List OpPushKV // Adds a key-value pair to a dataset OpCounterInc // Increments a counter collector OpArrayPush // Adds a value to a built-in Array instance OpObjectSet // Sets a property on a built-in Object instance OpObjectSetConst // Sets a property on a built-in Object instance using a constant key // Stream Operations OpStream // Subscribes to a stream OpStreamIter // Consumes a stream // Iterator Operations OpIter // Creates an iterator OpIterNext // Moves to the next element OpIterValue // Returns the current value OpIterKey // Returns the current key OpIterLimit OpIterSkip // Existence Operations OpExists // Random Operations OpRand // Dispatch Operations OpDispatch // Compare-Jump Operations OpJumpIfNe OpJumpIfNeConst OpJumpIfEq OpJumpIfEqConst OpJumpIfMissingProperty OpJumpIfMissingPropertyConst OpFail // Raises a runtime failure with a constant message // Internal Aggregate Operations OpLoadAggregateKey // Creates an internal grouped-aggregate selector key OpAggregateUpdate OpAggregateGroupUpdate )
type OpcodeClass ¶
type OpcodeClass uint8
const ( OpcodeClassUnknown OpcodeClass = iota OpcodeClassControl OpcodeClassLoad OpcodeClassAccess OpcodeClassArithmetic OpcodeClassType OpcodeClassComparison OpcodeClassArray OpcodeClassUtility OpcodeClassCall OpcodeClassDataset OpcodeClassStream OpcodeClassIterator )
type OpcodeInfo ¶
type OpcodeInfo struct {
Class OpcodeClass
ControlFlow ControlFlowRole
CallKind CallKind
CallArgEncoding CallArgEncoding
ProtectedCall bool
}
func OpcodeInfoOf ¶
func OpcodeInfoOf(op Opcode) OpcodeInfo
type Operand ¶
type Operand int