Documentation
¶
Overview ¶
Package jit provides a safe alternative to reflect.MakeFunc with support for transparent optimisation.
This package is still in an experimental proof-of-concept phase and is not quite ready for general use. The aim is to provide a safe way to create small optimised functions at runtime. This package is included in runtime.link to serve as an optimisation pathway for [api.Linker] implementations.
Index ¶
- Variables
- func Make[T any](impl Implementation) (T, error)
- func MakeFunc(fnType reflect.Type, impl Implementation) (reflect.Value, error)
- type ABI
- type Assembly
- func (asm Assembly) Add(a, b Value) Value
- func (asm Assembly) Convert(a Value, rtype reflect.Type) Value
- func (asm Assembly) Go(val Value, fn func(pointer unsafe.Pointer) reflect.Value) Value
- func (asm Assembly) IsZero(a Value) Value
- func (asm Assembly) NewError() Value
- func (asm Assembly) Not(a Value) Value
- func (asm Assembly) NullTerminated(s Value) Value
- func (asm Assembly) Pinner() Pinner
- func (asm Assembly) SliceLen(s Value) Value
- func (asm Assembly) StringLen(s Value) Value
- func (asm Assembly) UnsafeCall(abi ABI, ptr unsafe.Pointer, args []Value, rets ...reflect.Type) ([]Value, []Lifetime, error)
- type HardwareLocation
- type Implementation
- type Lifetime
- type Location
- type Pinner
- type Value
Constants ¶
This section is empty.
Variables ¶
var HardwareLocations = xyz.AccessorFor(HardwareLocation.Values)
var Locations = xyz.AccessorFor(Location.Values)
Functions ¶
func Make ¶
func Make[T any](impl Implementation) (T, error)
Make a new function of type 'T' using the given JIT implementation function. The implementation function must have the JIT equivalent for each argument and return value. The Implementation function may be called each time the JIT function is called, in order to compile it, or it may only be called once. Therefore the behaviour of the implementation should not depend on any side effects or mutability.
func MakeFunc ¶
MakeFunc is like Make, but it can be used to create a function value from a reflect.Type instead of one known at compile time.
Types ¶
type ABI ¶
type ABI interface { // Call the given pointer with the given arguments and return the results. // This will be used when making a 'safe' function using [reflect.MakeFunc] or // when the platform does not have JIT optimisations enabled. If an error is // returned, it will be returned by [MakeFunc]. The second return value should // contains functions that should release any resources allocated by the // corresponding argument. Call(unsafe.Pointer, []reflect.Value, ...reflect.Type) ([]reflect.Value, []func(), error) // CallingConvention returns the calling convention for the given function type // so that the location of each argument and return value is clearly specified, // if an error is returned, [Call] is used as a fallback. CallingConvention(reflect.Type) (args, rets []Location, err error) }
ABI describes how to call an unsafe.Pointer as the specified function type.
type Assembly ¶
type Assembly struct {
// contains filtered or unexported fields
}
Assembly used to assemble a function.
func (Assembly) NullTerminated ¶
type HardwareLocation ¶
type HardwareLocation xyz.Tagged[uint64, struct { Register xyz.Case[HardwareLocation, cpu.GPR] // standard register. Floating xyz.Case[HardwareLocation, cpu.FPR] // standard floating-point register. Stack xyz.Case[HardwareLocation, uintptr] // offset to the parameter on the stack. }]
HardwareLocation describes the physical and direct location of a value.
type Implementation ¶
Implementation for a function.
type Lifetime ¶
type Lifetime struct {
// contains filtered or unexported fields
}
Lifetime for a value.
type Location ¶
type Location xyz.Tagged[any, struct { Physical xyz.Case[Location, HardwareLocation] // value is passed directly. Indirect xyz.Case[Location, HardwareLocation] // value is passed indirectly. Multiple xyz.Case[Location, []Location] // multiple values (ie. struct). }]
Location of a function's argument or return value.