mirror of
https://github.com/golang/go
synced 2024-09-29 22:34:33 -06:00
cmd/internal/obj: hoist constant slice out of function called in loop
It's all local to a single file and responsible for 1.7% of total space allocated summed over compilation of the bent benchmarks. Showing nodes accounting for 27.16GB, 27.04% of 100.44GB total Dropped 1622 nodes (cum <= 0.50GB) Showing top 10 nodes out of 321 flat flat% sum% cum cum% 4.87GB 4.85% 4.85% 4.87GB 4.85% cmd/compile/internal/objw.init 4.79GB 4.77% 9.62% 4.81GB 4.79% runtime.allocm 4.72GB 4.70% 14.32% 4.72GB 4.70% cmd/compile/internal/types.newType 3.10GB 3.09% 17.41% 3.17GB 3.15% cmd/compile/internal/ssagen.InitConfig 1.86GB 1.85% 19.26% 2.61GB 2.60% cmd/compile/internal/ssa.cse 1.72GB 1.71% 20.97% 2.25GB 2.24% cmd/internal/obj.(*Link).traverseFuncAux 1.66GB 1.65% 22.62% 1.66GB 1.65% runtime.malg 1.61GB 1.61% 24.23% 1.64GB 1.63% cmd/compile/internal/ssa.schedule 1.42GB 1.41% 25.64% 1.42GB 1.41% cmd/compile/internal/ir.NewNameAt Change-Id: Id18ee3b83cb23a7042d59714a0c1ca074e7bc7a8 Reviewed-on: https://go-review.googlesource.com/c/go/+/437297 Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: David Chase <drchase@google.com>
This commit is contained in:
parent
1baea0ddb3
commit
2b1c414fa8
@ -349,6 +349,7 @@ func (ctxt *Link) traverseSyms(flag traverseFlag, fn func(*LSym)) {
|
||||
}
|
||||
}
|
||||
lists := [][]*LSym{ctxt.Text, ctxt.Data}
|
||||
files := ctxt.PosTable.FileTable()
|
||||
for _, list := range lists {
|
||||
for _, s := range list {
|
||||
if flag&traverseDefs != 0 {
|
||||
@ -365,7 +366,7 @@ func (ctxt *Link) traverseSyms(flag traverseFlag, fn func(*LSym)) {
|
||||
f := func(parent *LSym, aux *LSym) {
|
||||
fn(aux)
|
||||
}
|
||||
ctxt.traverseFuncAux(flag, s, f)
|
||||
ctxt.traverseFuncAux(flag, s, f, files)
|
||||
}
|
||||
}
|
||||
if flag&traversePcdata != 0 && s.Type == objabi.STEXT {
|
||||
@ -382,7 +383,7 @@ func (ctxt *Link) traverseSyms(flag traverseFlag, fn func(*LSym)) {
|
||||
}
|
||||
}
|
||||
|
||||
func (ctxt *Link) traverseFuncAux(flag traverseFlag, fsym *LSym, fn func(parent *LSym, aux *LSym)) {
|
||||
func (ctxt *Link) traverseFuncAux(flag traverseFlag, fsym *LSym, fn func(parent *LSym, aux *LSym), files []string) {
|
||||
fninfo := fsym.Func()
|
||||
pc := &fninfo.Pcln
|
||||
if flag&traverseAux == 0 {
|
||||
@ -395,7 +396,6 @@ func (ctxt *Link) traverseFuncAux(flag traverseFlag, fsym *LSym, fn func(parent
|
||||
fn(fsym, d)
|
||||
}
|
||||
}
|
||||
files := ctxt.PosTable.FileTable()
|
||||
usedFiles := make([]goobj.CUFileIndex, 0, len(pc.UsedFiles))
|
||||
for f := range pc.UsedFiles {
|
||||
usedFiles = append(usedFiles, f)
|
||||
@ -435,6 +435,7 @@ func (ctxt *Link) traverseFuncAux(flag traverseFlag, fsym *LSym, fn func(parent
|
||||
// Traverse aux symbols, calling fn for each sym/aux pair.
|
||||
func (ctxt *Link) traverseAuxSyms(flag traverseFlag, fn func(parent *LSym, aux *LSym)) {
|
||||
lists := [][]*LSym{ctxt.Text, ctxt.Data}
|
||||
files := ctxt.PosTable.FileTable()
|
||||
for _, list := range lists {
|
||||
for _, s := range list {
|
||||
if s.Gotype != nil {
|
||||
@ -445,7 +446,7 @@ func (ctxt *Link) traverseAuxSyms(flag traverseFlag, fn func(parent *LSym, aux *
|
||||
if s.Type != objabi.STEXT {
|
||||
continue
|
||||
}
|
||||
ctxt.traverseFuncAux(flag, s, fn)
|
||||
ctxt.traverseFuncAux(flag, s, fn, files)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user