Commit 3fc8cd05 authored by Alan Donovan's avatar Alan Donovan

exp/ssa: perform all packages' BUILD phases in parallel.

Details:
- move Builder.nTo1Vars into package => thread-safe.
- add BuildSerially builder mode flag to disable concurrency.
- add Builder.BuildAllPackages method.

Benchmark: BuildAllPackages for $GOROOT/test/append.go drops
to 83ms from 190ms (GOMAXPROCS=8).

R=gri
CC=golang-dev
https://golang.org/cl/7371051
parent 7add9b7f
This diff is collapsed.
......@@ -182,7 +182,7 @@ func run(t *testing.T, dir, input string) bool {
return false
}
b.BuildPackage(mainpkg)
b.BuildAllPackages()
b = nil // discard Builder
hint = fmt.Sprintf("To trace execution, run:\n%% go run exp/ssa/ssadump.go -build=C -run --interp=T %s\n", input)
......
......@@ -45,7 +45,9 @@ type Package struct {
// The following fields are set transiently during building,
// then cleared.
files []*ast.File // the abstract syntax tree for the files of the package
started int32 // atomically tested and set at start of build phase
files []*ast.File // the abstract syntax trees for the files of the package
nTo1Vars map[*ast.ValueSpec]bool // set of n:1 ValueSpecs already built
}
// A Member is a member of a Go package, implemented by *Literal,
......
......@@ -23,6 +23,7 @@ P log [P]ackage inventory.
F log [F]unction SSA code.
S log [S]ource locations as SSA builder progresses.
G use binary object files from gc to provide imports (no code).
L build distinct packages seria[L]ly instead of in parallel.
N build [N]aive SSA form: don't replace local loads/stores with registers.
`)
......@@ -66,6 +67,8 @@ func main() {
mode |= ssa.NaiveForm
case 'G':
mode |= ssa.UseGCImporter
case 'L':
mode |= ssa.BuildSerially
default:
log.Fatalf("Unknown -build option: '%c'.", c)
}
......@@ -128,7 +131,7 @@ func main() {
if err != nil {
log.Fatalf(err.Error())
}
b.BuildPackage(mainpkg)
b.BuildAllPackages()
b = nil // discard Builder
if *runFlag {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment