]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.link] cmd/link: clear lib.Textp2 after use
authorCherry Zhang <cherryyz@google.com>
Thu, 16 Apr 2020 05:01:33 +0000 (01:01 -0400)
committerCherry Zhang <cherryyz@google.com>
Thu, 16 Apr 2020 14:37:16 +0000 (14:37 +0000)
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>
src/cmd/link/internal/loader/loader.go

index e996fc720db0738cee01fec85196b725a4a1088a..59c022d5a98f58558887e912c77503963fbe0172 100644 (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
                }
        }