Package gc

import "cmd/compile/internal/gc"
Overview
Index
Subdirectories

Overview ▾

Index ▾

Constants
Variables
func AddAux(a *obj.Addr, v *ssa.Value)
func AddAux2(a *obj.Addr, v *ssa.Value, offset int64)
func AddrAuto(a *obj.Addr, v *ssa.Value)
func Addrconst(a *obj.Addr, v int64)
func AuxOffset(v *ssa.Value) (offset int64)
func CheckLoweredGetClosurePtr(v *ssa.Value)
func CheckLoweredPhi(v *ssa.Value)
func Dump(s string, n *Node)
func Exit(code int)
func Fatalf(fmt_ string, args ...interface{})
func IncomparableField(t *types.Type) *types.Field
func IsAlias(sym *types.Sym) bool
func IsComparable(t *types.Type) bool
func IsRegularMemory(t *types.Type) bool
func Isconst(n *Node, ct Ctype) bool
func Main(archInit func(*Arch))
func Patch(p *obj.Prog, to *obj.Prog)
func Rnd(o int64, r int64) int64
func Warn(fmt_ string, args ...interface{})
func Warnl(line src.XPos, fmt_ string, args ...interface{})
type AlgKind
type Arch
type BlockEffects
type Branch
type Class
    func (i Class) String() string
type Ctype
type Dlist
type Error
type EscEdge
type EscHole
type EscLeaks
    func ParseLeaks(s string) EscLeaks
    func (l *EscLeaks) AddHeap(derefs int)
    func (l *EscLeaks) AddResult(i, derefs int)
    func (l EscLeaks) Empty() bool
    func (l EscLeaks) Encode() string
    func (l EscLeaks) Heap() int
    func (l *EscLeaks) Optimize()
    func (l EscLeaks) Result(i int) int
type EscLocation
type EscNote
type Escape
type FloatingEQNEJump
type FmtFlag
type Func
    func (f *Func) Dupok() bool
    func (f *Func) ExportInline() bool
    func (f *Func) HasDefer() bool
    func (f *Func) InlinabilityChecked() bool
    func (f *Func) InstrumentBody() bool
    func (f *Func) IsHiddenClosure() bool
    func (f *Func) Needctxt() bool
    func (f *Func) NilCheckDisabled() bool
    func (f *Func) OpenCodedDeferDisallowed() bool
    func (f *Func) ReflectMethod() bool
    func (f *Func) SetDupok(b bool)
    func (f *Func) SetExportInline(b bool)
    func (f *Func) SetHasDefer(b bool)
    func (f *Func) SetInlinabilityChecked(b bool)
    func (f *Func) SetInstrumentBody(b bool)
    func (f *Func) SetIsHiddenClosure(b bool)
    func (f *Func) SetNeedctxt(b bool)
    func (f *Func) SetNilCheckDisabled(b bool)
    func (f *Func) SetOpenCodedDeferDisallowed(b bool)
    func (f *Func) SetReflectMethod(b bool)
    func (f *Func) SetWrapper(b bool)
    func (f *Func) Wrapper() bool
type GCProg
type InitEntry
type InitOrder
type InitPlan
type InitSchedule
type Inline
type Liveness
type LivenessIndex
    func (idx LivenessIndex) Valid() bool
type LivenessMap
    func (m LivenessMap) Get(v *ssa.Value) LivenessIndex
type Mark
type Mpcplx
    func (v *Mpcplx) Div(rv *Mpcplx) bool
    func (v *Mpcplx) GoString() string
    func (v *Mpcplx) Mul(rv *Mpcplx)
    func (v *Mpcplx) String() string
type Mpflt
    func (a *Mpflt) Add(b *Mpflt)
    func (a *Mpflt) AddFloat64(c float64)
    func (a *Mpflt) Cmp(b *Mpflt) int
    func (a *Mpflt) CmpFloat64(c float64) int
    func (a *Mpflt) Float32() float64
    func (a *Mpflt) Float64() float64
    func (fvp *Mpflt) GoString() string
    func (a *Mpflt) Mul(b *Mpflt)
    func (a *Mpflt) MulFloat64(c float64)
    func (a *Mpflt) Neg()
    func (a *Mpflt) Quo(b *Mpflt)
    func (a *Mpflt) Set(b *Mpflt)
    func (a *Mpflt) SetFloat64(c float64)
    func (a *Mpflt) SetInt(b *Mpint)
    func (a *Mpflt) SetString(as string)
    func (f *Mpflt) String() string
    func (a *Mpflt) Sub(b *Mpflt)
type Mpint
    func (a *Mpint) Add(b *Mpint)
    func (a *Mpint) And(b *Mpint)
    func (a *Mpint) AndNot(b *Mpint)
    func (a *Mpint) Cmp(b *Mpint) int
    func (a *Mpint) CmpInt64(c int64) int
    func (a *Mpint) GoString() string
    func (a *Mpint) Int64() int64
    func (a *Mpint) Lsh(b *Mpint)
    func (a *Mpint) Mul(b *Mpint)
    func (a *Mpint) Neg()
    func (a *Mpint) Or(b *Mpint)
    func (a *Mpint) Quo(b *Mpint)
    func (a *Mpint) Rem(b *Mpint)
    func (a *Mpint) Rsh(b *Mpint)
    func (a *Mpint) Set(b *Mpint)
    func (a *Mpint) SetFloat(b *Mpflt) bool
    func (a *Mpint) SetInt64(c int64)
    func (a *Mpint) SetOverflow()
    func (a *Mpint) SetString(as string)
    func (a *Mpint) String() string
    func (a *Mpint) Sub(b *Mpint)
    func (a *Mpint) Xor(b *Mpint)
type Name
    func (n *Name) Addrtaken() bool
    func (n *Name) Assigned() bool
    func (n *Name) AutoTemp() bool
    func (n *Name) Byval() bool
    func (n *Name) Captured() bool
    func (n *Name) InlFormal() bool
    func (n *Name) InlLocal() bool
    func (n *Name) IsClosureVar() bool
    func (n *Name) IsOutputParamHeapAddr() bool
    func (n *Name) Keepalive() bool
    func (n *Name) LibfuzzerExtraCounter() bool
    func (n *Name) Needzero() bool
    func (n *Name) OpenDeferSlot() bool
    func (n *Name) Readonly() bool
    func (n *Name) SetAddrtaken(b bool)
    func (n *Name) SetAssigned(b bool)
    func (n *Name) SetAutoTemp(b bool)
    func (n *Name) SetByval(b bool)
    func (n *Name) SetCaptured(b bool)
    func (n *Name) SetInlFormal(b bool)
    func (n *Name) SetInlLocal(b bool)
    func (n *Name) SetIsClosureVar(b bool)
    func (n *Name) SetIsOutputParamHeapAddr(b bool)
    func (n *Name) SetKeepalive(b bool)
    func (n *Name) SetLibfuzzerExtraCounter(b bool)
    func (n *Name) SetNeedzero(b bool)
    func (n *Name) SetOpenDeferSlot(b bool)
    func (n *Name) SetReadonly(b bool)
    func (n *Name) SetUsed(b bool)
    func (n *Name) Used() bool
type NilVal
type Node
    func AutoVar(v *ssa.Value) (*Node, int64)
    func (n *Node) Bool() bool
    func (n *Node) Bounded() bool
    func (n *Node) CanInt64() bool
    func (n *Node) Class() Class
    func (n *Node) Colas() bool
    func (n *Node) Diag() bool
    func (n *Node) Embedded() bool
    func (n *Node) Format(s fmt.State, verb rune)
    func (n *Node) HasBreak() bool
    func (n *Node) HasCall() bool
    func (n *Node) HasOpt() bool
    func (n *Node) HasVal() bool
    func (n *Node) Implicit() bool
    func (n *Node) IndexMapLValue() bool
    func (n *Node) Initorder() uint8
    func (n *Node) Int64() int64
    func (n *Node) Iota() int64
    func (n *Node) IsAutoTmp() bool
    func (n *Node) IsDDD() bool
    func (n *Node) IsMethod() bool
    func (n *Node) IsSynthetic() bool
    func (n *Node) Likely() bool
    func (n *Node) Line() string
    func (n *Node) NoInline() bool
    func (n *Node) NonNil() bool
    func (n *Node) Opt() interface{}
    func (n *Node) ResetAux()
    func (n *Node) SetBounded(b bool)
    func (n *Node) SetClass(b Class)
    func (n *Node) SetColas(b bool)
    func (n *Node) SetDiag(b bool)
    func (n *Node) SetEmbedded(b bool)
    func (n *Node) SetHasBreak(b bool)
    func (n *Node) SetHasCall(b bool)
    func (n *Node) SetHasOpt(b bool)
    func (n *Node) SetHasVal(b bool)
    func (n *Node) SetImplicit(b bool)
    func (n *Node) SetIndexMapLValue(b bool)
    func (n *Node) SetInitorder(b uint8)
    func (n *Node) SetIota(x int64)
    func (n *Node) SetIsDDD(b bool)
    func (n *Node) SetLikely(b bool)
    func (n *Node) SetNoInline(b bool)
    func (n *Node) SetNonNil(b bool)
    func (n *Node) SetOpt(x interface{})
    func (n *Node) SetSliceBounds(low, high, max *Node)
    func (n *Node) SetSubOp(op Op)
    func (n *Node) SetTChanDir(dir types.ChanDir)
    func (n *Node) SetTransient(b bool)
    func (n *Node) SetTypecheck(b uint8)
    func (n *Node) SetVal(v Val)
    func (n *Node) SetWalkdef(b uint8)
    func (n *Node) SliceBounds() (low, high, max *Node)
    func (n *Node) StorageClass() ssa.StorageClass
    func (n *Node) String() string
    func (n *Node) SubOp() Op
    func (n *Node) TChanDir() types.ChanDir
    func (n *Node) Transient() bool
    func (n *Node) Typ() *types.Type
    func (n *Node) Typecheck() uint8
    func (n *Node) Val() Val
    func (n *Node) Walkdef() uint8
type NodeSet
    func (s *NodeSet) Add(n *Node)
    func (s NodeSet) Has(n *Node) bool
    func (s NodeSet) Sorted(less func(*Node, *Node) bool) []*Node
type Nodes
    func (n Nodes) Addr(i int) **Node
    func (n *Nodes) Append(a ...*Node)
    func (n *Nodes) AppendNodes(n2 *Nodes)
    func (n Nodes) First() *Node
    func (n Nodes) Format(s fmt.State, verb rune)
    func (n Nodes) Index(i int) *Node
    func (n Nodes) Len() int
    func (n *Nodes) MoveNodes(n2 *Nodes)
    func (n *Nodes) Prepend(a ...*Node)
    func (n Nodes) Second() *Node
    func (n *Nodes) Set(s []*Node)
    func (n *Nodes) Set1(n1 *Node)
    func (n *Nodes) Set2(n1, n2 *Node)
    func (n *Nodes) Set3(n1, n2, n3 *Node)
    func (n Nodes) SetFirst(node *Node)
    func (n Nodes) SetIndex(i int, node *Node)
    func (n Nodes) SetSecond(node *Node)
    func (n Nodes) Slice() []*Node
    func (n Nodes) String() string
type Op
    func (o Op) Format(s fmt.State, verb rune)
    func (o Op) GoString() string
    func (o Op) IsSlice3() bool
    func (i Op) String() string
type Order
type Param
type Progs
    func (pp *Progs) Appendpp(p *obj.Prog, as obj.As, ftype obj.AddrType, freg int16, foffset int64, ttype obj.AddrType, treg int16, toffset int64) *obj.Prog
    func (pp *Progs) Flush()
    func (pp *Progs) Free()
    func (pp *Progs) NewProg() *obj.Prog
    func (pp *Progs) Prog(as obj.As) *obj.Prog
type SSAGenState
    func (s *SSAGenState) AddrScratch(a *obj.Addr)
    func (s *SSAGenState) Br(op obj.As, target *ssa.Block) *obj.Prog
    func (s *SSAGenState) Call(v *ssa.Value) *obj.Prog
    func (s *SSAGenState) DebugFriendlySetPosFrom(v *ssa.Value)
    func (s *SSAGenState) FPJump(b, next *ssa.Block, jumps *[2][2]FloatingEQNEJump)
    func (s *SSAGenState) Pc() *obj.Prog
    func (s *SSAGenState) PrepareCall(v *ssa.Value)
    func (s *SSAGenState) Prog(as obj.As) *obj.Prog
    func (s *SSAGenState) SetPos(pos src.XPos)
    func (s *SSAGenState) UseArgs(n int64)
type ScopeID
type Sig
type Symlink
type Timings
    func (t *Timings) AddEvent(size int64, unit string)
    func (t *Timings) Start(labels ...string)
    func (t *Timings) Stop(labels ...string)
    func (t *Timings) Write(w io.Writer, prefix string)
type Val
    func (v Val) Ctype() Ctype
    func (v Val) Format(s fmt.State, verb rune)
    func (v Val) Interface() interface{}

Package files

alg.go align.go bexport.go bimport.go bitset.go builtin.go bv.go class_string.go closure.go const.go dcl.go dump.go dwinl.go esc.go escape.go export.go fmt.go gen.go go.go gsubr.go iexport.go iimport.go init.go initorder.go inl.go lex.go main.go mapfile_mmap.go mpfloat.go mpint.go noder.go obj.go op_string.go order.go pgen.go phi.go plive.go pprof.go racewalk.go range.go reflect.go scc.go scope.go select.go sinit.go ssa.go subr.go swt.go syntax.go timings.go trace.go typecheck.go types.go types_acc.go universe.go unsafe.go util.go walk.go

Constants

FNV-1 hash function constants.

const (
    H0 = 2166136261
    Hp = 16777619
)
const (
    EscFuncUnknown = 0 + iota
    EscFuncPlanned
    EscFuncStarted
    EscFuncTagged
)
const (
    EscUnknown = iota
    EscNone    // Does not escape to heap, result, or parameters.
    EscHeap    // Reachable from the heap
    EscNever   // By construction will not escape.
)

*types.Sym, *types.Type, and *Node types use the flags below to set the format mode

const (
    FErr fmtMode = iota
    FDbg
    FTypeId
    FTypeIdName // same as FTypeId, but use package name instead of prefix
)

Static initialization phase. These values are stored in two bits in Node.flags.

const (
    InitNotStarted = iota
    InitDone
    InitPending
)
const (
    // Func pragmas.
    Nointerface    syntax.Pragma = 1 << iota
    Noescape                     // func parameters don't escape
    Norace                       // func must not have race detector annotations
    Nosplit                      // func should not execute on separate stack
    Noinline                     // func should not be inlined
    NoCheckPtr                   // func should not be instrumented by checkptr
    CgoUnsafeArgs                // treat a pointer to one arg as a pointer to them all
    UintptrEscapes               // pointers converted to uintptr escape

    // Runtime-only func pragmas.
    // See ../../../../runtime/README.md for detailed descriptions.
    Systemstack        // func must run on system stack
    Nowritebarrier     // emit compiler error instead of write barrier
    Nowritebarrierrec  // error on write barrier in this or recursive callees
    Yeswritebarrierrec // cancels Nowritebarrierrec in this function and callees

    // Runtime-only type pragmas
    NotInHeap // values of this type must not be heap allocated
)
const (
    // Maximum size in bits for Mpints before signalling
    // overflow and also mantissa precision for Mpflts.
    Mpprec = 512
    // Turn on for constant arithmetic debugging output.
    Mpdebug = false
)

Builds a type representing a Bucket structure for the given map type. This type is not visible to users - we include only enough information to generate a correct GC program for it. Make sure this stays in sync with runtime/map.go.

const (
    BUCKETSIZE  = 8
    MAXKEYSIZE  = 128
    MAXELEMSIZE = 128
)

convenience constants

const (
    Txxx = types.Txxx

    TINT8    = types.TINT8
    TUINT8   = types.TUINT8
    TINT16   = types.TINT16
    TUINT16  = types.TUINT16
    TINT32   = types.TINT32
    TUINT32  = types.TUINT32
    TINT64   = types.TINT64
    TUINT64  = types.TUINT64
    TINT     = types.TINT
    TUINT    = types.TUINT
    TUINTPTR = types.TUINTPTR

    TCOMPLEX64  = types.TCOMPLEX64
    TCOMPLEX128 = types.TCOMPLEX128

    TFLOAT32 = types.TFLOAT32
    TFLOAT64 = types.TFLOAT64

    TBOOL = types.TBOOL

    TPTR       = types.TPTR
    TFUNC      = types.TFUNC
    TSLICE     = types.TSLICE
    TARRAY     = types.TARRAY
    TSTRUCT    = types.TSTRUCT
    TCHAN      = types.TCHAN
    TMAP       = types.TMAP
    TINTER     = types.TINTER
    TFORW      = types.TFORW
    TANY       = types.TANY
    TSTRING    = types.TSTRING
    TUNSAFEPTR = types.TUNSAFEPTR

    // pseudo-types for literals
    TIDEAL = types.TIDEAL
    TNIL   = types.TNIL
    TBLANK = types.TBLANK

    // pseudo-types for frame layout
    TFUNCARGS = types.TFUNCARGS
    TCHANARGS = types.TCHANARGS

    NTYPE = types.NTYPE
)

architecture-independent object file output

const ArhdrSize = 60
const (
    BADWIDTH = types.BADWIDTH
)

Variables

var (
    Deferreturn,
    Duffcopy,
    Duffzero,

    Udiv *obj.LSym

    BoundsCheckFunc [ssa.BoundsKindCount]*obj.LSym
    ExtendCheckFunc [ssa.BoundsKindCount]*obj.LSym

    // GO386=387
    ControlWord64trunc,
    ControlWord32 *obj.LSym

    // Wasm
    WasmMove,
    WasmZero,
    WasmDiv,
    WasmTruncS,
    WasmTruncU,
    SigPanic *obj.LSym
)
var (
    Debug_append       int
    Debug_checkptr     int
    Debug_closure      int
    Debug_compilelater int

    Debug_libfuzzer    int
    Debug_panic        int
    Debug_slice        int
    Debug_vlog         bool
    Debug_wb           int
    Debug_pctab        string
    Debug_locationlist int
    Debug_typecheckinl int
    Debug_gendwarfinl  int
    Debug_softfloat    int
    Debug_defer        int
)
var Ctxt *obj.Link
var Debug [256]int
var Debug_checknil int
var (
    Debug_export int // if set, print debugging information about export data
)
var Debug_gcprog int // set by -d gcprog
var Debug_typeassert int

LivenessInvalid indicates an unsafe point.

We use index -2 because PCDATA tables conventionally start at -1, so -1 is used to mean the entry liveness map (which is actually at index 0; sigh). TODO(austin): Maybe we should use PCDATA+1 as the index into the liveness map so -1 uniquely refers to the entry liveness map.

var LivenessInvalid = LivenessIndex{-2, -2}
var Runtimepkg *types.Pkg // fake package runtime
var Widthptr int
var Widthreg int

func AddAux

func AddAux(a *obj.Addr, v *ssa.Value)

AddAux adds the offset in the aux fields (AuxInt and Aux) of v to a.

func AddAux2

func AddAux2(a *obj.Addr, v *ssa.Value, offset int64)

func AddrAuto

func AddrAuto(a *obj.Addr, v *ssa.Value)

func Addrconst

func Addrconst(a *obj.Addr, v int64)

func AuxOffset

func AuxOffset(v *ssa.Value) (offset int64)

func CheckLoweredGetClosurePtr

func CheckLoweredGetClosurePtr(v *ssa.Value)

CheckLoweredGetClosurePtr checks that v is the first instruction in the function's entry block. The output of LoweredGetClosurePtr is generally hardwired to the correct register. That register contains the closure pointer on closure entry.

func CheckLoweredPhi

func CheckLoweredPhi(v *ssa.Value)

CheckLoweredPhi checks that regalloc and stackalloc correctly handled phi values. Called during ssaGenValue.

func Dump

func Dump(s string, n *Node)

func Exit

func Exit(code int)

func Fatalf

func Fatalf(fmt_ string, args ...interface{})

func IncomparableField

func IncomparableField(t *types.Type) *types.Field

IncomparableField returns an incomparable Field of struct Type t, if any.

func IsAlias

func IsAlias(sym *types.Sym) bool

func IsComparable

func IsComparable(t *types.Type) bool

IsComparable reports whether t is a comparable type.

func IsRegularMemory

func IsRegularMemory(t *types.Type) bool

IsRegularMemory reports whether t can be compared/hashed as regular memory.

func Isconst

func Isconst(n *Node, ct Ctype) bool

func Main

func Main(archInit func(*Arch))

Main parses flags and Go source files specified in the command-line arguments, type-checks the parsed Go package, compiles functions to machine code, and finally writes the compiled package definition to disk.

func Patch

func Patch(p *obj.Prog, to *obj.Prog)

func Rnd

func Rnd(o int64, r int64) int64

func Warn

func Warn(fmt_ string, args ...interface{})

func Warnl

func Warnl(line src.XPos, fmt_ string, args ...interface{})

type AlgKind

AlgKind describes the kind of algorithms used for comparing and hashing a Type.

type AlgKind int
const (
    // These values are known by runtime.
    ANOEQ AlgKind = iota
    AMEM0
    AMEM8
    AMEM16
    AMEM32
    AMEM64
    AMEM128
    ASTRING
    AINTER
    ANILINTER
    AFLOAT32
    AFLOAT64
    ACPLX64
    ACPLX128

    // Type can be compared/hashed as regular memory.
    AMEM AlgKind = 100

    // Type needs special comparison/hashing functions.
    ASPECIAL AlgKind = -1
)

type Arch

type Arch struct {
    LinkArch *obj.LinkArch

    REGSP     int
    MAXWIDTH  int64
    Use387    bool // should 386 backend use 387 FP instructions instead of sse2.
    SoftFloat bool

    PadFrame func(int64) int64

    // ZeroRange zeroes a range of memory on stack. It is only inserted
    // at function entry, and it is ok to clobber registers.
    ZeroRange func(*Progs, *obj.Prog, int64, int64, *uint32) *obj.Prog

    Ginsnop      func(*Progs) *obj.Prog
    Ginsnopdefer func(*Progs) *obj.Prog // special ginsnop for deferreturn

    // SSAMarkMoves marks any MOVXconst ops that need to avoid clobbering flags.
    SSAMarkMoves func(*SSAGenState, *ssa.Block)

    // SSAGenValue emits Prog(s) for the Value.
    SSAGenValue func(*SSAGenState, *ssa.Value)

    // SSAGenBlock emits end-of-block Progs. SSAGenValue should be called
    // for all values in the block before SSAGenBlock.
    SSAGenBlock func(s *SSAGenState, b, next *ssa.Block)
}

type BlockEffects

BlockEffects summarizes the liveness effects on an SSA block.

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

type Branch

Branch is an unresolved branch.

type Branch struct {
    P *obj.Prog  // branch instruction
    B *ssa.Block // target
}

type Class

The Class of a variable/function describes the "storage class" of a variable or function. During parsing, storage classes are called declaration contexts.

type Class uint8

go:generate stringer -type=Class

const (
    Pxxx      Class = iota // no class; used during ssa conversion to indicate pseudo-variables
    PEXTERN                // global variable
    PAUTO                  // local variables
    PAUTOHEAP              // local variable or parameter moved to heap
    PPARAM                 // input arguments
    PPARAMOUT              // output results
    PFUNC                  // global function

)

func (Class) String

func (i Class) String() string

type Ctype

Ctype describes the constant kind of an "ideal" (untyped) constant.

type Ctype uint8
const (
    CTxxx Ctype = iota

    CTINT
    CTRUNE
    CTFLT
    CTCPLX
    CTSTR
    CTBOOL
    CTNIL
)

type Dlist

A Dlist stores a pointer to a TFIELD Type embedded within a TSTRUCT or TINTER Type.

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

type Error

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

type EscEdge

An EscEdge represents an assignment edge between two Go variables.

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

type EscHole

An EscHole represents a context for evaluation a Go expression. E.g., when evaluating p in "x = **p", we'd have a hole with dst==x and derefs==2.

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

type EscLeaks

An EscLeaks represents a set of assignment flows from a parameter to the heap or to any of its function's (first numEscResults) result parameters.

type EscLeaks [1 + numEscResults]uint8

func ParseLeaks

func ParseLeaks(s string) EscLeaks

ParseLeaks parses a binary string representing an EscLeaks.

func (*EscLeaks) AddHeap

func (l *EscLeaks) AddHeap(derefs int)

AddHeap adds an assignment flow from l to the heap.

func (*EscLeaks) AddResult

func (l *EscLeaks) AddResult(i, derefs int)

AddResult adds an assignment flow from l to its function's i'th result parameter.

func (EscLeaks) Empty

func (l EscLeaks) Empty() bool

Empty reports whether l is an empty set (i.e., no assignment flows).

func (EscLeaks) Encode

func (l EscLeaks) Encode() string

Encode converts l into a binary string for export data.

func (EscLeaks) Heap

func (l EscLeaks) Heap() int

Heap returns the minimum deref count of any assignment flow from l to the heap. If no such flows exist, Heap returns -1.

func (*EscLeaks) Optimize

func (l *EscLeaks) Optimize()

Optimize removes result flow paths that are equal in length or longer than the shortest heap flow path.

func (EscLeaks) Result

func (l EscLeaks) Result(i int) int

Result returns the minimum deref count of any assignment flow from l to its function's i'th result parameter. If no such flows exist, Result returns -1.

type EscLocation

An EscLocation represents an abstract location that stores a Go variable.

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

type EscNote

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

type Escape

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

type FloatingEQNEJump

type FloatingEQNEJump struct {
    Jump  obj.As
    Index int
}

type FmtFlag

A FmtFlag value is a set of flags (or 0). They control how the Xconv functions format their values. See the respective function's documentation for details.

type FmtFlag int
const (
    FmtLeft     FmtFlag = 1 << iota // '-'
    FmtSharp                        // '#'
    FmtSign                         // '+'
    FmtUnsigned                     // internal use only (historic: u flag)
    FmtShort                        // verb == 'S'       (historic: h flag)
    FmtLong                         // verb == 'L'       (historic: l flag)
    FmtComma                        // '.' (== hasPrec)  (historic: , flag)
    FmtByte                         // '0'               (historic: hh flag)
)

type Func

Func holds Node fields used only with function-like nodes.

type Func struct {
    Shortname *types.Sym
    Enter     Nodes // for example, allocate and initialize memory for escaping parameters
    Exit      Nodes
    Cvars     Nodes   // closure params
    Dcl       []*Node // autodcl for this func/closure

    // Parents records the parent scope of each scope within a
    // function. The root scope (0) has no parent, so the i'th
    // scope's parent is stored at Parents[i-1].
    Parents []ScopeID

    // Marks records scope boundary changes.
    Marks []Mark

    // Closgen tracks how many closures have been generated within
    // this function. Used by closurename for creating unique
    // function names.
    Closgen int

    FieldTrack map[*types.Sym]struct{}
    DebugInfo  *ssa.FuncDebug
    Ntype      *Node // signature
    Top        int   // top context (ctxCallee, etc)
    Closure    *Node // OCLOSURE <-> ODCLFUNC
    Nname      *Node

    Inl *Inline

    Label int32 // largest auto-generated label in this function

    Endlineno src.XPos
    WBPos     src.XPos // position of first write barrier; see SetWBPos

    Pragma syntax.Pragma // go:xxx function annotations
    // contains filtered or unexported fields
}

func (*Func) Dupok

func (f *Func) Dupok() bool

func (*Func) ExportInline

func (f *Func) ExportInline() bool

func (*Func) HasDefer

func (f *Func) HasDefer() bool

func (*Func) InlinabilityChecked

func (f *Func) InlinabilityChecked() bool

func (*Func) InstrumentBody

func (f *Func) InstrumentBody() bool

func (*Func) IsHiddenClosure

func (f *Func) IsHiddenClosure() bool

func (*Func) Needctxt

func (f *Func) Needctxt() bool

func (*Func) NilCheckDisabled

func (f *Func) NilCheckDisabled() bool

func (*Func) OpenCodedDeferDisallowed

func (f *Func) OpenCodedDeferDisallowed() bool

func (*Func) ReflectMethod

func (f *Func) ReflectMethod() bool

func (*Func) SetDupok

func (f *Func) SetDupok(b bool)

func (*Func) SetExportInline

func (f *Func) SetExportInline(b bool)

func (*Func) SetHasDefer

func (f *Func) SetHasDefer(b bool)

func (*Func) SetInlinabilityChecked

func (f *Func) SetInlinabilityChecked(b bool)

func (*Func) SetInstrumentBody

func (f *Func) SetInstrumentBody(b bool)

func (*Func) SetIsHiddenClosure

func (f *Func) SetIsHiddenClosure(b bool)

func (*Func) SetNeedctxt

func (f *Func) SetNeedctxt(b bool)

func (*Func) SetNilCheckDisabled

func (f *Func) SetNilCheckDisabled(b bool)

func (*Func) SetOpenCodedDeferDisallowed

func (f *Func) SetOpenCodedDeferDisallowed(b bool)

func (*Func) SetReflectMethod

func (f *Func) SetReflectMethod(b bool)

func (*Func) SetWrapper

func (f *Func) SetWrapper(b bool)

func (*Func) Wrapper

func (f *Func) Wrapper() bool

type GCProg

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

type InitEntry

type InitEntry struct {
    Xoffset int64 // struct, array only
    Expr    *Node // bytes of run-time computed expressions
}

type InitOrder

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

type InitPlan

type InitPlan struct {
    E []InitEntry
}

type InitSchedule

An InitSchedule is used to decompose assignment statements into static and dynamic initialization parts. Static initializations are handled by populating variables' linker symbol data, while dynamic initializations are accumulated to be executed in order.

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

type Inline

An Inline holds fields used for function bodies that can be inlined.

type Inline struct {
    Cost int32 // heuristic cost of inlining this function

    // Copies of Func.Dcl and Nbody for use during inlining.
    Dcl  []*Node
    Body []*Node
}

type Liveness

A collection of global state used by liveness analysis.

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

type LivenessIndex

LivenessIndex stores the liveness map index for a safe-point.

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

func (LivenessIndex) Valid

func (idx LivenessIndex) Valid() bool

type LivenessMap

LivenessMap maps from *ssa.Value to LivenessIndex.

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

func (LivenessMap) Get

func (m LivenessMap) Get(v *ssa.Value) LivenessIndex

type Mark

A Mark represents a scope boundary.

type Mark struct {
    // Pos is the position of the token that marks the scope
    // change.
    Pos src.XPos

    // Scope identifies the innermost scope to the right of Pos.
    Scope ScopeID
}

type Mpcplx

Mpcplx represents a complex constant.

type Mpcplx struct {
    Real Mpflt
    Imag Mpflt
}

func (*Mpcplx) Div

func (v *Mpcplx) Div(rv *Mpcplx) bool

complex divide v /= rv

(a, b) / (c, d) = ((a*c + b*d), (b*c - a*d))/(c*c + d*d)

func (*Mpcplx) GoString

func (v *Mpcplx) GoString() string

func (*Mpcplx) Mul

func (v *Mpcplx) Mul(rv *Mpcplx)

complex multiply v *= rv

(a, b) * (c, d) = (a*c - b*d, b*c + a*d)

func (*Mpcplx) String

func (v *Mpcplx) String() string

type Mpflt

Mpflt represents a floating-point constant.

type Mpflt struct {
    Val big.Float
}

func (*Mpflt) Add

func (a *Mpflt) Add(b *Mpflt)

func (*Mpflt) AddFloat64

func (a *Mpflt) AddFloat64(c float64)

func (*Mpflt) Cmp

func (a *Mpflt) Cmp(b *Mpflt) int

func (*Mpflt) CmpFloat64

func (a *Mpflt) CmpFloat64(c float64) int

func (*Mpflt) Float32

func (a *Mpflt) Float32() float64

func (*Mpflt) Float64

func (a *Mpflt) Float64() float64

func (*Mpflt) GoString

func (fvp *Mpflt) GoString() string

func (*Mpflt) Mul

func (a *Mpflt) Mul(b *Mpflt)

func (*Mpflt) MulFloat64

func (a *Mpflt) MulFloat64(c float64)

func (*Mpflt) Neg

func (a *Mpflt) Neg()

func (*Mpflt) Quo

func (a *Mpflt) Quo(b *Mpflt)

func (*Mpflt) Set

func (a *Mpflt) Set(b *Mpflt)

func (*Mpflt) SetFloat64

func (a *Mpflt) SetFloat64(c float64)

func (*Mpflt) SetInt

func (a *Mpflt) SetInt(b *Mpint)

func (*Mpflt) SetString

func (a *Mpflt) SetString(as string)

func (*Mpflt) String

func (f *Mpflt) String() string

func (*Mpflt) Sub

func (a *Mpflt) Sub(b *Mpflt)

type Mpint

Mpint represents an integer constant.

type Mpint struct {
    Val  big.Int
    Ovf  bool // set if Val overflowed compiler limit (sticky)
    Rune bool // set if syntax indicates default type rune
}

func (*Mpint) Add

func (a *Mpint) Add(b *Mpint)

func (*Mpint) And

func (a *Mpint) And(b *Mpint)

func (*Mpint) AndNot

func (a *Mpint) AndNot(b *Mpint)

func (*Mpint) Cmp

func (a *Mpint) Cmp(b *Mpint) int

func (*Mpint) CmpInt64

func (a *Mpint) CmpInt64(c int64) int

func (*Mpint) GoString

func (a *Mpint) GoString() string

func (*Mpint) Int64

func (a *Mpint) Int64() int64

func (*Mpint) Lsh

func (a *Mpint) Lsh(b *Mpint)

func (*Mpint) Mul

func (a *Mpint) Mul(b *Mpint)

func (*Mpint) Neg

func (a *Mpint) Neg()

func (*Mpint) Or

func (a *Mpint) Or(b *Mpint)

func (*Mpint) Quo

func (a *Mpint) Quo(b *Mpint)

func (*Mpint) Rem

func (a *Mpint) Rem(b *Mpint)

func (*Mpint) Rsh

func (a *Mpint) Rsh(b *Mpint)

func (*Mpint) Set

func (a *Mpint) Set(b *Mpint)

func (*Mpint) SetFloat

func (a *Mpint) SetFloat(b *Mpflt) bool

func (*Mpint) SetInt64

func (a *Mpint) SetInt64(c int64)

func (*Mpint) SetOverflow

func (a *Mpint) SetOverflow()

func (*Mpint) SetString

func (a *Mpint) SetString(as string)

func (*Mpint) String

func (a *Mpint) String() string

func (*Mpint) Sub

func (a *Mpint) Sub(b *Mpint)

func (*Mpint) Xor

func (a *Mpint) Xor(b *Mpint)

type Name

Name holds Node fields used only by named nodes (ONAME, OTYPE, OPACK, OLABEL, some OLITERAL).

type Name struct {
    Pack      *Node      // real package for import . names
    Pkg       *types.Pkg // pkg for OPACK nodes
    Defn      *Node      // initializing assignment
    Curfn     *Node      // function for local variables
    Param     *Param     // additional fields for ONAME, OTYPE
    Decldepth int32      // declaration loop depth, increased for every loop or label
    Vargen    int32      // unique name for ONAME within a function.  Function outputs are numbered starting at one.
    // contains filtered or unexported fields
}

func (*Name) Addrtaken

func (n *Name) Addrtaken() bool

func (*Name) Assigned

func (n *Name) Assigned() bool

func (*Name) AutoTemp

func (n *Name) AutoTemp() bool

func (*Name) Byval

func (n *Name) Byval() bool

func (*Name) Captured

func (n *Name) Captured() bool

func (*Name) InlFormal

func (n *Name) InlFormal() bool

func (*Name) InlLocal

func (n *Name) InlLocal() bool

func (*Name) IsClosureVar

func (n *Name) IsClosureVar() bool

func (*Name) IsOutputParamHeapAddr

func (n *Name) IsOutputParamHeapAddr() bool

func (*Name) Keepalive

func (n *Name) Keepalive() bool

func (*Name) LibfuzzerExtraCounter

func (n *Name) LibfuzzerExtraCounter() bool

func (*Name) Needzero

func (n *Name) Needzero() bool

func (*Name) OpenDeferSlot

func (n *Name) OpenDeferSlot() bool

func (*Name) Readonly

func (n *Name) Readonly() bool

func (*Name) SetAddrtaken

func (n *Name) SetAddrtaken(b bool)

func (*Name) SetAssigned

func (n *Name) SetAssigned(b bool)

func (*Name) SetAutoTemp

func (n *Name) SetAutoTemp(b bool)

func (*Name) SetByval

func (n *Name) SetByval(b bool)

func (*Name) SetCaptured

func (n *Name) SetCaptured(b bool)

func (*Name) SetInlFormal

func (n *Name) SetInlFormal(b bool)

func (*Name) SetInlLocal

func (n *Name) SetInlLocal(b bool)

func (*Name) SetIsClosureVar

func (n *Name) SetIsClosureVar(b bool)

func (*Name) SetIsOutputParamHeapAddr

func (n *Name) SetIsOutputParamHeapAddr(b bool)

func (*Name) SetKeepalive

func (n *Name) SetKeepalive(b bool)

func (*Name) SetLibfuzzerExtraCounter

func (n *Name) SetLibfuzzerExtraCounter(b bool)

func (*Name) SetNeedzero

func (n *Name) SetNeedzero(b bool)

func (*Name) SetOpenDeferSlot

func (n *Name) SetOpenDeferSlot(b bool)

func (*Name) SetReadonly

func (n *Name) SetReadonly(b bool)

func (*Name) SetUsed

func (n *Name) SetUsed(b bool)

func (*Name) Used

func (n *Name) Used() bool

type NilVal

type NilVal struct{}

type Node

A Node is a single node in the syntax tree. Actually the syntax tree is a syntax DAG, because there is only one node with Op=ONAME for a given instance of a variable x. The same is true for Op=OTYPE and Op=OLITERAL. See Node.mayBeShared.

type Node struct {
    // Tree structure.
    // Generic recursive walks should follow these fields.
    Left  *Node
    Right *Node
    Ninit Nodes
    Nbody Nodes
    List  Nodes
    Rlist Nodes

    // most nodes
    Type *types.Type
    Orig *Node // original form, for printing, and tracking copies of ONAMEs

    // func
    Func *Func

    // ONAME, OTYPE, OPACK, OLABEL, some OLITERAL
    Name *Name

    Sym *types.Sym  // various
    E   interface{} // Opt or Val, see methods below

    // Various. Usually an offset into a struct. For example:
    // - ONAME nodes that refer to local variables use it to identify their stack frame position.
    // - ODOT, ODOTPTR, and ORESULT use it to indicate offset relative to their base address.
    // - OSTRUCTKEY uses it to store the named field's offset.
    // - Named OLITERALs use it to store their ambient iota value.
    // - OINLMARK stores an index into the inlTree data structure.
    // - OCLOSURE uses it to store ambient iota value, if any.
    // Possibly still more uses. If you find any, document them.
    Xoffset int64

    Pos src.XPos

    Esc uint16 // EscXXX

    Op Op
    // contains filtered or unexported fields
}
var Curfn *Node

func AutoVar

func AutoVar(v *ssa.Value) (*Node, int64)

AutoVar returns a *Node and int64 representing the auto variable and offset within it where v should be spilled.

func (*Node) Bool

func (n *Node) Bool() bool

Bool returns n as a bool. n must be a boolean constant.

func (*Node) Bounded

func (n *Node) Bounded() bool

func (*Node) CanInt64

func (n *Node) CanInt64() bool

CanInt64 reports whether it is safe to call Int64() on n.

func (*Node) Class

func (n *Node) Class() Class

func (*Node) Colas

func (n *Node) Colas() bool

func (*Node) Diag

func (n *Node) Diag() bool

func (*Node) Embedded

func (n *Node) Embedded() bool

func (*Node) Format

func (n *Node) Format(s fmt.State, verb rune)

func (*Node) HasBreak

func (n *Node) HasBreak() bool

func (*Node) HasCall

func (n *Node) HasCall() bool

func (*Node) HasOpt

func (n *Node) HasOpt() bool

func (*Node) HasVal

func (n *Node) HasVal() bool

func (*Node) Implicit

func (n *Node) Implicit() bool

func (*Node) IndexMapLValue

func (n *Node) IndexMapLValue() bool

func (*Node) Initorder

func (n *Node) Initorder() uint8

func (*Node) Int64

func (n *Node) Int64() int64

Int64 returns n as an int64. n must be an integer or rune constant.

func (*Node) Iota

func (n *Node) Iota() int64

func (*Node) IsAutoTmp

func (n *Node) IsAutoTmp() bool

IsAutoTmp indicates if n was created by the compiler as a temporary, based on the setting of the .AutoTemp flag in n's Name.

func (*Node) IsDDD

func (n *Node) IsDDD() bool

func (*Node) IsMethod

func (n *Node) IsMethod() bool

IsMethod reports whether n is a method. n must be a function or a method.

func (*Node) IsSynthetic

func (n *Node) IsSynthetic() bool

func (*Node) Likely

func (n *Node) Likely() bool

func (*Node) Line

func (n *Node) Line() string

Line returns n's position as a string. If n has been inlined, it uses the outermost position where n has been inlined.

func (*Node) NoInline

func (n *Node) NoInline() bool

func (*Node) NonNil

func (n *Node) NonNil() bool

func (*Node) Opt

func (n *Node) Opt() interface{}

Opt returns the optimizer data for the node.

func (*Node) ResetAux

func (n *Node) ResetAux()

func (*Node) SetBounded

func (n *Node) SetBounded(b bool)

func (*Node) SetClass

func (n *Node) SetClass(b Class)

func (*Node) SetColas

func (n *Node) SetColas(b bool)

func (*Node) SetDiag

func (n *Node) SetDiag(b bool)

func (*Node) SetEmbedded

func (n *Node) SetEmbedded(b bool)

func (*Node) SetHasBreak

func (n *Node) SetHasBreak(b bool)

func (*Node) SetHasCall

func (n *Node) SetHasCall(b bool)

func (*Node) SetHasOpt

func (n *Node) SetHasOpt(b bool)

func (*Node) SetHasVal

func (n *Node) SetHasVal(b bool)

func (*Node) SetImplicit

func (n *Node) SetImplicit(b bool)

func (*Node) SetIndexMapLValue

func (n *Node) SetIndexMapLValue(b bool)

func (*Node) SetInitorder

func (n *Node) SetInitorder(b uint8)

func (*Node) SetIota

func (n *Node) SetIota(x int64)

func (*Node) SetIsDDD

func (n *Node) SetIsDDD(b bool)

func (*Node) SetLikely

func (n *Node) SetLikely(b bool)

func (*Node) SetNoInline

func (n *Node) SetNoInline(b bool)

func (*Node) SetNonNil

func (n *Node) SetNonNil(b bool)

func (*Node) SetOpt

func (n *Node) SetOpt(x interface{})

SetOpt sets the optimizer data for the node, which must not have been used with SetVal. SetOpt(nil) is ignored for Vals to simplify call sites that are clearing Opts.

func (*Node) SetSliceBounds

func (n *Node) SetSliceBounds(low, high, max *Node)

SetSliceBounds sets n's slice bounds, where n is a slice expression. n must be a slice expression. If max is non-nil, n must be a full slice expression.

func (*Node) SetSubOp

func (n *Node) SetSubOp(op Op)

func (*Node) SetTChanDir

func (n *Node) SetTChanDir(dir types.ChanDir)

func (*Node) SetTransient

func (n *Node) SetTransient(b bool)

func (*Node) SetTypecheck

func (n *Node) SetTypecheck(b uint8)

func (*Node) SetVal

func (n *Node) SetVal(v Val)

SetVal sets the Val for the node, which must not have been used with SetOpt.

func (*Node) SetWalkdef

func (n *Node) SetWalkdef(b uint8)

func (*Node) SliceBounds

func (n *Node) SliceBounds() (low, high, max *Node)

SliceBounds returns n's slice bounds: low, high, and max in expr[low:high:max]. n must be a slice expression. max is nil if n is a simple slice expression.

func (*Node) StorageClass

func (n *Node) StorageClass() ssa.StorageClass

func (*Node) String

func (n *Node) String() string

func (*Node) SubOp

func (n *Node) SubOp() Op

func (*Node) TChanDir

func (n *Node) TChanDir() types.ChanDir

func (*Node) Transient

func (n *Node) Transient() bool

func (*Node) Typ

func (n *Node) Typ() *types.Type

func (*Node) Typecheck

func (n *Node) Typecheck() uint8

func (*Node) Val

func (n *Node) Val() Val

Val returns the Val for the node.

func (*Node) Walkdef

func (n *Node) Walkdef() uint8

type NodeSet

NodeSet is a set of Nodes.

type NodeSet map[*Node]struct{}

func (*NodeSet) Add

func (s *NodeSet) Add(n *Node)

Add adds n to s.

func (NodeSet) Has

func (s NodeSet) Has(n *Node) bool

Has reports whether s contains n.

func (NodeSet) Sorted

func (s NodeSet) Sorted(less func(*Node, *Node) bool) []*Node

Sorted returns s sorted according to less.

type Nodes

Nodes is a pointer to a slice of *Node. For fields that are not used in most nodes, this is used instead of a slice to save space.

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

func (Nodes) Addr

func (n Nodes) Addr(i int) **Node

Addr returns the address of the i'th element of Nodes. It panics if n does not have at least i+1 elements.

func (*Nodes) Append

func (n *Nodes) Append(a ...*Node)

Append appends entries to Nodes.

func (*Nodes) AppendNodes

func (n *Nodes) AppendNodes(n2 *Nodes)

AppendNodes appends the contents of *n2 to n, then clears n2.

func (Nodes) First

func (n Nodes) First() *Node

First returns the first element of Nodes (same as n.Index(0)). It panics if n has no elements.

func (Nodes) Format

func (n Nodes) Format(s fmt.State, verb rune)

func (Nodes) Index

func (n Nodes) Index(i int) *Node

Index returns the i'th element of Nodes. It panics if n does not have at least i+1 elements.

func (Nodes) Len

func (n Nodes) Len() int

Len returns the number of entries in Nodes.

func (*Nodes) MoveNodes

func (n *Nodes) MoveNodes(n2 *Nodes)

MoveNodes sets n to the contents of n2, then clears n2.

func (*Nodes) Prepend

func (n *Nodes) Prepend(a ...*Node)

Prepend prepends entries to Nodes. If a slice is passed in, this will take ownership of it.

func (Nodes) Second

func (n Nodes) Second() *Node

Second returns the second element of Nodes (same as n.Index(1)). It panics if n has fewer than two elements.

func (*Nodes) Set

func (n *Nodes) Set(s []*Node)

Set sets n to a slice. This takes ownership of the slice.

func (*Nodes) Set1

func (n *Nodes) Set1(n1 *Node)

Set1 sets n to a slice containing a single node.

func (*Nodes) Set2

func (n *Nodes) Set2(n1, n2 *Node)

Set2 sets n to a slice containing two nodes.

func (*Nodes) Set3

func (n *Nodes) Set3(n1, n2, n3 *Node)

Set3 sets n to a slice containing three nodes.

func (Nodes) SetFirst

func (n Nodes) SetFirst(node *Node)

SetFirst sets the first element of Nodes to node. It panics if n does not have at least one elements.

func (Nodes) SetIndex

func (n Nodes) SetIndex(i int, node *Node)

SetIndex sets the i'th element of Nodes to node. It panics if n does not have at least i+1 elements.

func (Nodes) SetSecond

func (n Nodes) SetSecond(node *Node)

SetSecond sets the second element of Nodes to node. It panics if n does not have at least two elements.

func (Nodes) Slice

func (n Nodes) Slice() []*Node

Slice returns the entries in Nodes as a slice. Changes to the slice entries (as in s[i] = n) will be reflected in the Nodes.

func (Nodes) String

func (n Nodes) String() string

type Op

type Op uint8

Node ops.

const (
    OXXX Op = iota

    // names
    ONAME    // var or func name
    ONONAME  // unnamed arg or return value: f(int, string) (int, error) { etc }
    OTYPE    // type name
    OPACK    // import
    OLITERAL // literal

    // expressions
    OADD          // Left + Right
    OSUB          // Left - Right
    OOR           // Left | Right
    OXOR          // Left ^ Right
    OADDSTR       // +{List} (string addition, list elements are strings)
    OADDR         // &Left
    OANDAND       // Left && Right
    OAPPEND       // append(List); after walk, Left may contain elem type descriptor
    OBYTES2STR    // Type(Left) (Type is string, Left is a []byte)
    OBYTES2STRTMP // Type(Left) (Type is string, Left is a []byte, ephemeral)
    ORUNES2STR    // Type(Left) (Type is string, Left is a []rune)
    OSTR2BYTES    // Type(Left) (Type is []byte, Left is a string)
    OSTR2BYTESTMP // Type(Left) (Type is []byte, Left is a string, ephemeral)
    OSTR2RUNES    // Type(Left) (Type is []rune, Left is a string)
    OAS           // Left = Right or (if Colas=true) Left := Right
    OAS2          // List = Rlist (x, y, z = a, b, c)
    OAS2DOTTYPE   // List = Right (x, ok = I.(int))
    OAS2FUNC      // List = Right (x, y = f())
    OAS2MAPR      // List = Right (x, ok = m["foo"])
    OAS2RECV      // List = Right (x, ok = <-c)
    OASOP         // Left Etype= Right (x += y)
    OCALL         // Left(List) (function call, method call or type conversion)

    // OCALLFUNC, OCALLMETH, and OCALLINTER have the same structure.
    // Prior to walk, they are: Left(List), where List is all regular arguments.
    // If present, Right is an ODDDARG that holds the
    // generated slice used in a call to a variadic function.
    // After walk, List is a series of assignments to temporaries,
    // and Rlist is an updated set of arguments, including any ODDDARG slice.
    // TODO(josharian/khr): Use Ninit instead of List for the assignments to temporaries. See CL 114797.
    OCALLFUNC  // Left(List/Rlist) (function call f(args))
    OCALLMETH  // Left(List/Rlist) (direct method call x.Method(args))
    OCALLINTER // Left(List/Rlist) (interface method call x.Method(args))
    OCALLPART  // Left.Right (method expression x.Method, not called)
    OCAP       // cap(Left)
    OCLOSE     // close(Left)
    OCLOSURE   // func Type { Body } (func literal)
    OCOMPLIT   // Right{List} (composite literal, not yet lowered to specific form)
    OMAPLIT    // Type{List} (composite literal, Type is map)
    OSTRUCTLIT // Type{List} (composite literal, Type is struct)
    OARRAYLIT  // Type{List} (composite literal, Type is array)
    OSLICELIT  // Type{List} (composite literal, Type is slice) Right.Int64() = slice length.
    OPTRLIT    // &Left (left is composite literal)
    OCONV      // Type(Left) (type conversion)
    OCONVIFACE // Type(Left) (type conversion, to interface)
    OCONVNOP   // Type(Left) (type conversion, no effect)
    OCOPY      // copy(Left, Right)
    ODCL       // var Left (declares Left of type Left.Type)

    // Used during parsing but don't last.
    ODCLFUNC  // func f() or func (r) f()
    ODCLFIELD // struct field, interface field, or func/method argument/return value.
    ODCLCONST // const pi = 3.14
    ODCLTYPE  // type Int int or type Int = int

    ODELETE      // delete(Left, Right)
    ODOT         // Left.Sym (Left is of struct type)
    ODOTPTR      // Left.Sym (Left is of pointer to struct type)
    ODOTMETH     // Left.Sym (Left is non-interface, Right is method name)
    ODOTINTER    // Left.Sym (Left is interface, Right is method name)
    OXDOT        // Left.Sym (before rewrite to one of the preceding)
    ODOTTYPE     // Left.Right or Left.Type (.Right during parsing, .Type once resolved); after walk, .Right contains address of interface type descriptor and .Right.Right contains address of concrete type descriptor
    ODOTTYPE2    // Left.Right or Left.Type (.Right during parsing, .Type once resolved; on rhs of OAS2DOTTYPE); after walk, .Right contains address of interface type descriptor
    OEQ          // Left == Right
    ONE          // Left != Right
    OLT          // Left < Right
    OLE          // Left <= Right
    OGE          // Left >= Right
    OGT          // Left > Right
    ODEREF       // *Left
    OINDEX       // Left[Right] (index of array or slice)
    OINDEXMAP    // Left[Right] (index of map)
    OKEY         // Left:Right (key:value in struct/array/map literal)
    OSTRUCTKEY   // Sym:Left (key:value in struct literal, after type checking)
    OLEN         // len(Left)
    OMAKE        // make(List) (before type checking converts to one of the following)
    OMAKECHAN    // make(Type, Left) (type is chan)
    OMAKEMAP     // make(Type, Left) (type is map)
    OMAKESLICE   // make(Type, Left, Right) (type is slice)
    OMUL         // Left * Right
    ODIV         // Left / Right
    OMOD         // Left % Right
    OLSH         // Left << Right
    ORSH         // Left >> Right
    OAND         // Left & Right
    OANDNOT      // Left &^ Right
    ONEW         // new(Left); corresponds to calls to new in source code
    ONEWOBJ      // runtime.newobject(n.Type); introduced by walk; Left is type descriptor
    ONOT         // !Left
    OBITNOT      // ^Left
    OPLUS        // +Left
    ONEG         // -Left
    OOROR        // Left || Right
    OPANIC       // panic(Left)
    OPRINT       // print(List)
    OPRINTN      // println(List)
    OPAREN       // (Left)
    OSEND        // Left <- Right
    OSLICE       // Left[List[0] : List[1]] (Left is untypechecked or slice)
    OSLICEARR    // Left[List[0] : List[1]] (Left is array)
    OSLICESTR    // Left[List[0] : List[1]] (Left is string)
    OSLICE3      // Left[List[0] : List[1] : List[2]] (Left is untypedchecked or slice)
    OSLICE3ARR   // Left[List[0] : List[1] : List[2]] (Left is array)
    OSLICEHEADER // sliceheader{Left, List[0], List[1]} (Left is unsafe.Pointer, List[0] is length, List[1] is capacity)
    ORECOVER     // recover()
    ORECV        // <-Left
    ORUNESTR     // Type(Left) (Type is string, Left is rune)
    OSELRECV     // Left = <-Right.Left: (appears as .Left of OCASE; Right.Op == ORECV)
    OSELRECV2    // List = <-Right.Left: (appears as .Left of OCASE; count(List) == 2, Right.Op == ORECV)
    OIOTA        // iota
    OREAL        // real(Left)
    OIMAG        // imag(Left)
    OCOMPLEX     // complex(Left, Right) or complex(List[0]) where List[0] is a 2-result function call
    OALIGNOF     // unsafe.Alignof(Left)
    OOFFSETOF    // unsafe.Offsetof(Left)
    OSIZEOF      // unsafe.Sizeof(Left)

    // statements
    OBLOCK    // { List } (block of code)
    OBREAK    // break [Sym]
    OCASE     // case List: Nbody (List==nil means default)
    OCONTINUE // continue [Sym]
    ODEFER    // defer Left (Left must be call)
    OEMPTY    // no-op (empty statement)
    OFALL     // fallthrough
    OFOR      // for Ninit; Left; Right { Nbody }
    // OFORUNTIL is like OFOR, but the test (Left) is applied after the body:
    // 	Ninit
    // 	top: { Nbody }   // Execute the body at least once
    // 	cont: Right
    // 	if Left {        // And then test the loop condition
    // 		List     // Before looping to top, execute List
    // 		goto top
    // 	}
    // OFORUNTIL is created by walk. There's no way to write this in Go code.
    OFORUNTIL
    OGOTO   // goto Sym
    OIF     // if Ninit; Left { Nbody } else { Rlist }
    OLABEL  // Sym:
    OGO     // go Left (Left must be call)
    ORANGE  // for List = range Right { Nbody }
    ORETURN // return List
    OSELECT // select { List } (List is list of OCASE)
    OSWITCH // switch Ninit; Left { List } (List is a list of OCASE)
    OTYPESW // Left = Right.(type) (appears as .Left of OSWITCH)

    // types
    OTCHAN   // chan int
    OTMAP    // map[string]int
    OTSTRUCT // struct{}
    OTINTER  // interface{}
    OTFUNC   // func()
    OTARRAY  // []int, [8]int, [N]int or [...]int

    // misc
    ODDD        // func f(args ...int) or f(l...) or var a = [...]int{0, 1, 2}.
    ODDDARG     // func f(args ...int), introduced by escape analysis.
    OINLCALL    // intermediary representation of an inlined call.
    OEFACE      // itable and data words of an empty-interface value.
    OITAB       // itable word of an interface value.
    OIDATA      // data word of an interface value in Left
    OSPTR       // base pointer of a slice or string.
    OCLOSUREVAR // variable reference at beginning of closure function
    OCFUNC      // reference to c function pointer (not go func value)
    OCHECKNIL   // emit code to ensure pointer/interface not nil
    OVARDEF     // variable is about to be fully initialized
    OVARKILL    // variable is dead
    OVARLIVE    // variable is alive
    ORESULT     // result of a function call; Xoffset is stack offset
    OINLMARK    // start of an inlined body, with file/line of caller. Xoffset is an index into the inline tree.

    // arch-specific opcodes
    ORETJMP // return to other function
    OGETG   // runtime.getg() (read g pointer)

    OEND
)

func (Op) Format

func (o Op) Format(s fmt.State, verb rune)

func (Op) GoString

func (o Op) GoString() string

func (Op) IsSlice3

func (o Op) IsSlice3() bool

IsSlice3 reports whether o is a slice3 op (OSLICE3, OSLICE3ARR). o must be a slicing op.

func (Op) String

func (i Op) String() string

type Order

Order holds state during the ordering process.

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

type Param

type Param struct {
    Ntype    *Node
    Heapaddr *Node // temp holding heap address of param

    // ONAME PAUTOHEAP
    Stackcopy *Node // the PPARAM/PPARAMOUT on-stack slot (moved func params only)

    // ONAME closure linkage
    // Consider:
    //
    //	func f() {
    //		x := 1 // x1
    //		func() {
    //			use(x) // x2
    //			func() {
    //				use(x) // x3
    //				--- parser is here ---
    //			}()
    //		}()
    //	}
    //
    // There is an original declaration of x and then a chain of mentions of x
    // leading into the current function. Each time x is mentioned in a new closure,
    // we create a variable representing x for use in that specific closure,
    // since the way you get to x is different in each closure.
    //
    // Let's number the specific variables as shown in the code:
    // x1 is the original x, x2 is when mentioned in the closure,
    // and x3 is when mentioned in the closure in the closure.
    //
    // We keep these linked (assume N > 1):
    //
    //   - x1.Defn = original declaration statement for x (like most variables)
    //   - x1.Innermost = current innermost closure x (in this case x3), or nil for none
    //   - x1.IsClosureVar() = false
    //
    //   - xN.Defn = x1, N > 1
    //   - xN.IsClosureVar() = true, N > 1
    //   - x2.Outer = nil
    //   - xN.Outer = x(N-1), N > 2
    //
    //
    // When we look up x in the symbol table, we always get x1.
    // Then we can use x1.Innermost (if not nil) to get the x
    // for the innermost known closure function,
    // but the first reference in a closure will find either no x1.Innermost
    // or an x1.Innermost with .Funcdepth < Funcdepth.
    // In that case, a new xN must be created, linked in with:
    //
    //     xN.Defn = x1
    //     xN.Outer = x1.Innermost
    //     x1.Innermost = xN
    //
    // When we finish the function, we'll process its closure variables
    // and find xN and pop it off the list using:
    //
    //     x1 := xN.Defn
    //     x1.Innermost = xN.Outer
    //
    // We leave xN.Innermost set so that we can still get to the original
    // variable quickly. Not shown here, but once we're
    // done parsing a function and no longer need xN.Outer for the
    // lexical x reference links as described above, closurebody
    // recomputes xN.Outer as the semantic x reference link tree,
    // even filling in x in intermediate closures that might not
    // have mentioned it along the way to inner closures that did.
    // See closurebody for details.
    //
    // During the eventual compilation, then, for closure variables we have:
    //
    //     xN.Defn = original variable
    //     xN.Outer = variable captured in next outward scope
    //                to make closure where xN appears
    //
    // Because of the sharding of pieces of the node, x.Defn means x.Name.Defn
    // and x.Innermost/Outer means x.Name.Param.Innermost/Outer.
    Innermost *Node
    Outer     *Node

    // OTYPE
    //
    // TODO: Should Func pragmas also be stored on the Name?
    Pragma syntax.Pragma
    Alias  bool // node is alias for Ntype (only used when type-checking ODCLTYPE)
}

type Progs

Progs accumulates Progs for a function and converts them into machine code.

type Progs struct {
    Text *obj.Prog // ATEXT Prog for this function
    // contains filtered or unexported fields
}

func (*Progs) Appendpp

func (pp *Progs) Appendpp(p *obj.Prog, as obj.As, ftype obj.AddrType, freg int16, foffset int64, ttype obj.AddrType, treg int16, toffset int64) *obj.Prog

func (*Progs) Flush

func (pp *Progs) Flush()

Flush converts from pp to machine code.

func (*Progs) Free

func (pp *Progs) Free()

Free clears pp and any associated resources.

func (*Progs) NewProg

func (pp *Progs) NewProg() *obj.Prog

func (*Progs) Prog

func (pp *Progs) Prog(as obj.As) *obj.Prog

Prog adds a Prog with instruction As to pp.

type SSAGenState

SSAGenState contains state needed during Prog generation.

type SSAGenState struct {

    // Branches remembers all the branch instructions we've seen
    // and where they would like to go.
    Branches []Branch

    // 387 port: maps from SSE registers (REG_X?) to 387 registers (REG_F?)
    SSEto387 map[int16]int16
    // Some architectures require a 64-bit temporary for FP-related register shuffling. Examples include x86-387, PPC, and Sparc V8.
    ScratchFpMem *Node

    // wasm: The number of values on the WebAssembly stack. This is only used as a safeguard.
    OnWasmStackSkipped int
    // contains filtered or unexported fields
}

func (*SSAGenState) AddrScratch

func (s *SSAGenState) AddrScratch(a *obj.Addr)

func (*SSAGenState) Br

func (s *SSAGenState) Br(op obj.As, target *ssa.Block) *obj.Prog

Br emits a single branch instruction and returns the instruction. Not all architectures need the returned instruction, but otherwise the boilerplate is common to all.

func (*SSAGenState) Call

func (s *SSAGenState) Call(v *ssa.Value) *obj.Prog

Call returns a new CALL instruction for the SSA value v. It uses PrepareCall to prepare the call.

func (*SSAGenState) DebugFriendlySetPosFrom

func (s *SSAGenState) DebugFriendlySetPosFrom(v *ssa.Value)

DebugFriendlySetPosFrom adjusts Pos.IsStmt subject to heuristics that reduce "jumpy" line number churn when debugging. Spill/fill/copy instructions from the register allocator, phi functions, and instructions with a no-pos position are examples of instructions that can cause churn.

func (*SSAGenState) FPJump

func (s *SSAGenState) FPJump(b, next *ssa.Block, jumps *[2][2]FloatingEQNEJump)

func (*SSAGenState) Pc

func (s *SSAGenState) Pc() *obj.Prog

Pc returns the current Prog.

func (*SSAGenState) PrepareCall

func (s *SSAGenState) PrepareCall(v *ssa.Value)

PrepareCall prepares to emit a CALL instruction for v and does call-related bookkeeping. It must be called immediately before emitting the actual CALL instruction, since it emits PCDATA for the stack map at the call (calls are safe points).

func (*SSAGenState) Prog

func (s *SSAGenState) Prog(as obj.As) *obj.Prog

Prog appends a new Prog.

func (*SSAGenState) SetPos

func (s *SSAGenState) SetPos(pos src.XPos)

SetPos sets the current source position.

func (*SSAGenState) UseArgs

func (s *SSAGenState) UseArgs(n int64)

UseArgs records the fact that an instruction needs a certain amount of callee args space for its use.

type ScopeID

A ScopeID represents a lexical scope within a function.

type ScopeID int32

type Sig

type Sig struct {
    // contains filtered or unexported fields
}
type Symlink struct {
    // contains filtered or unexported fields
}

type Timings

Timings collects the execution times of labeled phases which are added trough a sequence of Start/Stop calls. Events may be associated with each phase via AddEvent.

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

func (*Timings) AddEvent

func (t *Timings) AddEvent(size int64, unit string)

AddEvent associates an event, i.e., a count, or an amount of data, with the most recently started or stopped phase; or the very first phase if Start or Stop hasn't been called yet. The unit specifies the unit of measurement (e.g., MB, lines, no. of funcs, etc.).

func (*Timings) Start

func (t *Timings) Start(labels ...string)

Start marks the beginning of a new phase and implicitly stops the previous phase. The phase name is the colon-separated concatenation of the labels.

func (*Timings) Stop

func (t *Timings) Stop(labels ...string)

Stop marks the end of a phase and implicitly starts a new phase. The labels are added to the labels of the ended phase.

func (*Timings) Write

func (t *Timings) Write(w io.Writer, prefix string)

Write prints the phase times to w. The prefix is printed at the start of each line.

type Val

type Val struct {
    // U contains one of:
    // bool     bool when Ctype() == CTBOOL
    // *Mpint   int when Ctype() == CTINT, rune when Ctype() == CTRUNE
    // *Mpflt   float when Ctype() == CTFLT
    // *Mpcplx  pair of floats when Ctype() == CTCPLX
    // string   string when Ctype() == CTSTR
    // *Nilval  when Ctype() == CTNIL
    U interface{}
}

func (Val) Ctype

func (v Val) Ctype() Ctype

func (Val) Format

func (v Val) Format(s fmt.State, verb rune)

func (Val) Interface

func (v Val) Interface() interface{}

Interface returns the constant value stored in v as an interface{}. It returns int64s for ints and runes, float64s for floats, complex128s for complex values, and nil for constant nils.

Subdirectories

Name Synopsis
..