Skip to content

Commit bd8bb67

Browse files
committed
cmd/internal/gc: unembed Param field
This is an automated follow-up to CL 10210. It was generated with a combination of eg and gofmt -r. No functional changes. Passes toolstash -cmp. Change-Id: I35f5897948a270b472d8cf80612071b4b29e9a2b Reviewed-on: https://go-review.googlesource.com/10253 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
1 parent f2c3957 commit bd8bb67

File tree

17 files changed

+106
-106
lines changed

17 files changed

+106
-106
lines changed

src/cmd/compile/internal/gc/align.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ func widstruct(errtype *Type, t *Type, o int64, flag int) int64 {
7171
// in typecheck.c. usually addrescapes runs after
7272
// widstruct, in which case we could drop this,
7373
// but function closure functions are the exception.
74-
if f.Nname.Stackparam != nil {
75-
f.Nname.Stackparam.Xoffset = o
74+
if f.Nname.Param.Stackparam != nil {
75+
f.Nname.Param.Stackparam.Xoffset = o
7676
f.Nname.Xoffset = 0
7777
} else {
7878
f.Nname.Xoffset = o

src/cmd/compile/internal/gc/closure.go

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func closurehdr(ntype *Node) {
1717
var a *Node
1818

1919
n := Nod(OCLOSURE, nil, nil)
20-
n.Ntype = ntype
20+
n.Param.Ntype = ntype
2121
n.Funcdepth = Funcdepth
2222
n.Func.Outerfunc = Curfn
2323

@@ -72,8 +72,8 @@ func closurebody(body *NodeList) *Node {
7272
var v *Node
7373
for l := func_.Func.Cvars; l != nil; l = l.Next {
7474
v = l.N
75-
v.Closure.Closure = v.Outer
76-
v.Outerexpr = oldname(v.Sym)
75+
v.Param.Closure.Param.Closure = v.Param.Outer
76+
v.Param.Outerexpr = oldname(v.Sym)
7777
}
7878

7979
return func_
@@ -83,7 +83,7 @@ func typecheckclosure(func_ *Node, top int) {
8383
var n *Node
8484

8585
for l := func_.Func.Cvars; l != nil; l = l.Next {
86-
n = l.N.Closure
86+
n = l.N.Param.Closure
8787
if !n.Name.Captured {
8888
n.Name.Captured = true
8989
if n.Name.Decldepth == 0 {
@@ -105,9 +105,9 @@ func typecheckclosure(func_ *Node, top int) {
105105
}
106106

107107
oldfn := Curfn
108-
typecheck(&func_.Ntype, Etype)
109-
func_.Type = func_.Ntype.Type
110-
func_.Top = top
108+
typecheck(&func_.Param.Ntype, Etype)
109+
func_.Type = func_.Param.Ntype.Type
110+
func_.Param.Top = top
111111

112112
// Type check the body now, but only if we're inside a function.
113113
// At top level (in a variable initialization: curfn==nil) we're not
@@ -193,7 +193,7 @@ func makeclosure(func_ *Node) *Node {
193193

194194
xfunc.Nname = newfuncname(closurename(func_))
195195
xfunc.Nname.Sym.Flags |= SymExported // disable export
196-
xfunc.Nname.Ntype = xtype
196+
xfunc.Nname.Param.Ntype = xtype
197197
xfunc.Nname.Defn = xfunc
198198
declare(xfunc.Nname, PFUNC)
199199
xfunc.Nname.Funcdepth = func_.Funcdepth
@@ -207,8 +207,8 @@ func makeclosure(func_ *Node) *Node {
207207
}
208208
typecheck(&xfunc, Etop)
209209

210-
xfunc.Closure = func_
211-
func_.Closure = xfunc
210+
xfunc.Param.Closure = func_
211+
func_.Param.Closure = xfunc
212212

213213
func_.Nbody = nil
214214
func_.List = nil
@@ -229,7 +229,7 @@ func capturevars(xfunc *Node) {
229229
lno := int(lineno)
230230
lineno = xfunc.Lineno
231231

232-
func_ := xfunc.Closure
232+
func_ := xfunc.Param.Closure
233233
func_.Func.Enter = nil
234234
for l := func_.Func.Cvars; l != nil; l = l.Next {
235235
v = l.N
@@ -249,14 +249,14 @@ func capturevars(xfunc *Node) {
249249
// so that the outer frame also grabs them and knows they escape.
250250
dowidth(v.Type)
251251

252-
outer = v.Outerexpr
253-
v.Outerexpr = nil
252+
outer = v.Param.Outerexpr
253+
v.Param.Outerexpr = nil
254254

255255
// out parameters will be assigned to implicitly upon return.
256-
if outer.Class != PPARAMOUT && !v.Closure.Addrtaken && !v.Closure.Assigned && v.Type.Width <= 128 {
256+
if outer.Class != PPARAMOUT && !v.Param.Closure.Addrtaken && !v.Param.Closure.Assigned && v.Type.Width <= 128 {
257257
v.Name.Byval = true
258258
} else {
259-
v.Closure.Addrtaken = true
259+
v.Param.Closure.Addrtaken = true
260260
outer = Nod(OADDR, outer, nil)
261261
}
262262

@@ -269,7 +269,7 @@ func capturevars(xfunc *Node) {
269269
if v.Name.Byval {
270270
how = "value"
271271
}
272-
Warnl(int(v.Lineno), "%v capturing by %s: %v (addr=%v assign=%v width=%d)", name, how, v.Sym, v.Closure.Addrtaken, v.Closure.Assigned, int32(v.Type.Width))
272+
Warnl(int(v.Lineno), "%v capturing by %s: %v (addr=%v assign=%v width=%d)", name, how, v.Sym, v.Param.Closure.Addrtaken, v.Param.Closure.Assigned, int32(v.Type.Width))
273273
}
274274

275275
typecheck(&outer, Erv)
@@ -284,9 +284,9 @@ func capturevars(xfunc *Node) {
284284
func transformclosure(xfunc *Node) {
285285
lno := int(lineno)
286286
lineno = xfunc.Lineno
287-
func_ := xfunc.Closure
287+
func_ := xfunc.Param.Closure
288288

289-
if func_.Top&Ecall != 0 {
289+
if func_.Param.Top&Ecall != 0 {
290290
// If the closure is directly called, we transform it to a plain function call
291291
// with variables passed as args. This avoids allocation of a closure object.
292292
// Here we do only a part of the transformation. Walk of OCALLFUNC(OCLOSURE)
@@ -395,7 +395,7 @@ func transformclosure(xfunc *Node) {
395395
// Declare variable holding addresses taken from closure
396396
// and initialize in entry prologue.
397397
addr = newname(Lookupf("&%s", v.Sym.Name))
398-
addr.Ntype = Nod(OIND, typenod(v.Type), nil)
398+
addr.Param.Ntype = Nod(OIND, typenod(v.Type), nil)
399399
addr.Class = PAUTO
400400
addr.Used = true
401401
addr.Curfn = xfunc
@@ -420,7 +420,7 @@ func transformclosure(xfunc *Node) {
420420
func walkclosure(func_ *Node, init **NodeList) *Node {
421421
// If no closure vars, don't bother wrapping.
422422
if func_.Func.Cvars == nil {
423-
return func_.Closure.Nname
423+
return func_.Param.Closure.Nname
424424
}
425425

426426
// Create closure in the form of a composite literal.
@@ -457,7 +457,7 @@ func walkclosure(func_ *Node, init **NodeList) *Node {
457457
clos := Nod(OCOMPLIT, nil, Nod(OIND, typ, nil))
458458
clos.Esc = func_.Esc
459459
clos.Right.Implicit = true
460-
clos.List = concat(list1(Nod(OCFUNC, func_.Closure.Nname, nil)), func_.Func.Enter)
460+
clos.List = concat(list1(Nod(OCFUNC, func_.Param.Closure.Nname, nil)), func_.Func.Enter)
461461

462462
// Force type conversion from *struct to the func type.
463463
clos = Nod(OCONVNOP, clos, nil)
@@ -583,7 +583,7 @@ func makepartialcall(fn *Node, t0 *Type, meth *Node) *Node {
583583
xfunc.Func.Dupok = true
584584
xfunc.Nname = newfuncname(sym)
585585
xfunc.Nname.Sym.Flags |= SymExported // disable export
586-
xfunc.Nname.Ntype = xtype
586+
xfunc.Nname.Param.Ntype = xtype
587587
xfunc.Nname.Defn = xfunc
588588
declare(xfunc.Nname, PFUNC)
589589

@@ -606,10 +606,10 @@ func makepartialcall(fn *Node, t0 *Type, meth *Node) *Node {
606606
xfunc.Func.Dcl = list(xfunc.Func.Dcl, ptr)
607607
var body *NodeList
608608
if Isptr[rcvrtype.Etype] || Isinter(rcvrtype) {
609-
ptr.Ntype = typenod(rcvrtype)
609+
ptr.Param.Ntype = typenod(rcvrtype)
610610
body = list(body, Nod(OAS, ptr, cv))
611611
} else {
612-
ptr.Ntype = typenod(Ptrto(rcvrtype))
612+
ptr.Param.Ntype = typenod(Ptrto(rcvrtype))
613613
body = list(body, Nod(OAS, ptr, Nod(OADDR, cv, nil)))
614614
}
615615

src/cmd/compile/internal/gc/dcl.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ func variter(vl *NodeList, t *Node, el *NodeList) *NodeList {
260260
v = vl.N
261261
v.Op = ONAME
262262
declare(v, dclcontext)
263-
v.Ntype = t
263+
v.Param.Ntype = t
264264
v.Defn = as2
265265
if Funcdepth > 0 {
266266
init = list(init, Nod(ODCL, v, nil))
@@ -288,7 +288,7 @@ func variter(vl *NodeList, t *Node, el *NodeList) *NodeList {
288288
v = vl.N
289289
v.Op = ONAME
290290
declare(v, dclcontext)
291-
v.Ntype = t
291+
v.Param.Ntype = t
292292

293293
if e != nil || Funcdepth > 0 || isblank(v) {
294294
if Funcdepth > 0 {
@@ -343,7 +343,7 @@ func constiter(vl *NodeList, t *Node, cl *NodeList) *NodeList {
343343
v.Op = OLITERAL
344344
declare(v, dclcontext)
345345

346-
v.Ntype = t
346+
v.Param.Ntype = t
347347
v.Defn = c
348348

349349
vv = list(vv, Nod(ODCLCONST, v, nil))
@@ -431,7 +431,7 @@ func oldname(s *Sym) *Node {
431431
// are parsing x := 5 inside the closure, until we get to
432432
// the := it looks like a reference to the outer x so we'll
433433
// make x a closure variable unnecessarily.
434-
if n.Closure == nil || n.Closure.Funcdepth != Funcdepth {
434+
if n.Param.Closure == nil || n.Param.Closure.Funcdepth != Funcdepth {
435435
// create new closure var.
436436
c := Nod(ONAME, nil, nil)
437437

@@ -442,15 +442,15 @@ func oldname(s *Sym) *Node {
442442
c.Addable = false
443443
c.Ullman = 2
444444
c.Funcdepth = Funcdepth
445-
c.Outer = n.Closure
446-
n.Closure = c
447-
c.Closure = n
445+
c.Param.Outer = n.Param.Closure
446+
n.Param.Closure = c
447+
c.Param.Closure = n
448448
c.Xoffset = 0
449449
Curfn.Func.Cvars = list(Curfn.Func.Cvars, c)
450450
}
451451

452452
// return ref to closure var, not original
453-
return n.Closure
453+
return n.Param.Closure
454454
}
455455

456456
return n
@@ -555,7 +555,7 @@ func ifacedcl(n *Node) {
555555
dclcontext = PPARAM
556556
markdcl()
557557
Funcdepth++
558-
n.Outer = Curfn
558+
n.Param.Outer = Curfn
559559
Curfn = n
560560
funcargs(n.Right)
561561

@@ -584,13 +584,13 @@ func funchdr(n *Node) {
584584
markdcl()
585585
Funcdepth++
586586

587-
n.Outer = Curfn
587+
n.Param.Outer = Curfn
588588
Curfn = n
589589

590590
if n.Nname != nil {
591-
funcargs(n.Nname.Ntype)
592-
} else if n.Ntype != nil {
593-
funcargs(n.Ntype)
591+
funcargs(n.Nname.Param.Ntype)
592+
} else if n.Param.Ntype != nil {
593+
funcargs(n.Param.Ntype)
594594
} else {
595595
funcargs2(n.Type)
596596
}
@@ -616,7 +616,7 @@ func funcargs(nt *Node) {
616616
}
617617
if n.Left != nil {
618618
n.Left.Op = ONAME
619-
n.Left.Ntype = n.Right
619+
n.Left.Param.Ntype = n.Right
620620
declare(n.Left, PPARAM)
621621
if dclcontext == PAUTO {
622622
vargen++
@@ -633,7 +633,7 @@ func funcargs(nt *Node) {
633633
}
634634
if n.Left != nil {
635635
n.Left.Op = ONAME
636-
n.Left.Ntype = n.Right
636+
n.Left.Param.Ntype = n.Right
637637
declare(n.Left, PPARAM)
638638
if dclcontext == PAUTO {
639639
vargen++
@@ -680,7 +680,7 @@ func funcargs(nt *Node) {
680680
n.Left = nn
681681
}
682682

683-
n.Left.Ntype = n.Right
683+
n.Left.Param.Ntype = n.Right
684684
declare(n.Left, PPARAMOUT)
685685
if dclcontext == PAUTO {
686686
i++
@@ -748,8 +748,8 @@ func funcbody(n *Node) {
748748
}
749749
popdcl()
750750
Funcdepth--
751-
Curfn = n.Outer
752-
n.Outer = nil
751+
Curfn = n.Param.Outer
752+
n.Param.Outer = nil
753753
if Funcdepth == 0 {
754754
dclcontext = PEXTERN
755755
}
@@ -771,7 +771,7 @@ func typedcl0(s *Sym) *Node {
771771
* return the ODCLTYPE node to use.
772772
*/
773773
func typedcl1(n *Node, t *Node, local bool) *Node {
774-
n.Ntype = t
774+
n.Param.Ntype = t
775775
n.Local = local
776776
return Nod(ODCLTYPE, n, nil)
777777
}

src/cmd/compile/internal/gc/esc.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ func (v *bottomUpVisitor) visitcode(n *Node, min uint32) uint32 {
154154
}
155155

156156
if n.Op == OCLOSURE {
157-
m := v.visit(n.Closure)
157+
m := v.visit(n.Param.Closure)
158158
if m < min {
159159
min = m
160160
}
@@ -849,7 +849,7 @@ func esc(e *EscState, n *Node, up *Node) {
849849
if v.Op == OXXX { // unnamed out argument; see dcl.c:/^funcargs
850850
continue
851851
}
852-
a = v.Closure
852+
a = v.Param.Closure
853853
if !v.Name.Byval {
854854
a = Nod(OADDR, a, nil)
855855
a.Lineno = v.Lineno
@@ -1363,7 +1363,7 @@ func esccall(e *EscState, n *Node, up *Node) {
13631363
}
13641364

13651365
if fn != nil && fn.Op == ONAME && fn.Class == PFUNC &&
1366-
fn.Defn != nil && fn.Defn.Nbody != nil && fn.Ntype != nil && fn.Defn.Esc < EscFuncTagged {
1366+
fn.Defn != nil && fn.Defn.Nbody != nil && fn.Param.Ntype != nil && fn.Defn.Esc < EscFuncTagged {
13671367
if Debug['m'] > 2 {
13681368
fmt.Printf("%v::esccall:: %v in recursive group\n", Ctxt.Line(int(lineno)), Nconv(n, obj.FmtShort))
13691369
}
@@ -1375,17 +1375,17 @@ func esccall(e *EscState, n *Node, up *Node) {
13751375
}
13761376

13771377
// set up out list on this call node
1378-
for lr := fn.Ntype.Rlist; lr != nil; lr = lr.Next {
1378+
for lr := fn.Param.Ntype.Rlist; lr != nil; lr = lr.Next {
13791379
n.Escretval = list(n.Escretval, lr.N.Left) // type.rlist -> dclfield -> ONAME (PPARAMOUT)
13801380
}
13811381

13821382
// Receiver.
13831383
if n.Op != OCALLFUNC {
1384-
escassign(e, fn.Ntype.Left.Left, n.Left.Left)
1384+
escassign(e, fn.Param.Ntype.Left.Left, n.Left.Left)
13851385
}
13861386

13871387
var src *Node
1388-
for lr := fn.Ntype.List; ll != nil && lr != nil; ll, lr = ll.Next, lr.Next {
1388+
for lr := fn.Param.Ntype.List; ll != nil && lr != nil; ll, lr = ll.Next, lr.Next {
13891389
src = ll.N
13901390
if lr.N.Isddd && !n.Isddd {
13911391
// Introduce ODDDARG node to represent ... allocation.
@@ -1653,7 +1653,7 @@ func escwalk(e *EscState, level Level, dst *Node, src *Node) {
16531653
if leaks && Debug['m'] != 0 {
16541654
Warnl(int(src.Lineno), "leaking closure reference %v", Nconv(src, obj.FmtShort))
16551655
}
1656-
escwalk(e, level, dst, src.Closure)
1656+
escwalk(e, level, dst, src.Param.Closure)
16571657
}
16581658

16591659
case OPTRLIT, OADDR:

src/cmd/compile/internal/gc/export.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func autoexport(n *Node, ctxt uint8) {
6464
if (ctxt != PEXTERN && ctxt != PFUNC) || dclcontext != PEXTERN {
6565
return
6666
}
67-
if n.Param != nil && n.Ntype != nil && n.Ntype.Op == OTFUNC && n.Ntype.Left != nil { // method
67+
if n.Param != nil && n.Param.Ntype != nil && n.Param.Ntype.Op == OTFUNC && n.Param.Ntype.Left != nil { // method
6868
return
6969
}
7070

src/cmd/compile/internal/gc/fmt.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,7 +1199,7 @@ func exprfmt(n *Node, prec int) string {
11991199
if n.Nbody != nil {
12001200
return fmt.Sprintf("%v { %v }", n.Type, n.Nbody)
12011201
}
1202-
return fmt.Sprintf("%v { %v }", n.Type, n.Closure.Nbody)
1202+
return fmt.Sprintf("%v { %v }", n.Type, n.Param.Closure.Nbody)
12031203

12041204
case OCOMPLIT:
12051205
ptrlit := n.Right != nil && n.Right.Implicit && n.Right.Type != nil && Isptr[n.Right.Type.Etype]
@@ -1521,19 +1521,19 @@ func nodedump(n *Node, flag int) string {
15211521
} else {
15221522
fmt.Fprintf(&buf, "%v%v", Oconv(int(n.Op), 0), Jconv(n, 0))
15231523
}
1524-
if recur && n.Type == nil && n.Ntype != nil {
1524+
if recur && n.Type == nil && n.Param.Ntype != nil {
15251525
indent(&buf)
1526-
fmt.Fprintf(&buf, "%v-ntype%v", Oconv(int(n.Op), 0), n.Ntype)
1526+
fmt.Fprintf(&buf, "%v-ntype%v", Oconv(int(n.Op), 0), n.Param.Ntype)
15271527
}
15281528

15291529
case OASOP:
15301530
fmt.Fprintf(&buf, "%v-%v%v", Oconv(int(n.Op), 0), Oconv(int(n.Etype), 0), Jconv(n, 0))
15311531

15321532
case OTYPE:
15331533
fmt.Fprintf(&buf, "%v %v%v type=%v", Oconv(int(n.Op), 0), n.Sym, Jconv(n, 0), n.Type)
1534-
if recur && n.Type == nil && n.Ntype != nil {
1534+
if recur && n.Type == nil && n.Param.Ntype != nil {
15351535
indent(&buf)
1536-
fmt.Fprintf(&buf, "%v-ntype%v", Oconv(int(n.Op), 0), n.Ntype)
1536+
fmt.Fprintf(&buf, "%v-ntype%v", Oconv(int(n.Op), 0), n.Param.Ntype)
15371537
}
15381538
}
15391539

0 commit comments

Comments
 (0)