gc

package
v0.0.0-...-43897cc Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2017 License: BSD-3-Clause Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WORDBITS  = 32
	WORDMASK  = WORDBITS - 1
	WORDSHIFT = 5
)
View Source
const (
	EscFuncUnknown = 0 + iota
	EscFuncPlanned
	EscFuncStarted
	EscFuncTagged
)
View Source
const (
	EscUnknown        = iota
	EscNone           // Does not escape to heap, result, or parameters.
	EscReturn         // Is returned or reachable from returned.
	EscHeap           // Reachable from the heap
	EscNever          // By construction will not escape.
	EscBits           = 3
	EscMask           = (1 << EscBits) - 1
	EscContentEscapes = 1 << EscBits // value obtained by indirect of parameter escapes to heap
	EscReturnBits     = EscBits + 1
)

Escape constants are numbered in order of increasing "escapiness" to help make inferences be monotonic. With the exception of EscNever which is sticky, eX < eY means that eY is more exposed than eX, and hence replaces it in a conservative analysis.

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

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

View Source
const (
	BADWIDTH        = -1000000000
	MaxStackVarSize = 10 * 1024 * 1024
)
View Source
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
	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
)
View Source
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
)
View Source
const (
	H0 = 2166136261
	Hp = 16777619
)

FNV-1 hash function constants.

View Source
const (
	BUCKETSIZE = 8
	MAXKEYSIZE = 128
	MAXVALSIZE = 128
)

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/hashmap.go!

View Source
const (
	InitNotStarted = 0
	InitDone       = 1
	InitPending    = 2
)

static initialization

View Source
const (
	OXXX = Op(iota)

	// names
	ONAME    // var, const 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)
	OARRAYBYTESTR    // Type(Left) (Type is string, Left is a []byte)
	OARRAYBYTESTRTMP // Type(Left) (Type is string, Left is a []byte, ephemeral)
	OARRAYRUNESTR    // Type(Left) (Type is string, Left is a []rune)
	OSTRARRAYBYTE    // Type(Left) (Type is []byte, Left is a string)
	OSTRARRAYBYTETMP // Type(Left) (Type is []byte, Left is a string, ephemeral)
	OSTRARRAYRUNE    // 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)
	OAS2FUNC         // List = Rlist (x, y = f())
	OAS2RECV         // List = Rlist (x, ok = <-c)
	OAS2MAPR         // List = Rlist (x, ok = m["foo"])
	OAS2DOTTYPE      // List = Rlist (x, ok = I.(int))
	OASOP            // Left Etype= Right (x += y)
	OCALL            // Left(List) (function call, method call or type conversion)
	OCALLFUNC        // Left(List) (function call f(args))
	OCALLMETH        // Left(List) (direct method call x.Method(args))
	OCALLINTER       // Left(List) (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)
	OCMPIFACE        // Left Etype Right (interface comparison, x == y or x != y)
	OCMPSTR          // Left Etype Right (string comparison, x == y, x < y, etc)
	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)
	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)
	ODOTTYPE2  // Left.Right or Left.Type (.Right during parsing, .Type once resolved; on rhs of OAS2DOTTYPE)
	OEQ        // Left == Right
	ONE        // Left != Right
	OLT        // Left < Right
	OLE        // Left <= Right
	OGE        // Left >= Right
	OGT        // Left > Right
	OIND       // *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)
	ONOT       // !Left
	OCOM       // ^Left
	OPLUS      // +Left
	OMINUS     // -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)
	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: (apperas as .Left of OCASE; count(List) == 2, Right.Op == ORECV)
	OIOTA      // iota
	OREAL      // real(Left)
	OIMAG      // imag(Left)
	OCOMPLEX   // complex(Left, Right)
	OALIGNOF   // unsafe.Alignof(Left)
	OOFFSETOF  // unsafe.Offsetof(Left)
	OSIZEOF    // unsafe.Sizeof(Left)

	// statements
	OBLOCK    // { List } (block of code)
	OBREAK    // break
	OCASE     // case Left or List[0]..List[1]: Nbody (select case after processing; Left==nil and List==nil means default)
	OXCASE    // case List: Nbody (select case before processing; List==nil means default)
	OCONTINUE // continue
	ODEFER    // defer Left (Left must be call)
	OEMPTY    // no-op (empty statement)
	OFALL     // fallthrough (after processing)
	OXFALL    // fallthrough (before processing)
	OFOR      // for Ninit; Left; Right { Nbody }
	OFORUNTIL // for Ninit; Left; Right { Nbody } ; test applied after executing body, not before
	OGOTO     // goto Left
	OIF       // if Ninit; Left { Nbody } else { Rlist }
	OLABEL    // Left:
	OPROC     // go Left (Left must be call)
	ORANGE    // for List = range Right { Nbody }
	ORETURN   // return List
	OSELECT   // select { List } (List is list of OXCASE or OCASE)
	OSWITCH   // switch Ninit; Left { List } (List is a list of OXCASE or OCASE)
	OTYPESW   // List = Left.(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
	OVARKILL    // variable is dead
	OVARLIVE    // variable is alive
	OINDREGSP   // offset plus indirect of REGSP, such as 8(SP).

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

	OEND
)

Node ops.

View Source
const (
	Txxx = iota

	TINT8
	TUINT8
	TINT16
	TUINT16
	TINT32
	TUINT32
	TINT64
	TUINT64
	TINT
	TUINT
	TUINTPTR

	TCOMPLEX64
	TCOMPLEX128

	TFLOAT32
	TFLOAT64

	TBOOL

	TPTR32
	TPTR64

	TFUNC
	TSLICE
	TARRAY
	TSTRUCT
	TCHAN
	TMAP
	TINTER
	TFORW
	TANY
	TSTRING
	TUNSAFEPTR

	// pseudo-types for literals
	TIDEAL
	TNIL
	TBLANK

	// pseudo-types for frame layout
	TFUNCARGS
	TCHANARGS

	// pseudo-types for import/export
	TDDDFIELD // wrapper: contained type is a ... field

	NTYPE
)
View Source
const (
	Etop      = 1 << iota // evaluated at statement level
	Erv                   // evaluated in value context
	Etype                 // evaluated in type context
	Ecall                 // call-only expressions are ok
	Efnstruct             // multivalue function returns are ok
	Easgn                 // assigning to expression
	Ecomplit              // type in composite literal
)
View Source
const (
	ArhdrSize = 60
)

architecture-independent object file output

View Source
const (
	MinLevel = -2
)

There appear to be some loops in the escape graph, causing arbitrary recursion into deeper and deeper levels. Cut this off safely by making minLevel sticky: once you get that deep, you cannot go down any further but you also cannot go up any further. This is a conservative fix. Making minLevel smaller (more negative) would handle more complex chains of indirections followed by address-of operations, at the cost of repeating the traversal once for each additional allowed level when a loop is encountered. Using -2 suffices to pass all the tests we have written so far, which we assume matches the level of complexity we want the escape analysis code to handle.

View Source
const NOTALOOPDEPTH = -1

Variables

View Source
var (
	Debug_append  int
	Debug_asm     bool
	Debug_closure int

	Debug_panic int
	Debug_slice int
	Debug_vlog  bool
	Debug_wb    int
	Debug_pctab string
)
View Source
var Ctxt *obj.Link
View Source
var Debug [256]int
View Source
var Debug_checknil int
View Source
var (
	Debug_export int // if set, print debugging information about export data
)
View Source
var Debug_gcprog int // set by -d gcprog
View Source
var Debug_typeassert int
View Source
var Nacl bool
View Source
var (
	Newproc,
	Deferproc,
	Deferreturn,
	Duffcopy,
	Duffzero *obj.LSym
)
View Source
var Types [NTYPE]*Type

Types stores pointers to predeclared named types.

It also stores pointers to several special types:

  • Types[TANY] is the placeholder "any" type recognized by substArgTypes.
  • Types[TBLANK] represents the blank variable's type.
  • Types[TIDEAL] represents untyped numeric constants.
  • Types[TNIL] represents the predeclared "nil" value's type.
  • Types[TUNSAFEPTR] is package unsafe's Pointer type.
View Source
var Widthint int
View Source
var Widthptr int
View Source
var Widthreg int

Functions

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 Appendpp

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

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 Clearp

func Clearp(p *obj.Prog)

func Dump

func Dump(s string, n *Node)

func Exit

func Exit(code int)

func Fatalf

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

func Import

func Import(in *bufio.Reader)

Import populates importpkg from the serialized package data.

func Isconst

func Isconst(n *Node, ct Ctype) bool

func Linksym

func Linksym(s *Sym) *obj.LSym

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 Prog

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

func Rnd

func Rnd(o int64, r int64) int64

func Sysfunc

func Sysfunc(name string) *obj.LSym

func Warn

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

func Warnl

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

Types

type AlgKind

type AlgKind int

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

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.

	Defframe func(*obj.Prog, *Node, int64)
	Ginsnop  func()

	// 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 ArrayType

type ArrayType struct {
	Elem        *Type // element type
	Bound       int64 // number of elements; <0 if unknown yet
	Haspointers uint8 // 0 unknown, 1 no, 2 yes
}

ArrayType contains Type fields specific to array types.

type BlockEffects

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

BlockEffects summarizes the liveness effects on an SSA block.

type Branch

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

Branch is an unresolved branch.

type ChanArgsType

type ChanArgsType struct {
	T *Type // reference to a chan type whose elements need a width check
}

ChanArgsType contains Type fields specific to TCHANARGS types.

type ChanDir

type ChanDir uint8

ChanDir is whether a channel can send, receive, or both.

const (
	// types of channel
	// must match ../../../../reflect/type.go:/ChanDir
	Crecv ChanDir = 1 << 0
	Csend ChanDir = 1 << 1
	Cboth ChanDir = Crecv | Csend
)

func (ChanDir) CanRecv

func (c ChanDir) CanRecv() bool

func (ChanDir) CanSend

func (c ChanDir) CanSend() bool

type ChanType

type ChanType struct {
	Elem *Type   // element type
	Dir  ChanDir // channel direction
}

ChanType contains Type fields specific to channel types.

type Class

type Class uint8

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

const (
	Pxxx      Class = iota
	PEXTERN         // global variable
	PAUTO           // local variables
	PAUTOHEAP       // local variable or parameter moved to heap
	PPARAM          // input arguments
	PPARAMOUT       // output results
	PFUNC           // global function

	PDISCARD // discard during parse of duplicate import
)

type Ctype

type Ctype int8

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

const (
	CTxxx Ctype = iota

	CTINT
	CTRUNE
	CTFLT
	CTCPLX
	CTSTR
	CTBOOL
	CTNIL
)

type DDDFieldType

type DDDFieldType struct {
	T *Type // reference to a slice type for ... args
}

DDDFieldType contains Type fields specific to TDDDFIELD types.

type Dlist

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

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

type EType

type EType uint8

EType describes a kind of type.

var Tptr EType // either TPTR32 or TPTR64

func (EType) String

func (et EType) String() string

type Error

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

type EscState

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

type EscStep

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

An EscStep documents one step in the path from memory that is heap allocated to the (alleged) reason for the heap allocation.

type Field

type Field struct {
	Embedded uint8 // embedded field
	Funarg   Funarg

	Sym   *Sym
	Nname *Node

	Type *Type // field type

	// Offset in bytes of this field or method within its enclosing struct
	// or interface Type.
	Offset int64

	Note string // literal string annotation
	// contains filtered or unexported fields
}

A Field represents a field in a struct or a method in an interface or associated with a named type.

func (*Field) Broke

func (f *Field) Broke() bool

func (*Field) Copy

func (f *Field) Copy() *Field

func (*Field) End

func (f *Field) End() int64

End returns the offset of the first byte immediately after this field.

func (*Field) Isddd

func (f *Field) Isddd() bool

func (*Field) Nointerface

func (f *Field) Nointerface() bool

func (*Field) SetBroke

func (f *Field) SetBroke(b bool)

func (*Field) SetIsddd

func (f *Field) SetIsddd(b bool)

func (*Field) SetNointerface

func (f *Field) SetNointerface(b bool)

type Fields

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

Fields is a pointer to a slice of *Field. This saves space in Types that do not have fields or methods compared to a simple slice of *Field.

func (*Fields) Append

func (f *Fields) Append(s ...*Field)

Append appends entries to f.

func (*Fields) Index

func (f *Fields) Index(i int) *Field

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

func (*Fields) Iter

func (fs *Fields) Iter() (*Field, Iter)

Iter returns the first field in fs and an Iter value to continue iterating across its successor fields. Deprecated: New code should use Slice instead.

func (*Fields) Len

func (f *Fields) Len() int

Len returns the number of entries in f.

func (*Fields) Set

func (f *Fields) Set(s []*Field)

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

func (*Fields) Slice

func (f *Fields) Slice() []*Field

Slice returns the entries in f as a slice. Changes to the slice entries will be reflected in f.

type FloatingEQNEJump

type FloatingEQNEJump struct {
	Jump  obj.As
	Index int
}

type FmtFlag

type FmtFlag int

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.

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 ForwardType

type ForwardType struct {
	Copyto      []*Node  // where to copy the eventual value to
	Embedlineno src.XPos // first use of this type as an embedded type
}

ForwardType contains Type fields specific to forward types.

type Funarg

type Funarg uint8

Fnstruct records the kind of function argument

const (
	FunargNone    Funarg = iota
	FunargRcvr           // receiver
	FunargParams         // input parameters
	FunargResults        // output results
)

type Func

type Func struct {
	Shortname  *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
	Inldcl     Nodes   // copy of dcl for use in inlining
	Closgen    int
	Outerfunc  *Node // outer function (for closure)
	FieldTrack map[*Sym]struct{}
	Ntype      *Node // signature
	Top        int   // top context (Ecall, Eproc, etc)
	Closure    *Node // OCLOSURE <-> ODCLFUNC
	Nname      *Node

	Inl     Nodes // copy of the body for use in inlining
	InlCost int32
	Depth   int32

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

	Endlineno src.XPos
	WBPos     src.XPos // position of first write barrier

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

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

func (*Func) Dupok

func (f *Func) Dupok() bool

func (*Func) HasDefer

func (f *Func) HasDefer() bool

func (*Func) IsHiddenClosure

func (f *Func) IsHiddenClosure() bool

func (*Func) Needctxt

func (f *Func) Needctxt() bool

func (*Func) NoFramePointer

func (f *Func) NoFramePointer() bool

func (*Func) ReflectMethod

func (f *Func) ReflectMethod() bool

func (*Func) SetDupok

func (f *Func) SetDupok(b bool)

func (*Func) SetHasDefer

func (f *Func) SetHasDefer(b bool)

func (*Func) SetIsHiddenClosure

func (f *Func) SetIsHiddenClosure(b bool)

func (*Func) SetNeedctxt

func (f *Func) SetNeedctxt(b bool)

func (*Func) SetNoFramePointer

func (f *Func) SetNoFramePointer(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 FuncArgsType

type FuncArgsType struct {
	T *Type // reference to a func type whose elements need a width check
}

// FuncArgsType contains Type fields specific to TFUNCARGS types.

type FuncType

type FuncType struct {
	Receiver *Type // function receiver
	Results  *Type // function results
	Params   *Type // function params

	Nname *Node

	// Argwid is the total width of the function receiver, params, and results.
	// It gets calculated via a temporary TFUNCARGS type.
	// Note that TFUNC's Width is Widthptr.
	Argwid int64

	Outnamed bool
}

FuncType contains Type fields specific to func types.

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 InitPlan

type InitPlan struct {
	E []InitEntry
}

type InterMethType

type InterMethType struct {
	Nname *Node
}

InterMethType contains Type fields specific to interface method pseudo-types.

type InterType

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

InterType contains Type fields specific to interface types.

type Iter

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

Iter provides an abstraction for iterating across struct fields and interface methods.

func (*Iter) Next

func (i *Iter) Next() *Field

Next returns the next field or method, if any.

type Level

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

A Level encodes the reference state and context applied to (stack, heap) allocated memory.

value is the overall sum of *(1) and &(-1) operations encountered along a path from a destination (sink, return value) to a source (allocation, parameter).

suffixValue is the maximum-copy-started-suffix-level applied to a sink. For example: sink = x.left.left --> level=2, x is dereferenced twice and does not escape to sink. sink = &Node{x} --> level=-1, x is accessible from sink via one "address of" sink = &Node{&Node{x}} --> level=-2, x is accessible from sink via two "address of" sink = &Node{&Node{x.left}} --> level=-1, but x is NOT accessible from sink because it was indirected and then copied. (The copy operations are sometimes implicit in the source code; in this case, value of x.left was copied into a field of a newly allocated Node)

There's one of these for each Node, and the integer values rarely exceed even what can be stored in 4 bits, never mind 8.

type Liveness

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

A collection of global state used by liveness analysis.

type MapType

type MapType struct {
	Key *Type // Key type
	Val *Type // Val (elem) type

	Bucket *Type // internal struct type representing a hash bucket
	Hmap   *Type // internal struct type representing the Hmap (map header object)
	Hiter  *Type // internal struct type representing hash iterator state
}

MapType contains Type fields specific to maps.

type Mpcplx

type Mpcplx struct {
	Real Mpflt
	Imag Mpflt
}

Mpcplx represents a complex constant.

type Mpflt

type Mpflt struct {
	Val big.Float
}

Mpflt represents a floating-point constant.

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) 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)

floating point input required syntax is [+-]d*[.]d*[e[+-]d*] or [+-]0xH*[e[+-]d*]

func (*Mpflt) String

func (f *Mpflt) String() string

func (*Mpflt) Sub

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

type Mpint

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

Mpint represents an integer constant.

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) 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 (x *Mpint) String() string

func (*Mpint) Sub

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

func (*Mpint) Xor

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

type Name

type Name struct {
	Pack      *Node  // real package for import . names
	Pkg       *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.
	Funcdepth int32
	// contains filtered or unexported fields
}

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

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) Keepalive

func (n *Name) Keepalive() bool

func (*Name) Needzero

func (n *Name) Needzero() bool

func (*Name) Readonly

func (n *Name) Readonly() 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) SetKeepalive

func (n *Name) SetKeepalive(b bool)

func (*Name) SetNeedzero

func (n *Name) SetNeedzero(b bool)

func (*Name) SetReadonly

func (n *Name) SetReadonly(b bool)

type NilVal

type NilVal struct{}

type Node

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 *Type
	Orig *Node // original form, for printing, and tracking copies of ONAMEs

	// func
	Func *Func

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

	Sym *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 OINDREGSP use it to indicate offset relative to their base address.
	// - OSTRUCTKEY uses it to store the named field's offset.
	// - OXCASE and OXFALL use it to validate the use of fallthrough.
	// - Named OLITERALs use it to to store their ambient iota value.
	// Possibly still more uses. If you find any, document them.
	Xoffset int64

	Pos src.XPos

	Esc uint16 // EscXXX

	Op        Op
	Etype     EType // op for OASOP, etype for OTYPE, exclam for export, 6g saved reg, ChanDir for OTCHAN, for OINDEXMAP 1=LHS,0=RHS
	Class     Class // PPARAM, PAUTO, PEXTERN, etc
	Embedded  uint8 // ODCLFIELD embedded type
	Walkdef   uint8 // tracks state during typecheckdef; 2 == loop detected
	Typecheck uint8 // tracks state during typechecking; 2 == loop detected
	Initorder uint8
	Likely    int8 // likeliness of if statement
	// contains filtered or unexported fields
}

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.

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) Addable

func (n *Node) Addable() bool

func (*Node) Addrtaken

func (n *Node) Addrtaken() bool

func (*Node) Assigned

func (n *Node) Assigned() bool

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) Colas

func (n *Node) Colas() bool

func (*Node) Diag

func (n *Node) Diag() 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) Implicit

func (n *Node) Implicit() bool

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) IsClosureVar

func (n *Node) IsClosureVar() 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) IsOutputParamHeapAddr

func (n *Node) IsOutputParamHeapAddr() bool

func (*Node) Isddd

func (n *Node) Isddd() 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) Local

func (n *Node) Local() bool

func (*Node) NoInline

func (n *Node) NoInline() bool

func (*Node) Noescape

func (n *Node) Noescape() 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) SetAddable

func (n *Node) SetAddable(b bool)

func (*Node) SetAddrtaken

func (n *Node) SetAddrtaken(b bool)

func (*Node) SetAssigned

func (n *Node) SetAssigned(b bool)

func (*Node) SetBounded

func (n *Node) SetBounded(b bool)

func (*Node) SetColas

func (n *Node) SetColas(b bool)

func (*Node) SetDiag

func (n *Node) SetDiag(b bool)

func (*Node) SetHasBreak

func (n *Node) SetHasBreak(b bool)

func (*Node) SetHasCall

func (n *Node) SetHasCall(b bool)

func (*Node) SetImplicit

func (n *Node) SetImplicit(b bool)

func (*Node) SetIota

func (n *Node) SetIota(x int64)

func (*Node) SetIsClosureVar

func (n *Node) SetIsClosureVar(b bool)

func (*Node) SetIsOutputParamHeapAddr

func (n *Node) SetIsOutputParamHeapAddr(b bool)

func (*Node) SetIsddd

func (n *Node) SetIsddd(b bool)

func (*Node) SetLocal

func (n *Node) SetLocal(b bool)

func (*Node) SetNoInline

func (n *Node) SetNoInline(b bool)

func (*Node) SetNoescape

func (n *Node) SetNoescape(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) SetUsed

func (n *Node) SetUsed(b bool)

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) 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) String

func (n *Node) String() string

func (*Node) Typ

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

func (*Node) Used

func (n *Node) Used() bool

func (*Node) Val

func (n *Node) Val() Val

Val returns the Val for the node.

type NodeEscState

type NodeEscState struct {
	Curfn             *Node
	Flowsrc           []EscStep // flow(this, src)
	Retval            Nodes     // on OCALLxxx, list of dummy return values
	Loopdepth         int32     // -1: global, 0: return variables, 1:function top level, increased inside function for every loop or label to mark scopes
	Level             Level
	Walkgen           uint32
	Maxextraloopdepth int32
}

type Nodes

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

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.

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

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 (o Op) String() string

type Order

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

Order holds state during the ordering process.

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 PPARAM
	Field *Field // TFIELD in arg struct

	// 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 Pkg

type Pkg struct {
	Name     string // package name, e.g. "sys"
	Path     string // string literal used in import statement, e.g. "runtime/internal/sys"
	Pathsym  *obj.LSym
	Prefix   string // escaped path for use in symbol table
	Imported bool   // export data of this package was parsed
	Direct   bool   // imported directly
	Syms     map[string]*Sym
}
var Runtimepkg *Pkg // fake package runtime

func (*Pkg) Lookup

func (pkg *Pkg) Lookup(name string) *Sym

func (*Pkg) LookupBytes

func (pkg *Pkg) LookupBytes(name []byte) *Sym

type PtrType

type PtrType struct {
	Elem *Type // element type
}

PtrType contains Type fields specific to pointer types.

type SSAGenState

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
	// contains filtered or unexported fields
}

SSAGenState contains state needed during Prog generation.

func (*SSAGenState) AddrScratch

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

func (*SSAGenState) Call

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

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) 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.

type Sig

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

type SliceType

type SliceType struct {
	Elem *Type // element type
}

SliceType contains Type fields specific to slice types.

type StructType

type StructType struct {

	// Maps have three associated internal structs (see struct MapType).
	// Map links such structs back to their map type.
	Map *Type

	Funarg      Funarg // type of function arguments for arg struct
	Haspointers uint8  // 0 unknown, 1 no, 2 yes
	// contains filtered or unexported fields
}

StructType contains Type fields specific to struct types.

type Sym

type Sym struct {
	Link      *Sym
	Importdef *Pkg   // where imported definition was found
	Linkname  string // link name

	// saved and restored by dcopy
	Pkg        *Pkg
	Name       string   // object name
	Def        *Node    // definition: ONAME OTYPE OPACK or OLITERAL
	Lastlineno src.XPos // last declaration for diagnostic
	Block      int32    // blocknumber to catch redeclaration

	Label   *Node // corresponding label (ephemeral)
	Origpkg *Pkg  // original package for . import
	Lsym    *obj.LSym
	Fsym    *Sym // funcsym
	// contains filtered or unexported fields
}

Sym represents an object name. Most commonly, this is a Go identifier naming an object declared within a package, but Syms are also used to name internal synthesized objects.

As an exception, field and method names that are exported use the Sym associated with localpkg instead of the package that declared them. This allows using Sym pointer equality to test for Go identifier uniqueness when handling selector expressions.

func Pkglookup

func Pkglookup(name string, pkg *Pkg) *Sym

func (*Sym) AlgGen

func (sym *Sym) AlgGen() bool

func (*Sym) Asm

func (sym *Sym) Asm() bool

func (*Sym) Export

func (sym *Sym) Export() bool

func (*Sym) Exported

func (sym *Sym) Exported() bool

func (*Sym) Format

func (y *Sym) Format(s fmt.State, verb rune)

func (*Sym) Package

func (sym *Sym) Package() bool

func (*Sym) SetAlgGen

func (sym *Sym) SetAlgGen(b bool)

func (*Sym) SetAsm

func (sym *Sym) SetAsm(b bool)

func (*Sym) SetExport

func (sym *Sym) SetExport(b bool)

func (*Sym) SetExported

func (sym *Sym) SetExported(b bool)

func (*Sym) SetPackage

func (sym *Sym) SetPackage(b bool)

func (*Sym) SetSiggen

func (sym *Sym) SetSiggen(b bool)

func (*Sym) SetUniq

func (sym *Sym) SetUniq(b bool)

func (*Sym) Siggen

func (sym *Sym) Siggen() bool

func (*Sym) String

func (s *Sym) String() string

func (*Sym) Uniq

func (sym *Sym) Uniq() bool
type Symlink struct {
	// contains filtered or unexported fields
}

code to help generate trampoline functions for methods on embedded subtypes. these are approx the same as the corresponding adddot routines except that they expect to be called with unique tasks and they return the actual methods.

type Timings

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

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.

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 Type

type Type struct {
	// Extra contains extra etype-specific fields.
	// As an optimization, those etype-specific structs which contain exactly
	// one pointer-shaped field are stored as values rather than pointers when possible.
	//
	// TMAP: *MapType
	// TFORW: *ForwardType
	// TFUNC: *FuncType
	// TINTERMETHOD: InterMethType
	// TSTRUCT: *StructType
	// TINTER: *InterType
	// TDDDFIELD: DDDFieldType
	// TFUNCARGS: FuncArgsType
	// TCHANARGS: ChanArgsType
	// TCHAN: *ChanType
	// TPTR32, TPTR64: PtrType
	// TARRAY: *ArrayType
	// TSLICE: SliceType
	Extra interface{}

	// Width is the width of this Type in bytes.
	Width int64

	Orig *Type // original type (type literal or predefined type)

	Sym    *Sym  // symbol containing name, for named types
	Vargen int32 // unique name for OTYPE/ONAME

	Etype  EType // kind of type
	Trecur uint8 // to detect loops
	Align  uint8 // the required alignment of this type, in bytes
	// contains filtered or unexported fields
}

A Type represents a Go type.

func (*Type) Alignment

func (t *Type) Alignment() int64

func (*Type) AllMethods

func (t *Type) AllMethods() *Fields

func (*Type) ArgWidth

func (t *Type) ArgWidth() int64

ArgWidth returns the total aligned argument size for a function. It includes the receiver, parameters, and results.

func (*Type) Broke

func (t *Type) Broke() bool

func (*Type) ChanArgs

func (t *Type) ChanArgs() *Type

ChanArgs returns the channel type for TCHANARGS type t.

func (*Type) ChanDir

func (t *Type) ChanDir() ChanDir

ChanDir returns the direction of a channel type t. The direction will be one of Crecv, Csend, or Cboth.

func (*Type) ChanType

func (t *Type) ChanType() *ChanType

ChanType returns t's extra channel-specific fields.

func (*Type) Compare

func (t *Type) Compare(u ssa.Type) ssa.Cmp

Compare compares types for purposes of the SSA back end, returning an ssa.Cmp (one of CMPlt, CMPeq, CMPgt). The answers are correct for an optimizer or code generator, but not necessarily typechecking. The order chosen is arbitrary, only consistency and division into equivalence classes (Types that compare CMPeq) matters.

func (*Type) Copy

func (t *Type) Copy() *Type

Copy returns a shallow copy of the Type.

func (*Type) DDDField

func (t *Type) DDDField() *Type

DDDField returns the slice ... type for TDDDFIELD type t.

func (*Type) Deferwidth

func (t *Type) Deferwidth() bool

func (*Type) Elem

func (t *Type) Elem() *Type

Elem returns the type of elements of t. Usable with pointers, channels, arrays, and slices.

func (*Type) ElemType

func (t *Type) ElemType() ssa.Type

func (*Type) Field

func (t *Type) Field(i int) *Field

Field returns the i'th field/method of struct/interface type t.

func (*Type) FieldName

func (t *Type) FieldName(i int) string

func (*Type) FieldOff

func (t *Type) FieldOff(i int) int64

func (*Type) FieldSlice

func (t *Type) FieldSlice() []*Field

FieldSlice returns a slice of containing all fields/methods of struct/interface type t.

func (*Type) FieldType

func (t *Type) FieldType(i int) ssa.Type

func (*Type) Fields

func (t *Type) Fields() *Fields

func (*Type) Format

func (t *Type) Format(s fmt.State, verb rune)

func (*Type) ForwardType

func (t *Type) ForwardType() *ForwardType

ForwardType returns t's extra forward-type-specific fields.

func (*Type) FuncArgs

func (t *Type) FuncArgs() *Type

FuncArgs returns the channel type for TFUNCARGS type t.

func (*Type) FuncType

func (t *Type) FuncType() *FuncType

FuncType returns t's extra func-specific fields.

func (*Type) HasPointer

func (t *Type) HasPointer() bool

HasPointer returns whether t contains heap pointer. This is used for write barrier insertion, so we ignore pointers to go:notinheap types.

func (*Type) IncomparableField

func (t *Type) IncomparableField() *Field

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

func (*Type) IsArray

func (t *Type) IsArray() bool

func (*Type) IsBoolean

func (t *Type) IsBoolean() bool

func (*Type) IsChan

func (t *Type) IsChan() bool

func (*Type) IsComparable

func (t *Type) IsComparable() bool

IsComparable reports whether t is a comparable type.

func (*Type) IsComplex

func (t *Type) IsComplex() bool

func (*Type) IsEmptyInterface

func (t *Type) IsEmptyInterface() bool

IsEmptyInterface reports whether t is an empty interface type.

func (*Type) IsFlags

func (t *Type) IsFlags() bool

func (*Type) IsFloat

func (t *Type) IsFloat() bool

func (*Type) IsFuncArgStruct

func (t *Type) IsFuncArgStruct() bool

IsFuncArgStruct reports whether t is a struct representing function parameters.

func (*Type) IsInteger

func (t *Type) IsInteger() bool

func (*Type) IsInterface

func (t *Type) IsInterface() bool

func (*Type) IsKind

func (t *Type) IsKind(et EType) bool

IsKind reports whether t is a Type of the specified kind.

func (*Type) IsMap

func (t *Type) IsMap() bool

func (*Type) IsMemory

func (t *Type) IsMemory() bool

func (*Type) IsPtr

func (t *Type) IsPtr() bool

IsPtr reports whether t is a regular Go pointer type. This does not include unsafe.Pointer.

func (*Type) IsPtrShaped

func (t *Type) IsPtrShaped() bool

IsPtrShaped reports whether t is represented by a single machine pointer. In addition to regular Go pointer types, this includes map, channel, and function types and unsafe.Pointer. It does not include array or struct types that consist of a single pointer shaped type. TODO(mdempsky): Should it? See golang.org/issue/15028.

func (*Type) IsRegularMemory

func (t *Type) IsRegularMemory() bool

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

func (*Type) IsSigned

func (t *Type) IsSigned() bool

func (*Type) IsSlice

func (t *Type) IsSlice() bool

func (*Type) IsString

func (t *Type) IsString() bool

func (*Type) IsStruct

func (t *Type) IsStruct() bool

func (*Type) IsTuple

func (t *Type) IsTuple() bool

func (*Type) IsUnsafePtr

func (t *Type) IsUnsafePtr() bool

IsUnsafePtr reports whether t is an unsafe pointer.

func (*Type) IsUntyped

func (t *Type) IsUntyped() bool

IsUntyped reports whether t is an untyped type.

func (*Type) IsVoid

func (t *Type) IsVoid() bool

func (*Type) Key

func (t *Type) Key() *Type

Key returns the key type of map type t.

func (*Type) Local

func (t *Type) Local() bool

func (*Type) LongString

func (t *Type) LongString() string

LongString generates a complete description of t. It is useful for reflection, or when a unique fingerprint or hash of a type is required.

func (*Type) MapType

func (t *Type) MapType() *MapType

MapType returns t's extra map-specific fields.

func (*Type) Methods

func (t *Type) Methods() *Fields

func (*Type) Nname

func (t *Type) Nname() *Node

Nname returns the associated function's nname.

func (*Type) Noalg

func (t *Type) Noalg() bool

func (*Type) NotInHeap

func (t *Type) NotInHeap() bool

func (*Type) NumElem

func (t *Type) NumElem() int64

func (*Type) NumFields

func (t *Type) NumFields() int

func (*Type) Params

func (t *Type) Params() *Type

func (*Type) PtrTo

func (t *Type) PtrTo() ssa.Type

func (*Type) Recv

func (t *Type) Recv() *Field

Recv returns the receiver of function type t, if any.

func (*Type) Recvs

func (t *Type) Recvs() *Type

func (*Type) Results

func (t *Type) Results() *Type

func (*Type) SetBroke

func (t *Type) SetBroke(b bool)

func (*Type) SetDeferwidth

func (t *Type) SetDeferwidth(b bool)

func (*Type) SetFields

func (t *Type) SetFields(fields []*Field)

SetFields sets struct/interface type t's fields/methods to fields.

func (*Type) SetInterface

func (t *Type) SetInterface(methods []*Field)

func (*Type) SetLocal

func (t *Type) SetLocal(b bool)

func (*Type) SetNname

func (t *Type) SetNname(n *Node)

Nname sets the associated function's nname.

func (*Type) SetNoalg

func (t *Type) SetNoalg(b bool)

func (*Type) SetNotInHeap

func (t *Type) SetNotInHeap(b bool)

func (*Type) SetNumElem

func (t *Type) SetNumElem(n int64)

SetNumElem sets the number of elements in an array type. The only allowed use is on array types created with typDDDArray. For other uses, create a new array with typArray instead.

func (*Type) ShortString

func (t *Type) ShortString() string

ShortString generates a short description of t. It is used in autogenerated method names, reflection, and itab names.

func (*Type) SimpleString

func (t *Type) SimpleString() string

func (*Type) Size

func (t *Type) Size() int64

func (*Type) String

func (t *Type) String() string

func (*Type) StructType

func (t *Type) StructType() *StructType

StructType returns t's extra struct-specific fields.

func (*Type) Symbol

func (t *Type) Symbol() *obj.LSym

func (*Type) Val

func (t *Type) Val() *Type

Val returns the value type of map type t.

type Val

type Val struct {
	// U contains one of:
	// bool     bool when n.ValCtype() == CTBOOL
	// *Mpint   int when n.ValCtype() == CTINT, rune when n.ValCtype() == CTRUNE
	// *Mpflt   float when n.ValCtype() == CTFLT
	// *Mpcplx  pair of floats when n.ValCtype() == CTCPLX
	// string   string when n.ValCtype() == CTSTR
	// *Nilval  when n.ValCtype() == 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.

Jump to

Keyboard shortcuts

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