diff options
author | Cherry Zhang <cherryyz@google.com> | 2020-04-16 01:01:33 -0400 |
---|---|---|
committer | Cherry Zhang <cherryyz@google.com> | 2020-04-16 14:37:16 +0000 |
commit | d4a70b97dc1a349e02fd7a0c6eee5bd569d4021f (patch) | |
tree | a071f44054f040beac2cea61113c42490e74987c /src/cmd/link/internal/loader/loader.go | |
parent | 5c0bd934a2e92727c5bd37f079aec0c79697f10c (diff) | |
download | go-d4a70b97dc1a349e02fd7a0c6eee5bd569d4021f.tar.gz go-d4a70b97dc1a349e02fd7a0c6eee5bd569d4021f.zip |
[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>
Diffstat (limited to 'src/cmd/link/internal/loader/loader.go')
-rw-r--r-- | src/cmd/link/internal/loader/loader.go | 7 |
1 files changed, 3 insertions, 4 deletions
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 } } |