1
0
mirror of https://github.com/golang/go synced 2024-11-18 18:04:46 -07:00

[dev.link] cmd/link: clear lib.Textp2 after use

lib.Textp2 is used to assemble the global Textp2. It is not used
after that point. Free some memory.

Slightly reduces allocation: for linking cmd/compile,
Linksetup_GC     1.10MB ± 0%    0.84MB ± 0%  -23.43%  (p=0.008 n=5+5)

Change-Id: Iec4572e282655306d5ff3e490f8855d479e45acf
Reviewed-on: https://go-review.googlesource.com/c/go/+/228481
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
This commit is contained in:
Cherry Zhang 2020-04-16 01:01:33 -04:00
parent 5c0bd934a2
commit d4a70b97dc

View File

@ -2664,19 +2664,17 @@ func (l *Loader) AssignTextSymbolOrder(libs []*sym.Library, intlibs []bool, exts
}
}
// Now redo the assignment of text symbols to libs/units.
// Now assemble global textp, and assign text symbols to units.
for _, doInternal := range [2]bool{true, false} {
for idx, lib := range libs {
if intlibs[idx] != doInternal {
continue
}
libtextp2 := []sym.LoaderSym{}
lists := [2][]sym.LoaderSym{lib.Textp2, lib.DupTextSyms2}
for i, list := range lists {
for _, s := range list {
sym := Sym(s)
if l.attrReachable.Has(sym) && !assignedToUnit.Has(sym) {
libtextp2 = append(libtextp2, s)
textp2 = append(textp2, sym)
unit := l.SymUnit(sym)
if unit != nil {
@ -2694,7 +2692,8 @@ func (l *Loader) AssignTextSymbolOrder(libs []*sym.Library, intlibs []bool, exts
}
}
}
lib.Textp2 = libtextp2
lib.Textp2 = nil
lib.DupTextSyms2 = nil
}
}