1
0
mirror of https://github.com/golang/go synced 2024-11-18 08:54:45 -07:00

cmd/internal/objfile: reuse tabwriter across symbols when disassembling

Since the tabwriter is flushed at every symbol,
it can be re-used with no impact on the output.

This cuts allocated space when objdump-ing
the compiler by almost 40%,
and enables further upcoming improvements.

It also speeds up objdump.

name            old time/op       new time/op       delta
ObjdumpCompile        9.22s ± 3%        8.77s ± 3%   -4.79%  (p=0.000 n=10+9)

Change-Id: Ief114d6c2680a4e762b5f439d3ca8dc7a89b9b27
Reviewed-on: https://go-review.googlesource.com/106978
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Josh Bleecher Snyder 2018-04-13 15:37:37 -07:00
parent 983fca55c0
commit 9137edc986

View File

@ -197,6 +197,7 @@ func (d *Disasm) Print(w io.Writer, filter *regexp.Regexp, start, end uint64, pr
fc = NewFileCache(8)
}
tw := tabwriter.NewWriter(bw, 18, 8, 1, '\t', tabwriter.StripEscape)
for _, sym := range d.syms {
symStart := sym.Addr
symEnd := sym.Addr + uint64(sym.Size)
@ -215,7 +216,6 @@ func (d *Disasm) Print(w io.Writer, filter *regexp.Regexp, start, end uint64, pr
file, _, _ := d.pcln.PCToLine(sym.Addr)
fmt.Fprintf(bw, "TEXT %s(SB) %s\n", sym.Name, file)
tw := tabwriter.NewWriter(bw, 18, 8, 1, '\t', tabwriter.StripEscape)
if symEnd > end {
symEnd = end
}