Skip to content

Commit 06839e3

Browse files
committed
cmd/link: run generator functions along with symbol writing
Like we do for applying relocations, for generator symbols, run the generator function along with symbol writing. This will probably have better locality and parallelism. Linking cmd/compile, Asmb 29.9ms ± 5% 19.1ms ±12% -36.18% (p=0.000 n=10+9) TotalTime 351ms ± 3% 339ms ± 2% -3.51% (p=0.000 n=11+10) Change-Id: I9cda6718bf70b3bcf1b7a501a845d6136234d2ee Reviewed-on: https://go-review.googlesource.com/c/go/+/263640 Trust: Cherry Zhang <[email protected]> Run-TryBot: Cherry Zhang <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Jeremy Faller <[email protected]> Reviewed-by: Than McIntosh <[email protected]>
1 parent 2ff9e01 commit 06839e3

File tree

2 files changed

+3
-12
lines changed

2 files changed

+3
-12
lines changed

src/cmd/link/internal/ld/data.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,9 @@ func writeBlock(ctxt *Link, out *OutBuf, ldr *loader.Loader, syms []loader.Sym,
951951
}
952952
P := out.WriteSym(ldr, s)
953953
st.relocsym(s, P)
954+
if f, ok := ctxt.generatorSyms[s]; ok {
955+
f(ctxt, s)
956+
}
954957
addr += int64(len(P))
955958
siz := ldr.SymSize(s)
956959
if addr < val+siz {

src/cmd/link/internal/ld/main.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,12 @@ import (
3636
"cmd/internal/objabi"
3737
"cmd/internal/sys"
3838
"cmd/link/internal/benchmark"
39-
"cmd/link/internal/loader"
4039
"flag"
4140
"log"
4241
"os"
4342
"runtime"
4443
"runtime/pprof"
4544
"strings"
46-
"sync"
4745
)
4846

4947
var (
@@ -331,16 +329,6 @@ func Main(arch *sys.Arch, theArch Arch) {
331329
// will be applied directly there.
332330
bench.Start("Asmb")
333331
asmb(ctxt)
334-
// Generate large symbols.
335-
var wg sync.WaitGroup
336-
for s, f := range ctxt.generatorSyms {
337-
wg.Add(1)
338-
go func(f generatorFunc, s loader.Sym) {
339-
defer wg.Done()
340-
f(ctxt, s)
341-
}(f, s)
342-
}
343-
wg.Wait()
344332

345333
// Generate additional symbols for the native symbol table just prior
346334
// to code generation.

0 commit comments

Comments
 (0)