mirror of
https://github.com/golang/go
synced 2024-11-18 06:14:46 -07:00
cmd/internal/gc: separate Node param fields
Param will be converted from an anonymous to a named field in a subsequent, automated CL. Reduces Node size from 368 to 328. Reduces inuse_space on the rotate tests by about 3%. No functional changes. Passes toolstash -cmp. Updates #9933. Change-Id: I5867b00328abf17ee24aea6ca58876bae9d8bfed Reviewed-on: https://go-review.googlesource.com/10210 Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
parent
ddc93398b9
commit
f4ab8203ba
@ -64,7 +64,7 @@ func autoexport(n *Node, ctxt uint8) {
|
||||
if (ctxt != PEXTERN && ctxt != PFUNC) || dclcontext != PEXTERN {
|
||||
return
|
||||
}
|
||||
if n.Ntype != nil && n.Ntype.Op == OTFUNC && n.Ntype.Left != nil { // method
|
||||
if n.Param != nil && n.Ntype != nil && n.Ntype.Op == OTFUNC && n.Ntype.Left != nil { // method
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -371,8 +371,12 @@ func Nod(op int, nleft *Node, nright *Node) *Node {
|
||||
switch op {
|
||||
case OCLOSURE, ODCLFUNC:
|
||||
n.Func = new(Func)
|
||||
n.Param = new(Param)
|
||||
case ONAME:
|
||||
n.Name = new(Name)
|
||||
n.Param = new(Param)
|
||||
case ODCLFIELD:
|
||||
n.Param = new(Param)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
@ -65,21 +65,12 @@ type Node struct {
|
||||
|
||||
// ONAME
|
||||
Name *Name
|
||||
Ntype *Node
|
||||
Defn *Node // ONAME: initializing assignment; OLABEL: labeled statement
|
||||
Pack *Node // real package for import . names
|
||||
Curfn *Node // function for local variables
|
||||
Paramfld *Type // TFIELD for this PPARAM; also for ODOT, curfn
|
||||
|
||||
// ONAME func param with PHEAP
|
||||
Outerexpr *Node // expression copied into closure for variable
|
||||
Stackparam *Node // OPARAM node referring to stack copy of param
|
||||
Alloc *Node // allocation call
|
||||
|
||||
// ONAME closure param with PPARAMREF
|
||||
Outer *Node // outer PPARAMREF in nested closure
|
||||
Closure *Node // ONAME/PHEAP <-> ONAME/PPARAMREF
|
||||
Top int // top context (Ecall, Eproc, etc)
|
||||
Alloc *Node // allocation call
|
||||
*Param
|
||||
|
||||
// OPACK
|
||||
Pkg *Pkg
|
||||
@ -115,6 +106,19 @@ type Name struct {
|
||||
Needzero bool // if it contains pointers, needs to be zeroed on function entry
|
||||
}
|
||||
|
||||
type Param struct {
|
||||
Ntype *Node
|
||||
|
||||
// ONAME func param with PHEAP
|
||||
Outerexpr *Node // expression copied into closure for variable
|
||||
Stackparam *Node // OPARAM node referring to stack copy of param
|
||||
|
||||
// ONAME closure param with PPARAMREF
|
||||
Outer *Node // outer PPARAMREF in nested closure
|
||||
Closure *Node // ONAME/PHEAP <-> ONAME/PPARAMREF
|
||||
Top int // top context (Ecall, Eproc, etc)
|
||||
}
|
||||
|
||||
// Func holds Node fields used only with function-like nodes.
|
||||
type Func struct {
|
||||
Shortname *Node
|
||||
|
@ -813,7 +813,7 @@ OpSwitch:
|
||||
var l *Node
|
||||
for l = n.Left; l != r; l = l.Left {
|
||||
l.Addrtaken = true
|
||||
if l.Closure != nil {
|
||||
if l.Param != nil && l.Closure != nil {
|
||||
l.Closure.Addrtaken = true
|
||||
}
|
||||
}
|
||||
@ -822,7 +822,7 @@ OpSwitch:
|
||||
Fatal("found non-orig name node %v", l)
|
||||
}
|
||||
l.Addrtaken = true
|
||||
if l.Closure != nil {
|
||||
if l.Param != nil && l.Closure != nil {
|
||||
l.Closure.Addrtaken = true
|
||||
}
|
||||
defaultlit(&n.Left, nil)
|
||||
@ -3273,13 +3273,13 @@ func checkassign(stmt *Node, n *Node) {
|
||||
var l *Node
|
||||
for l = n; l != r; l = l.Left {
|
||||
l.Assigned = true
|
||||
if l.Closure != nil {
|
||||
if l.Param != nil && l.Closure != nil {
|
||||
l.Closure.Assigned = true
|
||||
}
|
||||
}
|
||||
|
||||
l.Assigned = true
|
||||
if l.Closure != nil {
|
||||
if l.Param != nil && l.Closure != nil {
|
||||
l.Closure.Assigned = true
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user