From: Cherry Zhang Date: Thu, 16 Apr 2020 05:01:33 +0000 (-0400) Subject: [dev.link] cmd/link: clear lib.Textp2 after use X-Git-Tag: go1.15beta1~401^2^2~28 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=d4a70b97dc1a349e02fd7a0c6eee5bd569d4021f;p=gostls13.git [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 TryBot-Result: Gobot Gobot Reviewed-by: Than McIntosh --- diff --git a/src/cmd/link/internal/loader/loader.go b/src/cmd/link/internal/loader/loader.go index e996fc720d..59c022d5a9 100644 --- a/src/cmd/link/internal/loader/loader.go +++ b/src/cmd/link/internal/loader/loader.go @@ -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 } }