]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/gc: separate Node param fields
authorJosh Bleecher Snyder <josharian@gmail.com>
Mon, 18 May 2015 17:27:59 +0000 (10:27 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Mon, 18 May 2015 22:18:29 +0000 (22:18 +0000)
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>
src/cmd/internal/gc/export.go
src/cmd/internal/gc/subr.go
src/cmd/internal/gc/syntax.go
src/cmd/internal/gc/typecheck.go

index 1efc8150c51f5ecc4964bc569cc195058b98c7e9..614de4e2ce1563e3979fcd0dbd50b7cbfe2278bd 100644 (file)
@@ -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
        }
 
index 33741c3baf514e472743210a68faa98b78c9ca20..b10a6b3d3d0d6dfe532208d4abf37bc97f2f90e2 100644 (file)
@@ -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
 }
index d4ede60c900ad3ebcc8289a9f96a00cc0bda4e88..d52a3d4fe77e60937d40ed681252e2d3db42dfcc 100644 (file)
@@ -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
index 06f8b34305e0c78664de99d51fdf20ea2833db6e..8af9f084e2368f5626610d98eab11e727d560563 100644 (file)
@@ -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
                }
        }