aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/gc/compile.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2021-01-12 11:39:10 -0800
committerMatthew Dempsky <mdempsky@google.com>2021-01-12 23:22:11 +0000
commit432f9ffb11231b00b67c8fa8047f21a8282fa914 (patch)
treee7208c018be3fa6045e5eb103e60a2cbee30034d /src/cmd/compile/internal/gc/compile.go
parentcc90e7a51e15659ea1a1eb53ca08361b6a77696a (diff)
downloadgo-432f9ffb11231b00b67c8fa8047f21a8282fa914.tar.gz
go-432f9ffb11231b00b67c8fa8047f21a8282fa914.zip
[dev.regabi] cmd/compile: unindent compileFunctions
No real code changes. Just splitting into a separate CL so the next one is easier to review. Change-Id: I428dc986b76370d8d3afc12cf19585f6384389d7 Reviewed-on: https://go-review.googlesource.com/c/go/+/283314 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/gc/compile.go')
-rw-r--r--src/cmd/compile/internal/gc/compile.go76
1 files changed, 39 insertions, 37 deletions
diff --git a/src/cmd/compile/internal/gc/compile.go b/src/cmd/compile/internal/gc/compile.go
index b9c10056b4..c2894ab012 100644
--- a/src/cmd/compile/internal/gc/compile.go
+++ b/src/cmd/compile/internal/gc/compile.go
@@ -93,43 +93,45 @@ func prepareFunc(fn *ir.Func) {
// It fans out nBackendWorkers to do the work
// and waits for them to complete.
func compileFunctions() {
- if len(compilequeue) != 0 {
- types.CalcSizeDisabled = true // not safe to calculate sizes concurrently
- if race.Enabled {
- // Randomize compilation order to try to shake out races.
- tmp := make([]*ir.Func, len(compilequeue))
- perm := rand.Perm(len(compilequeue))
- for i, v := range perm {
- tmp[v] = compilequeue[i]
- }
- copy(compilequeue, tmp)
- } else {
- // Compile the longest functions first,
- // since they're most likely to be the slowest.
- // This helps avoid stragglers.
- sort.Slice(compilequeue, func(i, j int) bool {
- return len(compilequeue[i].Body) > len(compilequeue[j].Body)
- })
- }
- var wg sync.WaitGroup
- base.Ctxt.InParallel = true
- c := make(chan *ir.Func, base.Flag.LowerC)
- for i := 0; i < base.Flag.LowerC; i++ {
- wg.Add(1)
- go func(worker int) {
- for fn := range c {
- ssagen.Compile(fn, worker)
- }
- wg.Done()
- }(i)
- }
- for _, fn := range compilequeue {
- c <- fn
+ if len(compilequeue) == 0 {
+ return
+ }
+
+ types.CalcSizeDisabled = true // not safe to calculate sizes concurrently
+ if race.Enabled {
+ // Randomize compilation order to try to shake out races.
+ tmp := make([]*ir.Func, len(compilequeue))
+ perm := rand.Perm(len(compilequeue))
+ for i, v := range perm {
+ tmp[v] = compilequeue[i]
}
- close(c)
- compilequeue = nil
- wg.Wait()
- base.Ctxt.InParallel = false
- types.CalcSizeDisabled = false
+ copy(compilequeue, tmp)
+ } else {
+ // Compile the longest functions first,
+ // since they're most likely to be the slowest.
+ // This helps avoid stragglers.
+ sort.Slice(compilequeue, func(i, j int) bool {
+ return len(compilequeue[i].Body) > len(compilequeue[j].Body)
+ })
+ }
+ var wg sync.WaitGroup
+ base.Ctxt.InParallel = true
+ c := make(chan *ir.Func, base.Flag.LowerC)
+ for i := 0; i < base.Flag.LowerC; i++ {
+ wg.Add(1)
+ go func(worker int) {
+ for fn := range c {
+ ssagen.Compile(fn, worker)
+ }
+ wg.Done()
+ }(i)
+ }
+ for _, fn := range compilequeue {
+ c <- fn
}
+ close(c)
+ compilequeue = nil
+ wg.Wait()
+ base.Ctxt.InParallel = false
+ types.CalcSizeDisabled = false
}