Commit 8195ce2b authored by Rob Pike's avatar Rob Pike

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
parent 4e65f18c
...@@ -2493,6 +2493,7 @@ genwrapper(Type *rcvr, Type *method, Sym *newnam, int iface) ...@@ -2493,6 +2493,7 @@ genwrapper(Type *rcvr, Type *method, Sym *newnam, int iface)
Type *tpad, *methodrcvr; Type *tpad, *methodrcvr;
int isddd; int isddd;
Val v; Val v;
static int linehistdone = 0;
if(0 && debug['r']) if(0 && debug['r'])
print("genwrapper rcvrtype=%T method=%T newnam=%S\n", print("genwrapper rcvrtype=%T method=%T newnam=%S\n",
...@@ -2500,7 +2501,11 @@ genwrapper(Type *rcvr, Type *method, Sym *newnam, int iface) ...@@ -2500,7 +2501,11 @@ genwrapper(Type *rcvr, Type *method, Sym *newnam, int iface)
lexlineno++; lexlineno++;
lineno = lexlineno; lineno = lexlineno;
linehist("<autogenerated>", 0, 0); if (linehistdone == 0) {
// All the wrappers can share the same linehist entry.
linehist("<autogenerated>", 0, 0);
linehistdone = 1;
}
dclcontext = PEXTERN; dclcontext = PEXTERN;
markdcl(); markdcl();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment