encoder

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LnOffset = int64(unsafe.Offsetof(StateItem{}.Ln))
	MiOffset = int64(unsafe.Offsetof(StateItem{}.Mi))
	WpOffset = int64(unsafe.Offsetof(StateItem{}.Wp))
	BmOffset = int64(unsafe.Offsetof(RuntimeState{}.Bm))
)
View Source
const (
	MiKeyOffset   = int64(unsafe.Offsetof(rt.GoMapIterator{}.K))
	MiValueOffset = int64(unsafe.Offsetof(rt.GoMapIterator{}.V))
)
View Source
const (
	StateMax  = (defs.StackSize - 1) * StateSize
	StateSize = int64(unsafe.Sizeof(StateItem{}))
)
View Source
const (
	RangeUint8  = math.MaxUint8 + 1
	RangeUint16 = math.MaxUint16 + 1
)
View Source
const (
	ARG_buf      = 0
	ARG_len      = 1
	ARG_mem_itab = 2
	ARG_mem_data = 3
	ARG_p        = 4
	ARG_rs       = 5
	ARG_st       = 6
)
View Source
const (
	WP = hir.P1
	RP = hir.P2
	RS = hir.P3
	ET = hir.P4 // may also be used as a temporary pointer register
	EP = hir.P5 // may also be used as a temporary pointer register
)
View Source
const (
	RL = hir.R2
	RC = hir.R3
	ST = hir.R4
)
View Source
const (
	TP = hir.P0
	TR = hir.R0
	UR = hir.R1
)
View Source
const (
	LB_halt       = "_halt"
	LB_error      = "_error"
	LB_nomem      = "_nomem"
	LB_overflow   = "_overflow"
	LB_duplicated = "_duplicated"
)

Variables

View Source
var (
	MissCount uint64 = 0
	TypeCount uint64 = 0
)
View Source
var (
	F_mapiternext  = hir.RegisterGCall(mapiternext, emu_gcall_mapiternext)
	F_mapiterstart = hir.RegisterGCall(mapiterstart, emu_gcall_mapiterstart)
)
View Source
var (
	F_unique32  = hir.RegisterGCall(unique32, emu_gcall_unique32)
	F_unique64  = hir.RegisterGCall(unique64, emu_gcall_unique64)
	F_uniquestr = hir.RegisterGCall(uniquestr, emu_gcall_uniquestr)
)
View Source
var (
	F_encode *hir.CallHandle
)

Functions

func EncodeObject

func EncodeObject(buf []byte, mem thrift.NocopyWriter, val interface{}) (ret int, err error)

func EncodedSize

func EncodedSize(val interface{}) int

func Pretouch

func Pretouch(vt *rt.GoType, opts opts.Options) error

func SetLinker

func SetLinker(v Linker)

func Translate

func Translate(s Program) hir.Program

Types

type BasicBlock

type BasicBlock struct {
	P    Program
	Src  int
	End  int
	Next *BasicBlock
	Link *BasicBlock
}

func (*BasicBlock) Free

func (self *BasicBlock) Free()

func (*BasicBlock) Len

func (self *BasicBlock) Len() int

func (*BasicBlock) String

func (self *BasicBlock) String() string

type Compiler

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

func CreateCompiler

func CreateCompiler() *Compiler

func (*Compiler) Apply

func (self *Compiler) Apply(o opts.Options) *Compiler

func (*Compiler) Compile

func (self *Compiler) Compile(vt reflect.Type) (_ Program, err error)

func (*Compiler) CompileAndFree

func (self *Compiler) CompileAndFree(vt reflect.Type) (ret Program, err error)

func (*Compiler) Free

func (self *Compiler) Free()

type Encoder

type Encoder func(
	buf unsafe.Pointer,
	len int,
	mem thrift.NocopyWriter,
	p unsafe.Pointer,
	rs *RuntimeState,
	st int,
) (int, error)
func Link(p hir.Program) Encoder

type GraphBuilder

type GraphBuilder struct {
	Pin   map[int]bool
	Graph map[int]*BasicBlock
}

func (*GraphBuilder) Build

func (self *GraphBuilder) Build(p Program) *BasicBlock

func (*GraphBuilder) BuildAndFree

func (self *GraphBuilder) BuildAndFree(p Program) (bb *BasicBlock)

func (*GraphBuilder) Free

func (self *GraphBuilder) Free()

type Instr

type Instr struct {
	Op OpCode
	Uv int32
	Iv int64
	To int
	Pr unsafe.Pointer
}

func (Instr) Byte

func (self Instr) Byte(i int64) int8

func (Instr) Disassemble

func (self Instr) Disassemble() string

func (Instr) Long

func (self Instr) Long(i int64) int32

func (Instr) Quad

func (self Instr) Quad(i int64) int64

func (Instr) Str

func (self Instr) Str() string

func (Instr) Vt

func (self Instr) Vt() *rt.GoType

func (Instr) Word

func (self Instr) Word(i int64) int16

type Linker

type Linker interface {
	Link(p hir.Program) Encoder
}

type LinkerAMD64

type LinkerAMD64 struct{}
func (LinkerAMD64) Link(p hir.Program) Encoder

type OpCode

type OpCode uint8
const (
	OP_size_check OpCode = iota
	OP_size_const
	OP_size_dyn
	OP_size_map
	OP_size_defer
	OP_byte
	OP_word
	OP_long
	OP_quad
	OP_sint
	OP_length
	OP_memcpy_be
	OP_seek
	OP_deref
	OP_defer
	OP_map_len
	OP_map_key
	OP_map_next
	OP_map_value
	OP_map_begin
	OP_map_if_next
	OP_map_if_empty
	OP_list_decr
	OP_list_begin
	OP_list_if_next
	OP_list_if_empty
	OP_unique
	OP_goto
	OP_if_nil
	OP_if_hasbuf
	OP_if_eq_imm
	OP_if_eq_str
	OP_make_state
	OP_drop_state
	OP_halt
)

func (OpCode) String

func (self OpCode) String() string

type Program

type Program []Instr

func Optimize

func Optimize(p Program) Program

func (Program) Disassemble

func (self Program) Disassemble() string

func (Program) Free

func (self Program) Free()

type RuntimeState

type RuntimeState struct {
	St  [defs.StackSize]StateItem // Must be the first field.
	Bm  [1024]uint64              // Bitmap, used for uniqueness check of set<i8> and set<i16>.
	Val unsafe.Pointer            // Pointer to the object to be encoded
}

type StateItem

type StateItem struct {
	Ln uintptr
	Wp unsafe.Pointer
	Mi rt.GoMapIterator
}

Jump to

Keyboard shortcuts

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