cmd/compile, cmd/link: more efficient typelink generation

Instead of generating typelink symbols in the compiler
mark types that should have typelinks with a flag.
The linker detects this flag and adds the marked types
to the typelink table.

name            old s/op    new s/op    delta
LinkCmdCompile   0.27 ± 6%   0.25 ± 6%  -6.93%    (p=0.000 n=97+98)
LinkCmdGo        0.30 ± 5%   0.29 ±10%  -4.22%    (p=0.000 n=97+99)

name            old MaxRSS  new MaxRSS  delta
LinkCmdCompile   112k ± 3%   106k ± 2%  -4.85%  (p=0.000 n=100+100)
LinkCmdGo        107k ± 3%   103k ± 3%  -3.00%  (p=0.000 n=100+100)

Change-Id: Ic95dd4b0101e90c1fa262c9c6c03a2028d6b3623
Reviewed-on: https://go-review.googlesource.com/31772
Run-TryBot: Shahar Kohanim <skohanim@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
This commit is contained in:
shaharko 2016-10-19 07:33:16 +03:00 committed by Shahar Kohanim
parent 5a9549260d
commit d8d445280a
11 changed files with 80 additions and 50 deletions

View file

@ -937,11 +937,6 @@ func tracksym(t *Type, f *Field) *Sym {
return Pkglookup(t.tconv(FmtLeft)+"."+f.Sym.Name, trackpkg)
}
func typelinkLSym(t *Type) *obj.LSym {
name := "go.typelink." + t.tconv(FmtLeft) // complete, unambiguous type name
return obj.Linklookup(Ctxt, name, 0)
}
func typesymprefix(prefix string, t *Type) *Sym {
p := prefix + "." + t.tconv(FmtLeft)
s := Pkglookup(p, typepkg)
@ -1338,8 +1333,6 @@ ok:
ot = dextratypeData(s, ot, t)
ggloblsym(s, int32(ot), int16(dupok|obj.RODATA))
// generate typelink.foo pointing at s = type.foo.
//
// The linker will leave a table of all the typelinks for
// types in the binary, so the runtime can find them.
//
@ -1357,11 +1350,7 @@ ok:
keep = true
}
}
if keep {
slink := typelinkLSym(t)
dsymptrOffLSym(slink, 0, Linksym(s), 0)
ggloblLSym(slink, 4, int16(dupok|obj.RODATA))
}
s.Lsym.MakeTypelink = keep
return s
}