From f34a051afc7e584b079096f571d1970130cc4e96 Mon Sep 17 00:00:00 2001 From: David Symonds Date: Tue, 3 Jun 2014 11:19:11 +1000 Subject: [PATCH] [release-branch.go1.3] cmd/gc: don't generate zillions of linehists for wrapper functions MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit ««« CL 104840043 / 876107512a67 cmd/gc: don't generate zillions of linehists for wrapper functions This is a workaround - the code should be better than this - but the fix avoids generating large numbers of linehist entries for the wrapper functions that enable interface conversions. There can be many of them, they all happen at the end of compilation, and they can all share a linehist entry. Avoids bad n^2 behavior in liblink. Test case in issue 8135 goes from 64 seconds to 2.5 seconds (still bad but not intolerable). Fixes #8135. LGTM=rsc R=rsc CC=golang-codereviews https://golang.org/cl/104840043 »»» TBR=adg CC=golang-codereviews https://golang.org/cl/102070045 --- src/cmd/gc/subr.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cmd/gc/subr.c b/src/cmd/gc/subr.c index 23cc9e11f7..72a9ac20c7 100644 --- a/src/cmd/gc/subr.c +++ b/src/cmd/gc/subr.c @@ -2493,6 +2493,7 @@ genwrapper(Type *rcvr, Type *method, Sym *newnam, int iface) Type *tpad, *methodrcvr; int isddd; Val v; + static int linehistdone = 0; if(0 && debug['r']) print("genwrapper rcvrtype=%T method=%T newnam=%S\n", @@ -2500,7 +2501,11 @@ genwrapper(Type *rcvr, Type *method, Sym *newnam, int iface) lexlineno++; lineno = lexlineno; - linehist("", 0, 0); + if (linehistdone == 0) { + // All the wrappers can share the same linehist entry. + linehist("", 0, 0); + linehistdone = 1; + } dclcontext = PEXTERN; markdcl(); -- 2.48.1