]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: skip reexporting types in reexportdep
authorMatthew Dempsky <mdempsky@google.com>
Thu, 2 Feb 2017 00:40:46 +0000 (16:40 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Thu, 2 Feb 2017 04:25:40 +0000 (04:25 +0000)
The binary export format embeds type definitions inline as necessary,
so there's no need to add them to exportlist. Also, constants are
embedded directly by value, so they can be omitted too.

Change-Id: Id1879eb97c298a5a52f615cf9883c346c7f7bd69
Reviewed-on: https://go-review.googlesource.com/36170
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/cmd/compile/internal/gc/bexport.go
src/cmd/compile/internal/gc/export.go

index 06bb6975a9d25685f5e7702fcb32543217b37f71..a8f5c3bda0ce5700e7907227a6027ee0c57315b6 100644 (file)
@@ -517,13 +517,6 @@ func (p *exporter) obj(sym *Sym) {
                        var f *Func
                        if inlineable {
                                f = sym.Def.Func
-                               // TODO(gri) re-examine reexportdeplist:
-                               // Because we can trivially export types
-                               // in-place, we don't need to collect types
-                               // inside function bodies in the exportlist.
-                               // With an adjusted reexportdeplist used only
-                               // by the binary exporter, we can also avoid
-                               // the global exportlist.
                                reexportdeplist(f.Inl)
                        }
                        p.funcList = append(p.funcList, f)
@@ -714,7 +707,7 @@ func (p *exporter) typ(t *Type) {
                        var f *Func
                        if inlineable {
                                f = mfn.Func
-                               reexportdeplist(mfn.Func.Inl)
+                               reexportdeplist(f.Inl)
                        }
                        p.funcList = append(p.funcList, f)
                }
index 58b2bf8121bf73cace44cd7cf1d18099c3b27024..342d1bbda0c018fa3fc145462bc8364c5988399f 100644 (file)
@@ -108,7 +108,6 @@ func reexportdep(n *Node) {
                return
        }
 
-       //print("reexportdep %+hN\n", n);
        switch n.Op {
        case ONAME:
                switch n.Class {
@@ -133,78 +132,6 @@ func reexportdep(n *Node) {
                                exportlist = append(exportlist, n)
                        }
                }
-
-       // Local variables in the bodies need their type.
-       case ODCL:
-               t := n.Left.Type
-
-               if t != Types[t.Etype] && t != idealbool && t != idealstring {
-                       if t.IsPtr() {
-                               t = t.Elem()
-                       }
-                       if t != nil && t.Sym != nil && t.Sym.Def != nil && !exportedsym(t.Sym) {
-                               if Debug['E'] != 0 {
-                                       fmt.Printf("reexport type %v from declaration\n", t.Sym)
-                               }
-                               exportlist = append(exportlist, t.Sym.Def)
-                       }
-               }
-
-       case OLITERAL:
-               t := n.Type
-               if t != Types[n.Type.Etype] && t != idealbool && t != idealstring {
-                       if t.IsPtr() {
-                               t = t.Elem()
-                       }
-                       if t != nil && t.Sym != nil && t.Sym.Def != nil && !exportedsym(t.Sym) {
-                               if Debug['E'] != 0 {
-                                       fmt.Printf("reexport literal type %v\n", t.Sym)
-                               }
-                               exportlist = append(exportlist, t.Sym.Def)
-                       }
-               }
-               fallthrough
-
-       case OTYPE:
-               if n.Sym != nil && n.Sym.Def != nil && !exportedsym(n.Sym) {
-                       if Debug['E'] != 0 {
-                               fmt.Printf("reexport literal/type %v\n", n.Sym)
-                       }
-                       exportlist = append(exportlist, n)
-               }
-
-       // for operations that need a type when rendered, put the type on the export list.
-       case OCONV,
-               OCONVIFACE,
-               OCONVNOP,
-               ORUNESTR,
-               OARRAYBYTESTR,
-               OARRAYRUNESTR,
-               OSTRARRAYBYTE,
-               OSTRARRAYRUNE,
-               ODOTTYPE,
-               ODOTTYPE2,
-               OSTRUCTLIT,
-               OARRAYLIT,
-               OSLICELIT,
-               OPTRLIT,
-               OMAKEMAP,
-               OMAKESLICE,
-               OMAKECHAN:
-               t := n.Type
-
-               switch t.Etype {
-               case TARRAY, TCHAN, TPTR32, TPTR64, TSLICE:
-                       if t.Sym == nil {
-                               t = t.Elem()
-                       }
-               }
-               if t != nil && t.Sym != nil && t.Sym.Def != nil && !exportedsym(t.Sym) {
-                       if Debug['E'] != 0 {
-                               fmt.Printf("reexport type for expression %v\n", t.Sym)
-                       }
-                       exportlist = append(exportlist, t.Sym.Def)
-               }
        }
 
        reexportdep(n.Left)