From 6ea7a196d0a04eb913e0136fb681610055cf9b11 Mon Sep 17 00:00:00 2001 From: Than McIntosh Date: Fri, 1 May 2020 12:24:03 -0400 Subject: [PATCH] [dev.link] cmd/internal/dwarf: revise Abbrevs() signature MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The function Abbrevs() was returning an array of structures by value, which is not very efficient (this was showing up in a kubernetes kubelet linker profile). Switch the function to return a slice instead. Improves linker DwarfGenerateDebugSyms running time when linking the compiler in compilebench: DwarfGenerateDebugSyms 29.2ms ±144% 23.9ms ±125% -17.89% (p=0.000 n=99+99) Change-Id: I1132816563f208c63eb82a7932d9f2bcb2455324 Reviewed-on: https://go-review.googlesource.com/c/go/+/231558 Run-TryBot: Than McIntosh TryBot-Result: Gobot Gobot Reviewed-by: Cherry Zhang --- src/cmd/internal/dwarf/dwarf.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cmd/internal/dwarf/dwarf.go b/src/cmd/internal/dwarf/dwarf.go index a17b574cdd..db013999da 100644 --- a/src/cmd/internal/dwarf/dwarf.go +++ b/src/cmd/internal/dwarf/dwarf.go @@ -398,9 +398,9 @@ func expandPseudoForm(form uint8) uint8 { // Abbrevs() returns the finalized abbrev array for the platform, // expanding any DW_FORM pseudo-ops to real values. -func Abbrevs() [DW_NABRV]dwAbbrev { +func Abbrevs() []dwAbbrev { if abbrevsFinalized { - return abbrevs + return abbrevs[:] } for i := 1; i < DW_NABRV; i++ { for j := 0; j < len(abbrevs[i].attr); j++ { @@ -408,7 +408,7 @@ func Abbrevs() [DW_NABRV]dwAbbrev { } } abbrevsFinalized = true - return abbrevs + return abbrevs[:] } // abbrevs is a raw table of abbrev entries; it needs to be post-processed -- 2.48.1