]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: skip compiling wrappers for imported defined types
authorMatthew Dempsky <mdempsky@google.com>
Mon, 30 Oct 2017 19:16:30 +0000 (12:16 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Mon, 30 Oct 2017 22:03:33 +0000 (22:03 +0000)
When compiling a package that defines a type T with method T.M, we
already compile and emit the wrapper method (*T).M. There's no need
for every package that uses T to do the same.

Change-Id: I3ca2659029907570f8b98d66111686435fad7ed0
Reviewed-on: https://go-review.googlesource.com/74412
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
src/cmd/compile/internal/gc/subr.go

index 686a8177c54d5b12f721f84b5f9a04ec6e5c3db2..a3d8df8ffc8a4c8a83ba6cfa7f8b9ccd5a762f58 100644 (file)
@@ -1659,6 +1659,12 @@ func genwrapper(rcvr *types.Type, method *types.Field, newnam *types.Sym, iface
                fmt.Printf("genwrapper rcvrtype=%v method=%v newnam=%v\n", rcvr, method, newnam)
        }
 
+       // Only generate (*T).M wrappers for T.M in T's own package.
+       if rcvr.IsPtr() && rcvr.Elem() == method.Type.Recv().Type &&
+               rcvr.Elem().Sym != nil && rcvr.Elem().Sym.Pkg != localpkg {
+               return
+       }
+
        lineno = autogeneratedPos
 
        dclcontext = PEXTERN