]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: move Node.Paramfld to Node.Param.Field
authorRuss Cox <rsc@golang.org>
Wed, 27 May 2015 01:49:31 +0000 (21:49 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 3 Jun 2015 17:50:28 +0000 (17:50 +0000)
$ sizeof -p cmd/compile/internal/gc Node
Node 264
$

Change-Id: I5c90089dcf5df51c874250f28a1bc3ec32f764b9
Reviewed-on: https://go-review.googlesource.com/10522
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
src/cmd/compile/internal/gc/dcl.go
src/cmd/compile/internal/gc/esc.go
src/cmd/compile/internal/gc/pgen.go
src/cmd/compile/internal/gc/syntax.go
src/cmd/compile/internal/gc/typecheck.go
src/cmd/compile/internal/gc/walk.go

index 4a9cb295c8dd79e8e5b93ecb0e51159c18929103..35c4c4b1ba6debd44586922a274ff12610c9a9c3 100644 (file)
@@ -913,7 +913,7 @@ func tofunargs(l *NodeList) *Type {
 
                // esc.c needs to find f given a PPARAM to add the tag.
                if l.N.Left != nil && l.N.Left.Class == PPARAM {
-                       l.N.Left.Paramfld = f
+                       l.N.Left.Param.Field = f
                }
 
                *tp = f
index f9d83a2b53cc4444118268beed9634a6ba8b1d39..d6ebf13eb95033b6d33707d1379c686ee15b33ca 100644 (file)
@@ -1774,7 +1774,7 @@ func esctag(e *EscState, func_ *Node) {
                case EscNone, // not touched by escflood
                        EscReturn:
                        if haspointers(ll.N.Type) { // don't bother tagging for scalars
-                               ll.N.Paramfld.Note = mktag(int(ll.N.Esc))
+                               ll.N.Param.Field.Note = mktag(int(ll.N.Esc))
                        }
 
                case EscHeap, // touched by escflood, moved to heap
index 815f723b20c1c95bf54fbc16f301d7cb87c7c3ac..7ed661f045836375e5ffbc3d56dbe9e206d38777 100644 (file)
@@ -448,8 +448,8 @@ func compile(fn *Node) {
        gcargs = makefuncdatasym("gcargs·%d", obj.FUNCDATA_ArgsPointerMaps)
        gclocals = makefuncdatasym("gclocals·%d", obj.FUNCDATA_LocalsPointerMaps)
 
-       for t := Curfn.Paramfld; t != nil; t = t.Down {
-               gtrack(tracksym(t.Type))
+       for _, t := range Curfn.Func.Fieldtrack {
+               gtrack(tracksym(t))
        }
 
        for l := fn.Func.Dcl; l != nil; l = l.Next {
index f8f224818559e72a9b94475a99b92f1b89a8db55..eb368a3f66ba17baf078d78a3f36917ca9e27aff 100644 (file)
@@ -29,19 +29,16 @@ type Node struct {
        Func *Func
 
        // ONAME
-       Name     *Name
-       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
-       Alloc    *Node // allocation call
-       Param    *Param
+       Name  *Name
+       Defn  *Node // ONAME: initializing assignment; OLABEL: labeled statement
+       Pack  *Node // real package for import . names
+       Curfn *Node // function for local variables
+       Alloc *Node // allocation call
+       Param *Param
 
        // OPACK
        Pkg *Pkg
 
-       // OARRAYLIT, OMAPLIT, OSTRUCTLIT.
-
        // Escape analysis.
        Escflowsrc *NodeList // flow(this, src)
        Escretval  *NodeList // on OCALLxxx, list of dummy return values
@@ -116,6 +113,9 @@ type Param struct {
        Outerexpr  *Node // expression copied into closure for variable
        Stackparam *Node // OPARAM node referring to stack copy of param
 
+       // ONAME PPARAM
+       Field *Type // TFIELD in arg struct
+
        // ONAME closure param with PPARAMREF
        Outer   *Node // outer PPARAMREF in nested closure
        Closure *Node // ONAME/PHEAP <-> ONAME/PPARAMREF
@@ -124,14 +124,15 @@ type Param struct {
 
 // Func holds Node fields used only with function-like nodes.
 type Func struct {
-       Shortname *Node
-       Enter     *NodeList
-       Exit      *NodeList
-       Cvars     *NodeList // closure params
-       Dcl       *NodeList // autodcl for this func/closure
-       Inldcl    *NodeList // copy of dcl for use in inlining
-       Closgen   int
-       Outerfunc *Node
+       Shortname  *Node
+       Enter      *NodeList
+       Exit       *NodeList
+       Cvars      *NodeList // closure params
+       Dcl        *NodeList // autodcl for this func/closure
+       Inldcl     *NodeList // copy of dcl for use in inlining
+       Closgen    int
+       Outerfunc  *Node
+       Fieldtrack []*Type
 
        Inl     *NodeList // copy of the body for use in inlining
        InlCost int32
index 351f26f157bcfdd82646bf84e1b29d0c037ab154..490468f3b439607c121e82bfeb3d49dfe03ee23b 100644 (file)
@@ -2489,6 +2489,15 @@ func derefall(t *Type) *Type {
        return t
 }
 
+type typeSym struct {
+       t *Type
+       s *Sym
+}
+
+// dotField maps (*Type, *Sym) pairs to the corresponding struct field (*Type with Etype==TFIELD).
+// It is a cache for use during usefield in walk.go, only enabled when field tracking.
+var dotField = map[typeSym]*Type{}
+
 func lookdot(n *Node, t *Type, dostrcmp int) *Type {
        s := n.Right.Sym
 
@@ -2521,7 +2530,9 @@ func lookdot(n *Node, t *Type, dostrcmp int) *Type {
                }
                n.Xoffset = f1.Width
                n.Type = f1.Type
-               n.Paramfld = f1
+               if obj.Fieldtrack_enabled > 0 {
+                       dotField[typeSym{t, s}] = f1
+               }
                if t.Etype == TINTER {
                        if Isptr[n.Left.Type.Etype] {
                                n.Left = Nod(OIND, n.Left, nil) // implicitstar
index cd7db023923d68a916b2510d609c9d03c3cca19c..442f746520eb5bbc44b09b3392b567cd516073aa 100644 (file)
@@ -3857,7 +3857,11 @@ func usefield(n *Node) {
                break
        }
 
-       field := n.Paramfld
+       t := n.Left.Type
+       if Isptr[t.Etype] {
+               t = t.Type
+       }
+       field := dotField[typeSym{t, n.Right.Sym}]
        if field == nil {
                Fatal("usefield %v %v without paramfld", n.Left.Type, n.Right.Sym)
        }
@@ -3881,10 +3885,7 @@ func usefield(n *Node) {
                Yyerror("tracked field must be exported (upper case)")
        }
 
-       l := typ(0)
-       l.Type = field
-       l.Down = Curfn.Paramfld
-       Curfn.Paramfld = l
+       Curfn.Func.Fieldtrack = append(Curfn.Func.Fieldtrack, field)
 }
 
 func candiscardlist(l *NodeList) bool {