evalop

package
v1.24.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 18, 2024 License: MIT Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFuncCallNotAllowed   = errors.New("function calls not allowed without using 'call'")
	DebugPinnerFunctionName = "runtime.debugPinnerV1"
)

Functions

func Listing

func Listing(depth []int, ops []Op) string

Types

type AddrOf

type AddrOf struct {
	Node *ast.UnaryExpr
}

AddrOf replaces the topmost stack variable v with &v.

type Binary

type Binary struct {
	Node *ast.BinaryExpr
}

Binary pops two variables from the stack, applies the specified binary operator to them and pushes the result back on the stack.

type BoolToConst

type BoolToConst struct {
}

BoolToConst pops the topmost variable from the stack, which must be a boolean variable, and converts it to a constant.

type BuiltinCall

type BuiltinCall struct {
	Name string
	Args []ast.Expr
}

BuiltinCall pops len(Args) argument from the stack, calls the specified builtin on them and pushes the result back on the stack.

type CallInjectionComplete

type CallInjectionComplete struct {
	DoPinning bool
	// contains filtered or unexported fields
}

CallInjectionComplete resumes target execution so that the injected call can run. If DoPinning is true it stops after the call is completed without undoing the call injection frames so that address pinning for the return value can be performed, see CallInjectionComplete2.

type CallInjectionComplete2 added in v1.24.0

type CallInjectionComplete2 struct {
	// contains filtered or unexported fields
}

CallInjectionComplete2 if DoPinning was passed to CallInjectionComplete this will finish the call injection protocol and push the evaluation result on the stack.

type CallInjectionCopyArg

type CallInjectionCopyArg struct {
	ArgNum  int
	ArgExpr ast.Expr
	// contains filtered or unexported fields
}

CallInjectionCopyArg copies one argument for call injection.

type CallInjectionSetTarget

type CallInjectionSetTarget struct {
	// contains filtered or unexported fields
}

CallInjectionSetTarget starts the call injection, after runtime.debugCallVn set up the stack for us, by copying the entry point of the function, setting the closure register and copying the receiver.

type CallInjectionStart

type CallInjectionStart struct {
	HasFunc bool // target function already pushed on the stack
	Node    *ast.CallExpr
	// contains filtered or unexported fields
}

CallInjectionStart starts call injection by calling runtime.debugCallVn.

type CallInjectionStartSpecial added in v1.23.0

type CallInjectionStartSpecial struct {
	FnName string
	ArgAst []ast.Expr
	// contains filtered or unexported fields
}

CallInjectionStartSpecial starts call injection for a function with a name and arguments known at compile time.

type ConvertAllocToString added in v1.23.0

type ConvertAllocToString struct {
}

ConvertAllocToString pops two variables from the stack, a constant string and the return value of runtime.mallocgc (mallocv), copies the contents of the string at the address in mallocv and pushes on the stack a new string value that uses the backing storage of mallocv.

type Flags added in v1.24.0

type Flags uint8

Flags describes flags used to control Compile and CompileAST

const (
	CanSet         Flags = 1 << iota // Assignment is allowed
	HasDebugPinner                   // runtime.debugPinner is available
)

type Index

type Index struct {
	Node *ast.IndexExpr
}

Index pops two variables, idx and v, and pushes v[idx].

type Jump

type Jump struct {
	When   JumpCond
	Pop    bool
	Target int
	Node   ast.Expr
}

Jump looks at the topmost stack variable and if it satisfies the condition specified by When it jumps to the stack machine instruction at Target+1. If Pop is set the topmost stack variable is also popped.

type JumpCond

type JumpCond uint8

JumpCond specifies a condition for the Jump instruction.

const (
	JumpIfFalse JumpCond = iota
	JumpIfTrue
	JumpIfAllocStringChecksFail
	JumpAlways
	JumpIfPinningDone
)

type Op

type Op interface {
	// contains filtered or unexported methods
}

Op is a stack machine opcode

func Compile

func Compile(lookup evalLookup, expr string, flags Flags) ([]Op, error)

Compile compiles the expression expr into a list of instructions. If canSet is true expressions like "x = y" are also accepted.

func CompileAST

func CompileAST(lookup evalLookup, t ast.Expr, flags Flags) ([]Op, error)

CompileAST compiles the expression t into a list of instructions.

func CompileSet

func CompileSet(lookup evalLookup, lhexpr, rhexpr string, flags Flags) ([]Op, error)

CompileSet compiles the expression setting lhexpr to rhexpr into a list of instructions.

type PointerDeref

type PointerDeref struct {
	Node *ast.StarExpr
}

PointerDeref replaces the topmost stack variable v with *v.

type Pop

type Pop struct {
}

Pop removes the topmost variable from the stack.

type PushConst

type PushConst struct {
	Value constant.Value
}

PushConst pushes a constant on the stack.

type PushCurg

type PushCurg struct {
}

PushCurg pushes the current goroutine on the stack.

type PushDebugPinner added in v1.24.0

type PushDebugPinner struct {
}

PushDebugPinner pushes the debug pinner on the stack.

type PushFrameoff

type PushFrameoff struct {
}

PushFrameoff pushes the frame offset for the current frame on the stack.

type PushIdent added in v1.23.0

type PushIdent struct {
	Name string
}

PushIdent pushes a local or global variable or a predefined identifier (true, false, etc) or the value of a register on the stack.

type PushLen added in v1.23.0

type PushLen struct {
}

PushLen pushes the length of the variable at the top of the stack into the stack.

type PushLocal

type PushLocal struct {
	Name  string
	Frame int64
}

PushLocal pushes the local variable with the given name on the stack.

type PushNil

type PushNil struct {
}

PushNil pushes an untyped nil on the stack.

type PushPackageVarOrSelect added in v1.23.0

type PushPackageVarOrSelect struct {
	Name, Sel    string
	NameIsString bool
}

PushPackageVarOrSelect pushes the value of Name.Sel on the stack, which could either be a global variable (with the package name specified), or a field of a local variable.

type PushPinAddress added in v1.24.0

type PushPinAddress struct {
}

PushPinAddress pushes an address to pin on the stack (as an unsafe.Pointer) and removes it from the list of addresses to pin.

type PushRangeParentOffset added in v1.23.0

type PushRangeParentOffset struct {
}

PushRangeParentOffset pushes the frame offset of the range-over-func closure body parent.

type PushThreadID

type PushThreadID struct {
}

PushThreadID pushes the ID of the current thread on the stack.

type Reslice

type Reslice struct {
	HasHigh  bool
	TrustLen bool
	Node     *ast.SliceExpr
}

Reslice implements a reslice operation. If HasHigh is set it pops three variables, low, high and v, and pushes v[low:high]. Otherwise it pops two variables, low and v, and pushes v[low:]. If TrustLen is set when the variable resulting from the reslice is loaded it will be fully loaded.

type Roll added in v1.24.0

type Roll struct {
	N int
}

Roll removes the n-th element of the stack and pushes it back in at the top

type Select

type Select struct {
	Name string
}

Select replaces the topmost stack variable v with v.Name.

type SetDebugPinner added in v1.24.0

type SetDebugPinner struct {
}

SetDebugPinner pops one variable from the stack and uses it as the saved debug pinner.

type SetValue

type SetValue struct {
	Rhe ast.Expr
	// contains filtered or unexported fields
}

SetValue pops to variables from the stack, lhv and rhv, and sets lhv to rhv.

type TypeAssert

type TypeAssert struct {
	DwarfType godwarf.Type
	Node      *ast.TypeAssertExpr
}

TypeAssert replaces the topmost stack variable v with v.(DwarfType).

type TypeCast

type TypeCast struct {
	DwarfType godwarf.Type
	Node      *ast.CallExpr
}

TypeCast replaces the topmost stack variable v with (DwarfType)(v).

type Unary

type Unary struct {
	Node *ast.UnaryExpr
}

Unary applies the given unary operator to the topmost stack variable.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL