From 04b08da9af0c450d645ab7389d1467308cfc2db8 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Mon, 4 Mar 2013 21:27:36 +0100 Subject: Imported Upstream version 1.1~hg20130304 --- src/cmd/gc/go.h | 343 ++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 231 insertions(+), 112 deletions(-) (limited to 'src/cmd/gc/go.h') diff --git a/src/cmd/gc/go.h b/src/cmd/gc/go.h index 43bd68793..f86c152f2 100644 --- a/src/cmd/gc/go.h +++ b/src/cmd/gc/go.h @@ -137,6 +137,7 @@ typedef struct Label Label; struct Type { uchar etype; + uchar nointerface; uchar chan; uchar trecur; // to detect loops uchar printed; @@ -146,7 +147,7 @@ struct Type uchar copyany; uchar local; // created in this file uchar deferwidth; - uchar broke; + uchar broke; // broken type definition. uchar isddd; // TFIELD is ... argument uchar align; @@ -170,21 +171,25 @@ struct Type vlong argwid; // most nodes - Type* type; - vlong width; // offset in TFIELD, width in all others + Type* type; // actual type for TFIELD, element type for TARRAY, TCHAN, TMAP, TPTRxx + vlong width; // offset in TFIELD, width in all others // TFIELD - Type* down; // also used in TMAP + Type* down; // next struct field, also key type in TMAP + Type* outer; // outer struct Strlit* note; // literal string annotation // TARRAY - int32 bound; // negative is dynamic array + vlong bound; // negative is dynamic array int32 maplineno; // first use of TFORW as map key int32 embedlineno; // first use of TFORW as embedded type // for TFORW, where to copy the eventual value to NodeList *copyto; + + // for usefield + Node *lastfn; }; #define T ((Type*)0) @@ -215,7 +220,10 @@ enum EscHeap, EscScope, EscNone, + EscReturn, EscNever, + EscBits = 4, + EscMask = (1<= y + OGT, // x > y + OIND, // *p + OINDEX, // a[i] + OINDEXMAP, // m[s] + OKEY, // The x:3 in t{x:3, y:4}, the 1:2 in a[1:2], the 2:20 in [3]int{2:20}, etc. + OPARAM, // The on-stack copy of a parameter or return value that escapes. + OLEN, // len + OMAKE, // make, typechecking may convert to a more specfic OMAKEXXX. + OMAKECHAN, // make(chan int) + OMAKEMAP, // make(map[string]int) + OMAKESLICE, // make([]int, 0) + OMUL, // x * y + ODIV, // x / y + OMOD, // x % y + OLSH, // x << u + ORSH, // x >> u + OAND, // x & y + OANDNOT, // x &^ y + ONEW, // new + ONOT, // !b + OCOM, // ^x + OPLUS, // +x + OMINUS, // -y + OOROR, // b1 || b2 + OPANIC, // panic + OPRINT, // print + OPRINTN, // println + OPAREN, // (x) + OSEND, // c <- x + OSLICE, // v[1:2], typechecking may convert to a more specfic OSLICEXXX. + OSLICEARR, // a[1:2] + OSLICESTR, // s[1:2] + ORECOVER, // recover + ORECV, // <-c + ORUNESTR, // string(i) + OSELRECV, // case x = <-c: + OSELRECV2, // case x, ok = <-c: + OIOTA, // iota + OREAL, // real + OIMAG, // imag + OCOMPLEX, // complex + + // statements + OBLOCK, // block of code + OBREAK, // break + OCASE, // case, after being verified by swt.c's casebody. + OXCASE, // case, before verification. + OCONTINUE, // continue + ODEFER, // defer + OEMPTY, // no-op + OFALL, // fallthrough, after being verified by swt.c's casebody. + OXFALL, // fallthrough, before verification. + OFOR, // for + OGOTO, // goto + OIF, // if + OLABEL, // label: + OPROC, // go + ORANGE, // range + ORETURN, // return + OSELECT, // select + OSWITCH, // switch x + OTYPESW, // switch err.(type) // types - OTCHAN, - OTMAP, - OTSTRUCT, - OTINTER, - OTFUNC, - OTARRAY, - OTPAREN, + OTCHAN, // chan int + OTMAP, // map[string]int + OTSTRUCT, // struct{} + OTINTER, // interface{} + OTFUNC, // func() + OTARRAY, // []int, [8]int, [N]int or [...]int + OTPAREN, // (T) // misc - ODDD, - ODDDARG, - OINLCALL, // intermediary representation of an inlined call - OITAB, // itable word of interface value - - // for back ends - OCMP, ODEC, OEXTEND, OINC, OREGISTER, OINDREG, + 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. + OCLOSUREVAR, // variable reference at beginning of closure function + OCFUNC, // reference to c function pointer (not go func value) + + // arch-specific registers + OREGISTER, // a register, such as AX. + OINDREG, // offset plus indirect of a register, such as 8(SP). + + // 386/amd64-specific opcodes + OCMP, // compare: ACMP. + ODEC, // decrement: ADEC. + OINC, // increment: AINC. + OEXTEND, // extend: ACWD/ACDQ/ACQO. + OHMUL, // high mul: AMUL/AIMUL for unsigned/signed (OMUL uses AIMUL for both). + OLROT, // left rotate: AROL. + ORROTC, // right rotate-carry: ARCR. OEND, }; + enum { Txxx, // 0 @@ -539,6 +624,7 @@ enum NTYPE, }; + enum { CTxxx, @@ -562,18 +648,21 @@ enum Cboth = Crecv | Csend, }; +// declaration context enum { Pxxx, - PEXTERN, // declaration context - PAUTO, - PPARAM, - PPARAMOUT, - PPARAMREF, // param passed by reference - PFUNC, + PEXTERN, // global variable + PAUTO, // local variables + PPARAM, // input arguments + PPARAMOUT, // output results + PPARAMREF, // closure variable reference + PFUNC, // global function - PHEAP = 1<<7, + PDISCARD, // discard during parse of duplicate import + + PHEAP = 1<<7, // an extra bit to identify an escaped variable }; enum @@ -606,7 +695,6 @@ typedef struct Var Var; struct Var { vlong offset; - Sym* gotype; Node* node; int width; char name; @@ -756,7 +844,7 @@ EXTERN int safemode; EXTERN char namebuf[NSYMB]; EXTERN char lexbuf[NSYMB]; EXTERN char litbuf[NSYMB]; -EXTERN char debug[256]; +EXTERN int debug[256]; EXTERN Sym* hash[NHASH]; EXTERN Sym* importmyname; // my name for package EXTERN Pkg* localpkg; // package being compiled @@ -764,11 +852,15 @@ EXTERN Pkg* importpkg; // package being imported EXTERN Pkg* structpkg; // package that declared struct, during import EXTERN Pkg* builtinpkg; // fake package for builtins EXTERN Pkg* gostringpkg; // fake pkg for Go strings +EXTERN Pkg* itabpkg; // fake pkg for itab cache EXTERN Pkg* runtimepkg; // package runtime +EXTERN Pkg* racepkg; // package runtime/race EXTERN Pkg* stringpkg; // fake package for C strings -EXTERN Pkg* typepkg; // fake package for runtime type info +EXTERN Pkg* typepkg; // fake package for runtime type info (headers) +EXTERN Pkg* typelinkpkg; // fake package for runtime type info (data) EXTERN Pkg* weaktypepkg; // weak references to runtime type info EXTERN Pkg* unsafepkg; // package unsafe +EXTERN Pkg* trackpkg; // fake package for field tracking EXTERN Pkg* phash[128]; EXTERN int tptr; // either TPTR32 or TPTR64 extern char* runtimeimport; @@ -815,6 +907,7 @@ EXTERN NodeList* externdcl; EXTERN NodeList* closures; EXTERN NodeList* exportlist; EXTERN NodeList* importlist; // imported functions and methods with inlinable bodies +EXTERN NodeList* funcsyms; EXTERN int dclcontext; // PEXTERN/PAUTO EXTERN int incannedimport; EXTERN int statuniqgen; // name generator for static temps @@ -823,8 +916,8 @@ EXTERN int loophack; EXTERN int32 iota; EXTERN NodeList* lastconst; EXTERN Node* lasttype; -EXTERN int32 maxarg; -EXTERN int32 stksize; // stack size for current frame +EXTERN vlong maxarg; +EXTERN vlong stksize; // stack size for current frame EXTERN int32 blockgen; // max block number EXTERN int32 block; // current block number EXTERN int hasdefer; // flag that curfn has defer statetment @@ -832,12 +925,14 @@ EXTERN int hasdefer; // flag that curfn has defer statetment EXTERN Node* curfn; EXTERN int widthptr; +EXTERN int widthint; EXTERN Node* typesw; EXTERN Node* nblank; extern int thechar; extern char* thestring; +EXTERN int use_sse; EXTERN char* hunk; EXTERN int32 nhunk; @@ -846,6 +941,14 @@ EXTERN int32 thunk; EXTERN int funcdepth; EXTERN int typecheckok; EXTERN int compiling_runtime; +EXTERN int compiling_wrappers; +EXTERN int pure_go; +EXTERN int flag_race; +EXTERN int flag_largemodel; +EXTERN int noescape; + +EXTERN int nointerface; +EXTERN int fieldtrack_enabled; /* * y.tab.c @@ -860,7 +963,7 @@ void checkwidth(Type *t); void defercheckwidth(void); void dowidth(Type *t); void resumecheckwidth(void); -uint32 rnd(uint32 o, uint32 r); +vlong rnd(vlong o, vlong r); void typeinit(void); /* @@ -898,9 +1001,11 @@ void defaultlit(Node **np, Type *t); void defaultlit2(Node **lp, Node **rp, int force); void evconst(Node *n); int isconst(Node *n, int ct); +int isgoconst(Node *n); Node* nodcplxlit(Val r, Val i); Node* nodlit(Val v); long nonnegconst(Node *n); +int doesoverflow(Val v, Type *t); void overflow(Val v, Type *t); int smallintconst(Node *n); Val toint(Val v); @@ -910,7 +1015,7 @@ Mpflt* truncfltlit(Mpflt *oldv, Type *t); * cplx.c */ void complexadd(int op, Node *nl, Node *nr, Node *res); -void complexbool(int op, Node *nl, Node *nr, int true, Prog *to); +void complexbool(int op, Node *nl, Node *nr, int true, int likely, Prog *to); void complexgen(Node *n, Node *res); void complexminus(Node *nl, Node *res); void complexmove(Node *f, Node *t); @@ -921,10 +1026,10 @@ void nodfconst(Node *n, Type *t, Mpflt* fval); /* * dcl.c */ -void addmethod(Sym *sf, Type *t, int local); +void addmethod(Sym *sf, Type *t, int local, int nointerface); void addvar(Node *n, Type *t, int ctxt); NodeList* checkarglist(NodeList *all, int input); -Node* colas(NodeList *left, NodeList *right); +Node* colas(NodeList *left, NodeList *right, int32 lno); void colasdefn(NodeList *left, Node *defn); NodeList* constiter(NodeList *vl, Node *t, NodeList *cl); Node* dclname(Sym *s); @@ -954,6 +1059,7 @@ Node* typedcl0(Sym *s); Node* typedcl1(Node *n, Node *t, int local); Node* typenod(Type *t); NodeList* variter(NodeList *vl, Node *t, NodeList *el); +Sym* funcsym(Sym*); /* * esc.c @@ -987,6 +1093,8 @@ void dumplist(char *s, NodeList *l); void addrescapes(Node *n); void cgen_as(Node *nl, Node *nr); void cgen_callmeth(Node *n, int proc); +void cgen_eface(Node* n, Node* res); +void cgen_slice(Node* n, Node* res); void clearlabels(void); void checklabels(void); int dotoffset(Node *n, int *oary, Node **nn); @@ -1115,8 +1223,11 @@ void dumptypestructs(void); Type* methodfunc(Type *f, Type*); Node* typename(Type *t); Sym* typesym(Type *t); +Sym* typenamesym(Type *t); +Sym* tracksym(Type *t); Sym* typesymprefix(char *prefix, Type *t); int haspointers(Type *t); +void usefield(Node*); /* * select.c @@ -1214,6 +1325,7 @@ Node* safeexpr(Node *n, NodeList **init); void saveerrors(void); Node* cheapexpr(Node *n, NodeList **init); Node* localexpr(Node *n, Type *t, NodeList **init); +void saveorignode(Node *n); int32 setlineno(Node *n); void setmaxarg(Type *t); Type* shallow(Type *t); @@ -1274,6 +1386,7 @@ void walkexprlistsafe(NodeList *l, NodeList **init); void walkstmt(Node **np); void walkstmtlist(NodeList *l); Node* conv(Node*, Type*); +int candiscard(Node*); /* * arch-specific ggen.c/gsubr.c/gobj.c/pgen.c @@ -1302,7 +1415,8 @@ EXTERN Node* nodfp; int anyregalloc(void); void betypeinit(void); -void bgen(Node *n, int true, Prog *to); +void bgen(Node *n, int true, int likely, Prog *to); +void checkref(Node*); void cgen(Node*, Node*); void cgen_asop(Node *n); void cgen_call(Node *n, int proc); @@ -1323,8 +1437,8 @@ void gdata(Node*, Node*, int); void gdatacomplex(Node*, Mpcplx*); void gdatastring(Node*, Strlit*); void genembedtramp(Type*, Type*, Sym*, int iface); -void ggloblnod(Node *nam, int32 width); -void ggloblsym(Sym *s, int32 width, int dupok); +void ggloblnod(Node *nam); +void ggloblsym(Sym *s, int32 width, int dupok, int rodata); Prog* gjmp(Prog*); void gused(Node*); int isfat(Type*); @@ -1364,3 +1478,8 @@ void zname(Biobuf *b, Sym *s, int t); #pragma varargck type "V" Val* #pragma varargck type "Y" char* #pragma varargck type "Z" Strlit* + +/* + * racewalk.c + */ +void racewalk(Node *fn); -- cgit v1.2.3