]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/gc: more Node cleanups
authorDave Cheney <dave@cheney.net>
Mon, 9 Mar 2015 22:58:01 +0000 (09:58 +1100)
committerDave Cheney <dave@cheney.net>
Wed, 11 Mar 2015 02:58:03 +0000 (02:58 +0000)
More cleanups to gc.Node

- make Node.Local a boolean
- make Type.Local a boolean
- reduce the size of Node.Esc to a uint8

Reducing the size of Node.Esc shaves ~45mb off the RSS compiling cmd/internal/gc on amd64

before:
        Maximum resident set size (kbytes): 659496
after:
        Maximum resident set size (kbytes): 612196

- declare gc.Funcdepth as int32
- declare Node.Funcdepth as int32

In both cases, these were previously machine specific int types. This doesn't result in
any memory saving at the moment due to struct padding.

Change-Id: Iabef8da15e962fe8b79d7fd3d402fb26ce7ec31c
Reviewed-on: https://go-review.googlesource.com/7261
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/internal/gc/dcl.go
src/cmd/internal/gc/go.go
src/cmd/internal/gc/go.y
src/cmd/internal/gc/reflect.go
src/cmd/internal/gc/select.go
src/cmd/internal/gc/subr.go
src/cmd/internal/gc/syntax.go
src/cmd/internal/gc/walk.go
src/cmd/internal/gc/y.go

index cccdbdd6f09fad6d5dcad8e394e3e17712caa11b..7194c123a25acf57971200301a57460ef382f17d 100644 (file)
@@ -763,9 +763,9 @@ func typedcl0(s *Sym) *Node {
  * is being declared to have uncompiled type t.
  * return the ODCLTYPE node to use.
  */
-func typedcl1(n *Node, t *Node, local int) *Node {
+func typedcl1(n *Node, t *Node, local bool) *Node {
        n.Ntype = t
-       n.Local = uint8(local)
+       n.Local = local
        return Nod(ODCLTYPE, n, nil)
 }
 
@@ -1404,7 +1404,7 @@ func addmethod(sf *Sym, t *Type, local bool, nointerface bool) {
                }
        }
 
-       if local && pa.Local == 0 {
+       if local && !pa.Local {
                // defining method on non-local type.
                Yyerror("cannot define new methods on non-local type %v", Tconv(pa, 0))
 
index 6442eb6739a3981ab9541f28fad8bac6f2ffc1da..348dd833e0388d71d6637c372e5b09735d454fa0 100644 (file)
@@ -140,7 +140,7 @@ type Type struct {
        Siggen      uint8
        Funarg      uint8 // on TSTRUCT and TFIELD
        Copyany     uint8
-       Local       uint8 // created in this file
+       Local       bool // created in this file
        Deferwidth  uint8
        Broke       uint8 // broken type definition.
        Isddd       bool  // TFIELD is ... argument
@@ -661,7 +661,7 @@ var nhunk int32
 
 var thunk int32
 
-var Funcdepth int
+var Funcdepth int32
 
 var typecheckok int
 
index ba01f5be79d217708a3b1d08f9dd826b8f4eaa3d..bfdf781519d27d379992baf5ced4d5ce1919dc29 100644 (file)
@@ -404,7 +404,7 @@ typedclname:
 typedcl:
        typedclname ntype
        {
-               $$ = typedcl1($1, $2, 1);
+               $$ = typedcl1($1, $2, true);
        }
 
 simple_stmt:
index 36aa0b6749db14b27ca11e89aef007c4a83f2dcb..19694ad3d876e6f177a1073c878e3bae0324c7a9 100644 (file)
@@ -1000,7 +1000,7 @@ func dtypesym(t *Type) *Sym {
        }
 
        // named types from other files are defined only by those files
-       if tbase.Sym != nil && tbase.Local == 0 {
+       if tbase.Sym != nil && !tbase.Local {
                return s
        }
        if isforw[tbase.Etype] {
index 145d18688ff235162a43d003cb5c6c08e5a1c6d8..5816428debc2390a41f2ef21a724dca62df82998 100644 (file)
@@ -340,7 +340,7 @@ func selecttype(size int32) *Type {
        sudog.List = list(sudog.List, Nod(ODCLFIELD, newname(Lookup("waitlink")), typenod(Ptrto(Types[TUINT8]))))
        typecheck(&sudog, Etype)
        sudog.Type.Noalg = 1
-       sudog.Type.Local = 1
+       sudog.Type.Local = true
 
        scase := Nod(OTSTRUCT, nil, nil)
        scase.List = list(scase.List, Nod(ODCLFIELD, newname(Lookup("elem")), typenod(Ptrto(Types[TUINT8]))))
@@ -352,7 +352,7 @@ func selecttype(size int32) *Type {
        scase.List = list(scase.List, Nod(ODCLFIELD, newname(Lookup("releasetime")), typenod(Types[TUINT64])))
        typecheck(&scase, Etype)
        scase.Type.Noalg = 1
-       scase.Type.Local = 1
+       scase.Type.Local = true
 
        sel := Nod(OTSTRUCT, nil, nil)
        sel.List = list(sel.List, Nod(ODCLFIELD, newname(Lookup("tcase")), typenod(Types[TUINT16])))
@@ -367,7 +367,7 @@ func selecttype(size int32) *Type {
        sel.List = list(sel.List, Nod(ODCLFIELD, newname(Lookup("pollorderarr")), arr))
        typecheck(&sel, Etype)
        sel.Type.Noalg = 1
-       sel.Type.Local = 1
+       sel.Type.Local = true
 
        return sel.Type
 }
index 65881defbbe92cdeddfe36a52654e677ffbd2d6a..c59b7e6447e066658a799fcb1ddcc1cbf0a630d5 100644 (file)
@@ -2503,7 +2503,7 @@ func genwrapper(rcvr *Type, method *Type, newnam *Sym, iface int) {
 
        // Set inl_nonlocal to whether we are calling a method on a
        // type defined in a different package.  Checked in inlvar.
-       if methodrcvr.Local == 0 {
+       if !methodrcvr.Local {
                inl_nonlocal = 1
        }
 
index bd0f343c38e32eecdb4baf746bfd54fa36d5c741..442cc5cbd81beae20de9b56f5feaebaeea289799 100644 (file)
@@ -40,26 +40,26 @@ type Node struct {
        Nowritebarrier bool  // emit compiler error instead of write barrier
        Walkdef        uint8
        Typecheck      uint8
-       Local          uint8
+       Local          bool
        Dodata         uint8
        Initorder      uint8
        Used           bool
        Isddd          bool // is the argument variadic
        Readonly       bool
        Implicit       bool
-       Addrtaken      bool // address taken, even if not moved to heap
-       Assigned       bool // is the variable ever assigned to
-       Captured       bool // is the variable captured by a closure
-       Byval          bool // is the variable captured by value or by reference
-       Dupok          bool // duplicate definitions ok (for func)
-       Wrapper        bool // is method wrapper (for func)
-       Reslice        bool // this is a reslice x = x[0:y] or x = append(x, ...)
-       Likely         int8 // likeliness of if statement
-       Hasbreak       bool // has break statement
-       Needzero       bool // if it contains pointers, needs to be zeroed on function entry
-       Needctxt       bool // function uses context register (has closure variables)
-       Esc            uint // EscXXX
-       Funcdepth      int
+       Addrtaken      bool  // address taken, even if not moved to heap
+       Assigned       bool  // is the variable ever assigned to
+       Captured       bool  // is the variable captured by a closure
+       Byval          bool  // is the variable captured by value or by reference
+       Dupok          bool  // duplicate definitions ok (for func)
+       Wrapper        bool  // is method wrapper (for func)
+       Reslice        bool  // this is a reslice x = x[0:y] or x = append(x, ...)
+       Likely         int8  // likeliness of if statement
+       Hasbreak       bool  // has break statement
+       Needzero       bool  // if it contains pointers, needs to be zeroed on function entry
+       Needctxt       bool  // function uses context register (has closure variables)
+       Esc            uint8 // EscXXX
+       Funcdepth      int32
 
        // most nodes
        Type *Type
index c1156680e87a0b7c833d5b5a5077866b35137d48..af45015ccb3e82a3d2e3b6026a3ec923e937932e 100644 (file)
@@ -1757,9 +1757,9 @@ func ascompatet(op int, nl *NodeList, nr **Type, fp int, init **NodeList) *NodeL
 * package all the arguments that match a ... T parameter into a []T.
  */
 func mkdotargslice(lr0 *NodeList, nn *NodeList, l *Type, fp int, init **NodeList, ddd *Node) *NodeList {
-       esc := EscUnknown
+       esc := uint8(EscUnknown)
        if ddd != nil {
-               esc = int(ddd.Esc)
+               esc = ddd.Esc
        }
 
        tslice := typ(TARRAY)
@@ -1776,7 +1776,7 @@ func mkdotargslice(lr0 *NodeList, nn *NodeList, l *Type, fp int, init **NodeList
                        n.Alloc = ddd.Alloc // temporary to use
                }
                n.List = lr0
-               n.Esc = uint(esc)
+               n.Esc = esc
                typecheck(&n, Erv)
                if n.Type == nil {
                        Fatal("mkdotargslice: typecheck failed")
index 532ae39da80b312535e625d512065087c2cbcf83..4f97439b22b9af063aea2e608cd6441a43eba3bb 100644 (file)
@@ -1416,7 +1416,7 @@ yydefault:
                yyDollar = yyS[yypt-2 : yypt+1]
                //line go.y:406
                {
-                       yyVAL.node = typedcl1(yyDollar[1].node, yyDollar[2].node, 1)
+                       yyVAL.node = typedcl1(yyDollar[1].node, yyDollar[2].node, true)
                }
        case 49:
                yyDollar = yyS[yypt-1 : yypt+1]