Commit bd4fff63 authored by Russ Cox's avatar Russ Cox

cmd/compile: move ODCLFUNC Node.Nname into Node.Func.Nname

$ sizeof -p cmd/compile/internal/gc Node
Node 168
$

Change-Id: I7decd950fe068c0f294c6c9bff07ef809c394429
Reviewed-on: https://go-review.googlesource.com/10534Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
Reviewed-by: 's avatarJosh Bleecher Snyder <josharian@gmail.com>
parent 8f4d9646
...@@ -150,14 +150,14 @@ func closurename(n *Node) *Sym { ...@@ -150,14 +150,14 @@ func closurename(n *Node) *Sym {
gen = closurename_closgen gen = closurename_closgen
} else if n.Func.Outerfunc.Op == ODCLFUNC { } else if n.Func.Outerfunc.Op == ODCLFUNC {
// The outermost closure inside of a named function. // The outermost closure inside of a named function.
outer = n.Func.Outerfunc.Nname.Sym.Name outer = n.Func.Outerfunc.Func.Nname.Sym.Name
prefix = "func" prefix = "func"
// Yes, functions can be named _. // Yes, functions can be named _.
// Can't use function closgen in such case, // Can't use function closgen in such case,
// because it would lead to name clashes. // because it would lead to name clashes.
if !isblank(n.Func.Outerfunc.Nname) { if !isblank(n.Func.Outerfunc.Func.Nname) {
n.Func.Outerfunc.Func.Closgen++ n.Func.Outerfunc.Func.Closgen++
gen = n.Func.Outerfunc.Func.Closgen gen = n.Func.Outerfunc.Func.Closgen
} else { } else {
...@@ -191,12 +191,12 @@ func makeclosure(func_ *Node) *Node { ...@@ -191,12 +191,12 @@ func makeclosure(func_ *Node) *Node {
// create the function // create the function
xfunc := Nod(ODCLFUNC, nil, nil) xfunc := Nod(ODCLFUNC, nil, nil)
xfunc.Nname = newfuncname(closurename(func_)) xfunc.Func.Nname = newfuncname(closurename(func_))
xfunc.Nname.Sym.Flags |= SymExported // disable export xfunc.Func.Nname.Sym.Flags |= SymExported // disable export
xfunc.Nname.Name.Param.Ntype = xtype xfunc.Func.Nname.Name.Param.Ntype = xtype
xfunc.Nname.Name.Defn = xfunc xfunc.Func.Nname.Name.Defn = xfunc
declare(xfunc.Nname, PFUNC) declare(xfunc.Func.Nname, PFUNC)
xfunc.Nname.Name.Funcdepth = func_.Func.Depth xfunc.Func.Nname.Name.Funcdepth = func_.Func.Depth
xfunc.Func.Depth = func_.Func.Depth xfunc.Func.Depth = func_.Func.Depth
xfunc.Func.Endlineno = func_.Func.Endlineno xfunc.Func.Endlineno = func_.Func.Endlineno
...@@ -262,8 +262,8 @@ func capturevars(xfunc *Node) { ...@@ -262,8 +262,8 @@ func capturevars(xfunc *Node) {
if Debug['m'] > 1 { if Debug['m'] > 1 {
var name *Sym var name *Sym
if v.Name.Curfn != nil && v.Name.Curfn.Nname != nil { if v.Name.Curfn != nil && v.Name.Curfn.Func.Nname != nil {
name = v.Name.Curfn.Nname.Sym name = v.Name.Curfn.Func.Nname.Sym
} }
how := "ref" how := "ref"
if v.Name.Byval { if v.Name.Byval {
...@@ -303,7 +303,7 @@ func transformclosure(xfunc *Node) { ...@@ -303,7 +303,7 @@ func transformclosure(xfunc *Node) {
// }(42, byval, &byref) // }(42, byval, &byref)
// f is ONAME of the actual function. // f is ONAME of the actual function.
f := xfunc.Nname f := xfunc.Func.Nname
// Get pointer to input arguments and rewind to the end. // Get pointer to input arguments and rewind to the end.
// We are going to append captured variables to input args. // We are going to append captured variables to input args.
...@@ -420,7 +420,7 @@ func transformclosure(xfunc *Node) { ...@@ -420,7 +420,7 @@ func transformclosure(xfunc *Node) {
func walkclosure(func_ *Node, init **NodeList) *Node { func walkclosure(func_ *Node, init **NodeList) *Node {
// If no closure vars, don't bother wrapping. // If no closure vars, don't bother wrapping.
if func_.Func.Cvars == nil { if func_.Func.Cvars == nil {
return func_.Func.Closure.Nname return func_.Func.Closure.Func.Nname
} }
// Create closure in the form of a composite literal. // Create closure in the form of a composite literal.
...@@ -457,7 +457,7 @@ func walkclosure(func_ *Node, init **NodeList) *Node { ...@@ -457,7 +457,7 @@ func walkclosure(func_ *Node, init **NodeList) *Node {
clos := Nod(OCOMPLIT, nil, Nod(OIND, typ, nil)) clos := Nod(OCOMPLIT, nil, Nod(OIND, typ, nil))
clos.Esc = func_.Esc clos.Esc = func_.Esc
clos.Right.Implicit = true clos.Right.Implicit = true
clos.List = concat(list1(Nod(OCFUNC, func_.Func.Closure.Nname, nil)), func_.Func.Enter) clos.List = concat(list1(Nod(OCFUNC, func_.Func.Closure.Func.Nname, nil)), func_.Func.Enter)
// Force type conversion from *struct to the func type. // Force type conversion from *struct to the func type.
clos = Nod(OCONVNOP, clos, nil) clos = Nod(OCONVNOP, clos, nil)
...@@ -494,11 +494,11 @@ func typecheckpartialcall(fn *Node, sym *Node) { ...@@ -494,11 +494,11 @@ func typecheckpartialcall(fn *Node, sym *Node) {
} }
// Create top-level function. // Create top-level function.
fn.Nname = makepartialcall(fn, fn.Type, sym) xfunc := makepartialcall(fn, fn.Type, sym)
fn.Func = xfunc.Func
fn.Right = sym fn.Right = sym
fn.Op = OCALLPART fn.Op = OCALLPART
fn.Type = fn.Nname.Type fn.Type = xfunc.Type
} }
var makepartialcall_gopkg *Pkg var makepartialcall_gopkg *Pkg
...@@ -581,11 +581,11 @@ func makepartialcall(fn *Node, t0 *Type, meth *Node) *Node { ...@@ -581,11 +581,11 @@ func makepartialcall(fn *Node, t0 *Type, meth *Node) *Node {
xtype.Rlist = l xtype.Rlist = l
xfunc.Func.Dupok = true xfunc.Func.Dupok = true
xfunc.Nname = newfuncname(sym) xfunc.Func.Nname = newfuncname(sym)
xfunc.Nname.Sym.Flags |= SymExported // disable export xfunc.Func.Nname.Sym.Flags |= SymExported // disable export
xfunc.Nname.Name.Param.Ntype = xtype xfunc.Func.Nname.Name.Param.Ntype = xtype
xfunc.Nname.Name.Defn = xfunc xfunc.Func.Nname.Name.Defn = xfunc
declare(xfunc.Nname, PFUNC) declare(xfunc.Func.Nname, PFUNC)
// Declare and initialize variable holding receiver. // Declare and initialize variable holding receiver.
...@@ -660,7 +660,7 @@ func walkpartialcall(n *Node, init **NodeList) *Node { ...@@ -660,7 +660,7 @@ func walkpartialcall(n *Node, init **NodeList) *Node {
clos := Nod(OCOMPLIT, nil, Nod(OIND, typ, nil)) clos := Nod(OCOMPLIT, nil, Nod(OIND, typ, nil))
clos.Esc = n.Esc clos.Esc = n.Esc
clos.Right.Implicit = true clos.Right.Implicit = true
clos.List = list1(Nod(OCFUNC, n.Nname.Nname, nil)) clos.List = list1(Nod(OCFUNC, n.Func.Nname, nil))
clos.List = list(clos.List, n.Left) clos.List = list(clos.List, n.Left)
// Force type conversion from *struct to the func type. // Force type conversion from *struct to the func type.
......
...@@ -592,8 +592,8 @@ func funchdr(n *Node) { ...@@ -592,8 +592,8 @@ func funchdr(n *Node) {
n.Func.Outer = Curfn n.Func.Outer = Curfn
Curfn = n Curfn = n
if n.Nname != nil { if n.Func.Nname != nil {
funcargs(n.Nname.Name.Param.Ntype) funcargs(n.Func.Nname.Name.Param.Ntype)
} else if n.Func.Ntype != nil { } else if n.Func.Ntype != nil {
funcargs(n.Func.Ntype) funcargs(n.Func.Ntype)
} else { } else {
...@@ -1471,7 +1471,7 @@ func funccompile(n *Node) { ...@@ -1471,7 +1471,7 @@ func funccompile(n *Node) {
checkwidth(n.Type) checkwidth(n.Type)
if Curfn != nil { if Curfn != nil {
Fatal("funccompile %v inside %v", n.Nname.Sym, Curfn.Nname.Sym) Fatal("funccompile %v inside %v", n.Func.Nname.Sym, Curfn.Func.Nname.Sym)
} }
Stksize = 0 Stksize = 0
......
...@@ -412,11 +412,11 @@ type EscState struct { ...@@ -412,11 +412,11 @@ type EscState struct {
} }
// funcSym returns n.Nname.Sym if no nils are encountered along the way. // funcSym returns n.Nname.Sym if no nils are encountered along the way.
func funcSym(n *Node) *Sym { func funcSym(fn *Node) *Sym {
if n == nil || n.Nname == nil { if fn == nil || fn.Func.Nname == nil {
return nil return nil
} }
return n.Nname.Sym return fn.Func.Nname.Sym
} }
// curfnSym returns n.Curfn.Nname.Sym if no nils are encountered along the way. // curfnSym returns n.Curfn.Nname.Sym if no nils are encountered along the way.
...@@ -478,7 +478,7 @@ func escAnalyze(all *NodeList, recursive bool) { ...@@ -478,7 +478,7 @@ func escAnalyze(all *NodeList, recursive bool) {
func escfunc(e *EscState, func_ *Node) { func escfunc(e *EscState, func_ *Node) {
// print("escfunc %N %s\n", func->nname, e->recursive?"(recursive)":""); // print("escfunc %N %s\n", func->nname, e->recursive?"(recursive)":"");
if func_.Esc != 1 { if func_.Esc != 1 {
Fatal("repeat escfunc %v", func_.Nname) Fatal("repeat escfunc %v", func_.Func.Nname)
} }
func_.Esc = EscFuncStarted func_.Esc = EscFuncStarted
......
...@@ -1420,10 +1420,10 @@ fndcl: ...@@ -1420,10 +1420,10 @@ fndcl:
t.Rlist = $5; t.Rlist = $5;
$$ = Nod(ODCLFUNC, nil, nil); $$ = Nod(ODCLFUNC, nil, nil);
$$.Nname = newfuncname($1); $$.Func.Nname = newfuncname($1);
$$.Nname.Name.Defn = $$; $$.Func.Nname.Name.Defn = $$;
$$.Nname.Param.Ntype = t; // TODO: check if nname already has an ntype $$.Func.Nname.Name.Param.Ntype = t; // TODO: check if nname already has an ntype
declare($$.Nname, PFUNC); declare($$.Func.Nname, PFUNC);
funchdr($$); funchdr($$);
} }
...@@ -1455,11 +1455,11 @@ fndcl: ...@@ -1455,11 +1455,11 @@ fndcl:
$$ = Nod(ODCLFUNC, nil, nil); $$ = Nod(ODCLFUNC, nil, nil);
$$.Func.Shortname = newfuncname($4); $$.Func.Shortname = newfuncname($4);
$$.Nname = methodname1($$.Func.Shortname, rcvr.Right); $$.Func.Nname = methodname1($$.Func.Shortname, rcvr.Right);
$$.Nname.Name.Defn = $$; $$.Func.Nname.Name.Defn = $$;
$$.Nname.Param.Ntype = t; $$.Func.Nname.Name.Param.Ntype = t;
$$.Nname.Nointerface = nointerface; $$.Func.Nname.Nointerface = nointerface;
declare($$.Nname, PFUNC); declare($$.Func.Nname, PFUNC);
funchdr($$); funchdr($$);
} }
......
...@@ -114,10 +114,10 @@ func fninit(n *NodeList) { ...@@ -114,10 +114,10 @@ func fninit(n *NodeList) {
fn := Nod(ODCLFUNC, nil, nil) fn := Nod(ODCLFUNC, nil, nil)
initsym := Lookup("init") initsym := Lookup("init")
fn.Nname = newname(initsym) fn.Func.Nname = newname(initsym)
fn.Nname.Name.Defn = fn fn.Func.Nname.Name.Defn = fn
fn.Nname.Name.Param.Ntype = Nod(OTFUNC, nil, nil) fn.Func.Nname.Name.Param.Ntype = Nod(OTFUNC, nil, nil)
declare(fn.Nname, PFUNC) declare(fn.Func.Nname, PFUNC)
funchdr(fn) funchdr(fn)
// (3) // (3)
...@@ -176,7 +176,7 @@ func fninit(n *NodeList) { ...@@ -176,7 +176,7 @@ func fninit(n *NodeList) {
a = Nod(ORETURN, nil, nil) a = Nod(ORETURN, nil, nil)
r = list(r, a) r = list(r, a)
exportsym(fn.Nname) exportsym(fn.Func.Nname)
fn.Nbody = r fn.Nbody = r
funcbody(fn) funcbody(fn)
......
...@@ -102,7 +102,7 @@ func caninl(fn *Node) { ...@@ -102,7 +102,7 @@ func caninl(fn *Node) {
if fn.Op != ODCLFUNC { if fn.Op != ODCLFUNC {
Fatal("caninl %v", fn) Fatal("caninl %v", fn)
} }
if fn.Nname == nil { if fn.Func.Nname == nil {
Fatal("caninl no nname %v", Nconv(fn, obj.FmtSign)) Fatal("caninl no nname %v", Nconv(fn, obj.FmtSign))
} }
...@@ -143,19 +143,19 @@ func caninl(fn *Node) { ...@@ -143,19 +143,19 @@ func caninl(fn *Node) {
savefn := Curfn savefn := Curfn
Curfn = fn Curfn = fn
fn.Nname.Func.Inl = fn.Nbody fn.Func.Nname.Func.Inl = fn.Nbody
fn.Nbody = inlcopylist(fn.Nname.Func.Inl) fn.Nbody = inlcopylist(fn.Func.Nname.Func.Inl)
fn.Nname.Func.Inldcl = inlcopylist(fn.Nname.Name.Defn.Func.Dcl) fn.Func.Nname.Func.Inldcl = inlcopylist(fn.Func.Nname.Name.Defn.Func.Dcl)
fn.Nname.Func.InlCost = int32(maxBudget - budget) fn.Func.Nname.Func.InlCost = int32(maxBudget - budget)
// hack, TODO, check for better way to link method nodes back to the thing with the ->inl // hack, TODO, check for better way to link method nodes back to the thing with the ->inl
// this is so export can find the body of a method // this is so export can find the body of a method
fn.Type.Nname = fn.Nname fn.Type.Nname = fn.Func.Nname
if Debug['m'] > 1 { if Debug['m'] > 1 {
fmt.Printf("%v: can inline %v as: %v { %v }\n", fn.Line(), Nconv(fn.Nname, obj.FmtSharp), Tconv(fn.Type, obj.FmtSharp), Hconv(fn.Nname.Func.Inl, obj.FmtSharp)) fmt.Printf("%v: can inline %v as: %v { %v }\n", fn.Line(), Nconv(fn.Func.Nname, obj.FmtSharp), Tconv(fn.Type, obj.FmtSharp), Hconv(fn.Func.Nname.Func.Inl, obj.FmtSharp))
} else if Debug['m'] != 0 { } else if Debug['m'] != 0 {
fmt.Printf("%v: can inline %v\n", fn.Line(), fn.Nname) fmt.Printf("%v: can inline %v\n", fn.Line(), fn.Func.Nname)
} }
Curfn = savefn Curfn = savefn
......
...@@ -430,7 +430,7 @@ func gdatastring(nam *Node, sval string) { ...@@ -430,7 +430,7 @@ func gdatastring(nam *Node, sval string) {
p.From3.Offset = Types[Tptr].Width p.From3.Offset = Types[Tptr].Width
p.To.Type = obj.TYPE_ADDR p.To.Type = obj.TYPE_ADDR
//print("%P\n", p); //print("%v\n", p);
Nodconst(&nod1, Types[TINT], int64(len(sval))) Nodconst(&nod1, Types[TINT], int64(len(sval)))
......
...@@ -50,7 +50,7 @@ type Order struct { ...@@ -50,7 +50,7 @@ type Order struct {
// described in the comment at the top of the file. // described in the comment at the top of the file.
func order(fn *Node) { func order(fn *Node) {
if Debug['W'] > 1 { if Debug['W'] > 1 {
s := fmt.Sprintf("\nbefore order %v", fn.Nname.Sym) s := fmt.Sprintf("\nbefore order %v", fn.Func.Nname.Sym)
dumplist(s, fn.Nbody) dumplist(s, fn.Nbody)
} }
......
...@@ -129,7 +129,7 @@ func gcsymdup(s *Sym) { ...@@ -129,7 +129,7 @@ func gcsymdup(s *Sym) {
} }
func emitptrargsmap() { func emitptrargsmap() {
sym := Lookup(fmt.Sprintf("%s.args_stackmap", Curfn.Nname.Sym.Name)) sym := Lookup(fmt.Sprintf("%s.args_stackmap", Curfn.Func.Nname.Sym.Name))
nptr := int(Curfn.Type.Argwid / int64(Widthptr)) nptr := int(Curfn.Type.Argwid / int64(Widthptr))
bv := bvalloc(int32(nptr) * 2) bv := bvalloc(int32(nptr) * 2)
...@@ -354,8 +354,8 @@ func compile(fn *Node) { ...@@ -354,8 +354,8 @@ func compile(fn *Node) {
var gcargs *Sym var gcargs *Sym
var gclocals *Sym var gclocals *Sym
if fn.Nbody == nil { if fn.Nbody == nil {
if pure_go != 0 || strings.HasPrefix(fn.Nname.Sym.Name, "init.") { if pure_go != 0 || strings.HasPrefix(fn.Func.Nname.Sym.Name, "init.") {
Yyerror("missing function body for %q", fn.Nname.Sym.Name) Yyerror("missing function body for %q", fn.Func.Nname.Sym.Name)
goto ret goto ret
} }
...@@ -408,12 +408,12 @@ func compile(fn *Node) { ...@@ -408,12 +408,12 @@ func compile(fn *Node) {
breakpc = nil breakpc = nil
pl = newplist() pl = newplist()
pl.Name = Linksym(Curfn.Nname.Sym) pl.Name = Linksym(Curfn.Func.Nname.Sym)
setlineno(Curfn) setlineno(Curfn)
Nodconst(&nod1, Types[TINT32], 0) Nodconst(&nod1, Types[TINT32], 0)
nam = Curfn.Nname nam = Curfn.Func.Nname
if isblank(nam) { if isblank(nam) {
nam = nil nam = nil
} }
...@@ -436,12 +436,12 @@ func compile(fn *Node) { ...@@ -436,12 +436,12 @@ func compile(fn *Node) {
// See test/recover.go for test cases and src/reflect/value.go // See test/recover.go for test cases and src/reflect/value.go
// for the actual functions being considered. // for the actual functions being considered.
if myimportpath != "" && myimportpath == "reflect" { if myimportpath != "" && myimportpath == "reflect" {
if Curfn.Nname.Sym.Name == "callReflect" || Curfn.Nname.Sym.Name == "callMethod" { if Curfn.Func.Nname.Sym.Name == "callReflect" || Curfn.Func.Nname.Sym.Name == "callMethod" {
ptxt.From3.Offset |= obj.WRAPPER ptxt.From3.Offset |= obj.WRAPPER
} }
} }
Afunclit(&ptxt.From, Curfn.Nname) Afunclit(&ptxt.From, Curfn.Func.Nname)
ginit() ginit()
......
...@@ -1284,7 +1284,7 @@ func livenessepilogue(lv *Liveness) { ...@@ -1284,7 +1284,7 @@ func livenessepilogue(lv *Liveness) {
if !n.Name.Needzero { if !n.Name.Needzero {
n.Name.Needzero = true n.Name.Needzero = true
if debuglive >= 1 { if debuglive >= 1 {
Warnl(int(p.Lineno), "%v: %v is ambiguously live", Curfn.Nname, Nconv(n, obj.FmtLong)) Warnl(int(p.Lineno), "%v: %v is ambiguously live", Curfn.Func.Nname, Nconv(n, obj.FmtLong))
} }
// Record in 'ambiguous' bitmap. // Record in 'ambiguous' bitmap.
...@@ -1331,7 +1331,7 @@ func livenessepilogue(lv *Liveness) { ...@@ -1331,7 +1331,7 @@ func livenessepilogue(lv *Liveness) {
var numlive int32 var numlive int32
var msg []string var msg []string
for _, bb := range lv.cfg { for _, bb := range lv.cfg {
if debuglive >= 1 && Curfn.Nname.Sym.Name != "init" && Curfn.Nname.Sym.Name[0] != '.' { if debuglive >= 1 && Curfn.Func.Nname.Sym.Name != "init" && Curfn.Func.Nname.Sym.Name[0] != '.' {
nmsg = int32(len(lv.livepointers)) nmsg = int32(len(lv.livepointers))
startmsg = nmsg startmsg = nmsg
msg = make([]string, nmsg) msg = make([]string, nmsg)
...@@ -1381,7 +1381,7 @@ func livenessepilogue(lv *Liveness) { ...@@ -1381,7 +1381,7 @@ func livenessepilogue(lv *Liveness) {
} }
n = lv.vars[j] n = lv.vars[j]
if n.Class != PPARAM { if n.Class != PPARAM {
yyerrorl(int(p.Lineno), "internal error: %v %v recorded as live on entry", Curfn.Nname, Nconv(n, obj.FmtLong)) yyerrorl(int(p.Lineno), "internal error: %v %v recorded as live on entry", Curfn.Func.Nname, Nconv(n, obj.FmtLong))
} }
} }
} }
...@@ -1622,7 +1622,7 @@ func livenessprintdebug(lv *Liveness) { ...@@ -1622,7 +1622,7 @@ func livenessprintdebug(lv *Liveness) {
var locals Bvec var locals Bvec
var n *Node var n *Node
fmt.Printf("liveness: %s\n", Curfn.Nname.Sym.Name) fmt.Printf("liveness: %s\n", Curfn.Func.Nname.Sym.Name)
uevar := bvalloc(int32(len(lv.vars))) uevar := bvalloc(int32(len(lv.vars)))
varkill := bvalloc(int32(len(lv.vars))) varkill := bvalloc(int32(len(lv.vars)))
...@@ -1770,13 +1770,13 @@ func liveness(fn *Node, firstp *obj.Prog, argssym *Sym, livesym *Sym) { ...@@ -1770,13 +1770,13 @@ func liveness(fn *Node, firstp *obj.Prog, argssym *Sym, livesym *Sym) {
// Change name to dump debugging information only for a specific function. // Change name to dump debugging information only for a specific function.
debugdelta := 0 debugdelta := 0
if Curfn.Nname.Sym.Name == "!" { if Curfn.Func.Nname.Sym.Name == "!" {
debugdelta = 2 debugdelta = 2
} }
debuglive += debugdelta debuglive += debugdelta
if debuglive >= 3 { if debuglive >= 3 {
fmt.Printf("liveness: %s\n", Curfn.Nname.Sym.Name) fmt.Printf("liveness: %s\n", Curfn.Func.Nname.Sym.Name)
printprog(firstp) printprog(firstp)
} }
......
...@@ -263,7 +263,7 @@ func Flowstart(firstp *obj.Prog, newData func() interface{}) *Graph { ...@@ -263,7 +263,7 @@ func Flowstart(firstp *obj.Prog, newData func() interface{}) *Graph {
if nf >= MaxFlowProg { if nf >= MaxFlowProg {
if Debug['v'] != 0 { if Debug['v'] != 0 {
Warn("%v is too big (%d instructions)", Curfn.Nname.Sym, nf) Warn("%v is too big (%d instructions)", Curfn.Func.Nname.Sym, nf)
} }
return nil return nil
} }
...@@ -786,7 +786,7 @@ func mergetemp(firstp *obj.Prog) { ...@@ -786,7 +786,7 @@ func mergetemp(firstp *obj.Prog) {
} }
if debugmerge > 0 && Debug['v'] != 0 { if debugmerge > 0 && Debug['v'] != 0 {
fmt.Printf("%v [%d - %d]\n", Curfn.Nname.Sym, len(var_), nkill) fmt.Printf("%v [%d - %d]\n", Curfn.Func.Nname.Sym, len(var_), nkill)
var v *TempVar var v *TempVar
for i := 0; i < len(var_); i++ { for i := 0; i < len(var_); i++ {
v = &var_[i] v = &var_[i]
...@@ -980,7 +980,7 @@ func nilopt(firstp *obj.Prog) { ...@@ -980,7 +980,7 @@ func nilopt(firstp *obj.Prog) {
Flowend(g) Flowend(g)
if Debug_checknil > 1 { if Debug_checknil > 1 {
fmt.Printf("%v: removed %d of %d nil checks\n", Curfn.Nname.Sym, nkill, ncheck) fmt.Printf("%v: removed %d of %d nil checks\n", Curfn.Func.Nname.Sym, nkill, ncheck)
} }
} }
......
...@@ -48,7 +48,7 @@ func isforkfunc(fn *Node) bool { ...@@ -48,7 +48,7 @@ func isforkfunc(fn *Node) bool {
// they might have been locked at the time of the fork. This means // they might have been locked at the time of the fork. This means
// no rescheduling, no malloc calls, and no new stack segments. // no rescheduling, no malloc calls, and no new stack segments.
// Race instrumentation does all of the above. // Race instrumentation does all of the above.
return myimportpath != "" && myimportpath == "syscall" && fn.Nname.Sym.Name == "forkAndExecInChild" return myimportpath != "" && myimportpath == "syscall" && fn.Func.Nname.Sym.Name == "forkAndExecInChild"
} }
func racewalk(fn *Node) { func racewalk(fn *Node) {
...@@ -77,11 +77,11 @@ func racewalk(fn *Node) { ...@@ -77,11 +77,11 @@ func racewalk(fn *Node) {
fn.Func.Exit = list(fn.Func.Exit, nd) fn.Func.Exit = list(fn.Func.Exit, nd)
if Debug['W'] != 0 { if Debug['W'] != 0 {
s := fmt.Sprintf("after racewalk %v", fn.Nname.Sym) s := fmt.Sprintf("after racewalk %v", fn.Func.Nname.Sym)
dumplist(s, fn.Nbody) dumplist(s, fn.Nbody)
s = fmt.Sprintf("enter %v", fn.Nname.Sym) s = fmt.Sprintf("enter %v", fn.Func.Nname.Sym)
dumplist(s, fn.Func.Enter) dumplist(s, fn.Func.Enter)
s = fmt.Sprintf("exit %v", fn.Nname.Sym) s = fmt.Sprintf("exit %v", fn.Func.Nname.Sym)
dumplist(s, fn.Func.Exit) dumplist(s, fn.Func.Exit)
} }
} }
......
...@@ -1342,7 +1342,7 @@ loop2: ...@@ -1342,7 +1342,7 @@ loop2:
} }
} }
if false && Debug['v'] != 0 && strings.Contains(Curfn.Nname.Sym.Name, "Parse") { if false && Debug['v'] != 0 && strings.Contains(Curfn.Func.Nname.Sym.Name, "Parse") {
Warn("regions: %d\n", nregion) Warn("regions: %d\n", nregion)
} }
if nregion >= MaxRgn { if nregion >= MaxRgn {
......
...@@ -1622,7 +1622,7 @@ func frame(context int) { ...@@ -1622,7 +1622,7 @@ func frame(context int) {
fmt.Printf("--- external frame ---\n") fmt.Printf("--- external frame ---\n")
l = externdcl l = externdcl
} else if Curfn != nil { } else if Curfn != nil {
fmt.Printf("--- %v frame ---\n", Curfn.Nname.Sym) fmt.Printf("--- %v frame ---\n", Curfn.Func.Nname.Sym)
l = Curfn.Func.Dcl l = Curfn.Func.Dcl
} else { } else {
return return
...@@ -2409,10 +2409,10 @@ func genwrapper(rcvr *Type, method *Type, newnam *Sym, iface int) { ...@@ -2409,10 +2409,10 @@ func genwrapper(rcvr *Type, method *Type, newnam *Sym, iface int) {
t.Rlist = out t.Rlist = out
fn := Nod(ODCLFUNC, nil, nil) fn := Nod(ODCLFUNC, nil, nil)
fn.Nname = newname(newnam) fn.Func.Nname = newname(newnam)
fn.Nname.Name.Defn = fn fn.Func.Nname.Name.Defn = fn
fn.Nname.Name.Param.Ntype = t fn.Func.Nname.Name.Param.Ntype = t
declare(fn.Nname, PFUNC) declare(fn.Func.Nname, PFUNC)
funchdr(fn) funchdr(fn)
// arg list // arg list
...@@ -2581,10 +2581,10 @@ func genhash(sym *Sym, t *Type) { ...@@ -2581,10 +2581,10 @@ func genhash(sym *Sym, t *Type) {
// func sym(p *T, h uintptr) uintptr // func sym(p *T, h uintptr) uintptr
fn := Nod(ODCLFUNC, nil, nil) fn := Nod(ODCLFUNC, nil, nil)
fn.Nname = newname(sym) fn.Func.Nname = newname(sym)
fn.Nname.Class = PFUNC fn.Func.Nname.Class = PFUNC
tfn := Nod(OTFUNC, nil, nil) tfn := Nod(OTFUNC, nil, nil)
fn.Nname.Name.Param.Ntype = tfn fn.Func.Nname.Name.Param.Ntype = tfn
n := Nod(ODCLFIELD, newname(Lookup("p")), typenod(Ptrto(t))) n := Nod(ODCLFIELD, newname(Lookup("p")), typenod(Ptrto(t)))
tfn.List = list(tfn.List, n) tfn.List = list(tfn.List, n)
...@@ -2596,7 +2596,7 @@ func genhash(sym *Sym, t *Type) { ...@@ -2596,7 +2596,7 @@ func genhash(sym *Sym, t *Type) {
tfn.Rlist = list(tfn.Rlist, n) tfn.Rlist = list(tfn.Rlist, n)
funchdr(fn) funchdr(fn)
typecheck(&fn.Nname.Name.Param.Ntype, Etype) typecheck(&fn.Func.Nname.Name.Param.Ntype, Etype)
// genhash is only called for types that have equality but // genhash is only called for types that have equality but
// cannot be handled by the standard algorithms, // cannot be handled by the standard algorithms,
...@@ -2833,10 +2833,10 @@ func geneq(sym *Sym, t *Type) { ...@@ -2833,10 +2833,10 @@ func geneq(sym *Sym, t *Type) {
// func sym(p, q *T) bool // func sym(p, q *T) bool
fn := Nod(ODCLFUNC, nil, nil) fn := Nod(ODCLFUNC, nil, nil)
fn.Nname = newname(sym) fn.Func.Nname = newname(sym)
fn.Nname.Class = PFUNC fn.Func.Nname.Class = PFUNC
tfn := Nod(OTFUNC, nil, nil) tfn := Nod(OTFUNC, nil, nil)
fn.Nname.Name.Param.Ntype = tfn fn.Func.Nname.Name.Param.Ntype = tfn
n := Nod(ODCLFIELD, newname(Lookup("p")), typenod(Ptrto(t))) n := Nod(ODCLFIELD, newname(Lookup("p")), typenod(Ptrto(t)))
tfn.List = list(tfn.List, n) tfn.List = list(tfn.List, n)
......
...@@ -123,6 +123,7 @@ type Func struct { ...@@ -123,6 +123,7 @@ type Func struct {
Top int // top context (Ecall, Eproc, etc) Top int // top context (Ecall, Eproc, etc)
Closure *Node // OCLOSURE <-> ODCLFUNC Closure *Node // OCLOSURE <-> ODCLFUNC
FCurfn *Node FCurfn *Node
Nname *Node
Inl *NodeList // copy of the body for use in inlining Inl *NodeList // copy of the body for use in inlining
InlCost int32 InlCost int32
......
...@@ -3465,16 +3465,16 @@ out: ...@@ -3465,16 +3465,16 @@ out:
* type check function definition * type check function definition
*/ */
func typecheckfunc(n *Node) { func typecheckfunc(n *Node) {
typecheck(&n.Nname, Erv|Easgn) typecheck(&n.Func.Nname, Erv|Easgn)
t := n.Nname.Type t := n.Func.Nname.Type
if t == nil { if t == nil {
return return
} }
n.Type = t n.Type = t
t.Nname = n.Nname t.Nname = n.Func.Nname
rcvr := getthisx(t).Type rcvr := getthisx(t).Type
if rcvr != nil && n.Func.Shortname != nil && !isblank(n.Func.Shortname) { if rcvr != nil && n.Func.Shortname != nil && !isblank(n.Func.Shortname) {
addmethod(n.Func.Shortname.Sym, t, true, n.Nname.Nointerface) addmethod(n.Func.Shortname.Sym, t, true, n.Func.Nname.Nointerface)
} }
for l := n.Func.Dcl; l != nil; l = l.Next { for l := n.Func.Dcl; l != nil; l = l.Next {
......
...@@ -21,7 +21,7 @@ func walk(fn *Node) { ...@@ -21,7 +21,7 @@ func walk(fn *Node) {
Curfn = fn Curfn = fn
if Debug['W'] != 0 { if Debug['W'] != 0 {
s := fmt.Sprintf("\nbefore %v", Curfn.Nname.Sym) s := fmt.Sprintf("\nbefore %v", Curfn.Func.Nname.Sym)
dumplist(s, Curfn.Nbody) dumplist(s, Curfn.Nbody)
} }
...@@ -65,13 +65,13 @@ func walk(fn *Node) { ...@@ -65,13 +65,13 @@ func walk(fn *Node) {
} }
walkstmtlist(Curfn.Nbody) walkstmtlist(Curfn.Nbody)
if Debug['W'] != 0 { if Debug['W'] != 0 {
s := fmt.Sprintf("after walk %v", Curfn.Nname.Sym) s := fmt.Sprintf("after walk %v", Curfn.Func.Nname.Sym)
dumplist(s, Curfn.Nbody) dumplist(s, Curfn.Nbody)
} }
heapmoves() heapmoves()
if Debug['W'] != 0 && Curfn.Func.Enter != nil { if Debug['W'] != 0 && Curfn.Func.Enter != nil {
s := fmt.Sprintf("enter %v", Curfn.Nname.Sym) s := fmt.Sprintf("enter %v", Curfn.Func.Nname.Sym)
dumplist(s, Curfn.Func.Enter) dumplist(s, Curfn.Func.Enter)
} }
} }
...@@ -615,7 +615,7 @@ func walkexpr(np **Node, init **NodeList) { ...@@ -615,7 +615,7 @@ func walkexpr(np **Node, init **NodeList) {
n.Left.Func.Enter = nil n.Left.Func.Enter = nil
// Replace OCLOSURE with ONAME/PFUNC. // Replace OCLOSURE with ONAME/PFUNC.
n.Left = n.Left.Func.Closure.Nname n.Left = n.Left.Func.Closure.Func.Nname
// Update type of OCALLFUNC node. // Update type of OCALLFUNC node.
// Output arguments had not changed, but their offsets could. // Output arguments had not changed, but their offsets could.
...@@ -1719,7 +1719,7 @@ func ascompatee(op int, nl *NodeList, nr *NodeList, init **NodeList) *NodeList { ...@@ -1719,7 +1719,7 @@ func ascompatee(op int, nl *NodeList, nr *NodeList, init **NodeList) *NodeList {
// cannot happen: caller checked that lists had same length // cannot happen: caller checked that lists had same length
if ll != nil || lr != nil { if ll != nil || lr != nil {
Yyerror("error in shape across %v %v %v / %d %d [%s]", Hconv(nl, obj.FmtSign), Oconv(int(op), 0), Hconv(nr, obj.FmtSign), count(nl), count(nr), Curfn.Nname.Sym.Name) Yyerror("error in shape across %v %v %v / %d %d [%s]", Hconv(nl, obj.FmtSign), Oconv(int(op), 0), Hconv(nr, obj.FmtSign), count(nl), count(nr), Curfn.Func.Nname.Sym.Name)
} }
return nn return nn
} }
...@@ -2687,7 +2687,7 @@ func paramstoheap(argin **Type, out int) *NodeList { ...@@ -2687,7 +2687,7 @@ func paramstoheap(argin **Type, out int) *NodeList {
} }
nn = list(nn, Nod(OAS, v.Name.Heapaddr, prealloc[v])) nn = list(nn, Nod(OAS, v.Name.Heapaddr, prealloc[v]))
if v.Class&^PHEAP != PPARAMOUT { if v.Class&^PHEAP != PPARAMOUT {
as = Nod(OAS, v, v.Name.Stackparam) as = Nod(OAS, v, v.Name.Param.Stackparam)
v.Name.Param.Stackparam.Typecheck = 1 v.Name.Param.Stackparam.Typecheck = 1
typecheck(&as, Etop) typecheck(&as, Etop)
as = applywritebarrier(as, &nn) as = applywritebarrier(as, &nn)
...@@ -4027,10 +4027,10 @@ func walkprintfunc(np **Node, init **NodeList) { ...@@ -4027,10 +4027,10 @@ func walkprintfunc(np **Node, init **NodeList) {
fn := Nod(ODCLFUNC, nil, nil) fn := Nod(ODCLFUNC, nil, nil)
walkprintfunc_prgen++ walkprintfunc_prgen++
buf = fmt.Sprintf("print·%d", walkprintfunc_prgen) buf = fmt.Sprintf("print·%d", walkprintfunc_prgen)
fn.Nname = newname(Lookup(buf)) fn.Func.Nname = newname(Lookup(buf))
fn.Nname.Name.Defn = fn fn.Func.Nname.Name.Defn = fn
fn.Nname.Name.Param.Ntype = t fn.Func.Nname.Name.Param.Ntype = t
declare(fn.Nname, PFUNC) declare(fn.Func.Nname, PFUNC)
oldfn := Curfn oldfn := Curfn
Curfn = nil Curfn = nil
...@@ -4051,7 +4051,7 @@ func walkprintfunc(np **Node, init **NodeList) { ...@@ -4051,7 +4051,7 @@ func walkprintfunc(np **Node, init **NodeList) {
Curfn = oldfn Curfn = oldfn
a = Nod(OCALL, nil, nil) a = Nod(OCALL, nil, nil)
a.Left = fn.Nname a.Left = fn.Func.Nname
a.List = n.List a.List = n.List
typecheck(&a, Etop) typecheck(&a, Etop)
walkexpr(&a, init) walkexpr(&a, init)
......
...@@ -2558,10 +2558,10 @@ yydefault: ...@@ -2558,10 +2558,10 @@ yydefault:
t.Rlist = yyDollar[5].list t.Rlist = yyDollar[5].list
yyVAL.node = Nod(ODCLFUNC, nil, nil) yyVAL.node = Nod(ODCLFUNC, nil, nil)
yyVAL.node.Nname = newfuncname(yyDollar[1].sym) yyVAL.node.Func.Nname = newfuncname(yyDollar[1].sym)
yyVAL.node.Nname.Name.Defn = yyVAL.node yyVAL.node.Func.Nname.Name.Defn = yyVAL.node
yyVAL.node.Nname.Name.Param.Ntype = t // TODO: check if nname already has an ntype yyVAL.node.Func.Nname.Name.Param.Ntype = t // TODO: check if nname already has an ntype
declare(yyVAL.node.Nname, PFUNC) declare(yyVAL.node.Func.Nname, PFUNC)
funchdr(yyVAL.node) funchdr(yyVAL.node)
} }
...@@ -2595,11 +2595,11 @@ yydefault: ...@@ -2595,11 +2595,11 @@ yydefault:
yyVAL.node = Nod(ODCLFUNC, nil, nil) yyVAL.node = Nod(ODCLFUNC, nil, nil)
yyVAL.node.Func.Shortname = newfuncname(yyDollar[4].sym) yyVAL.node.Func.Shortname = newfuncname(yyDollar[4].sym)
yyVAL.node.Nname = methodname1(yyVAL.node.Func.Shortname, rcvr.Right) yyVAL.node.Func.Nname = methodname1(yyVAL.node.Func.Shortname, rcvr.Right)
yyVAL.node.Nname.Name.Defn = yyVAL.node yyVAL.node.Func.Nname.Name.Defn = yyVAL.node
yyVAL.node.Nname.Name.Param.Ntype = t yyVAL.node.Func.Nname.Name.Param.Ntype = t
yyVAL.node.Nname.Nointerface = nointerface yyVAL.node.Func.Nname.Nointerface = nointerface
declare(yyVAL.node.Nname, PFUNC) declare(yyVAL.node.Func.Nname, PFUNC)
funchdr(yyVAL.node) funchdr(yyVAL.node)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment