mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: teach assemblers to accept a Prog allocator
The existing bulk Prog allocator is not concurrency-safe. To allow for concurrency-safe bulk allocation of Progs, I want to move Prog allocation and caching upstream, to the clients of cmd/internal/obj. This is a preliminary enabling refactoring. After this CL, instead of calling Ctxt.NewProg throughout the assemblers, we thread through a newprog function that returns a new Prog. That function is set up to be Ctxt.NewProg, so there are no real changes in this CL; this CL only establishes the plumbing. Passes toolstash-check -all. Negligible compiler performance impact. Updates #15756 name old time/op new time/op delta Template 213ms ± 3% 214ms ± 4% ~ (p=0.574 n=49+47) Unicode 90.1ms ± 5% 89.9ms ± 4% ~ (p=0.417 n=50+49) GoTypes 585ms ± 4% 584ms ± 3% ~ (p=0.466 n=49+49) SSA 6.50s ± 3% 6.52s ± 2% ~ (p=0.251 n=49+49) Flate 128ms ± 4% 128ms ± 4% ~ (p=0.673 n=49+50) GoParser 152ms ± 3% 152ms ± 3% ~ (p=0.810 n=48+49) Reflect 372ms ± 4% 372ms ± 5% ~ (p=0.778 n=49+50) Tar 113ms ± 5% 111ms ± 4% -0.98% (p=0.016 n=50+49) XML 208ms ± 3% 208ms ± 2% ~ (p=0.483 n=47+49) [Geo mean] 285ms 285ms -0.17% name old user-ns/op new user-ns/op delta Template 253M ± 8% 254M ± 9% ~ (p=0.899 n=50+50) Unicode 106M ± 9% 106M ±11% ~ (p=0.642 n=50+50) GoTypes 736M ± 4% 740M ± 4% ~ (p=0.121 n=50+49) SSA 8.82G ± 3% 8.88G ± 2% +0.65% (p=0.006 n=49+48) Flate 147M ± 4% 147M ± 5% ~ (p=0.844 n=47+48) GoParser 179M ± 4% 178M ± 6% ~ (p=0.785 n=50+50) Reflect 443M ± 6% 441M ± 5% ~ (p=0.850 n=48+47) Tar 126M ± 5% 126M ± 5% ~ (p=0.734 n=50+50) XML 244M ± 5% 244M ± 5% ~ (p=0.594 n=49+50) [Geo mean] 341M 341M +0.11% Change-Id: Ice962f61eb3a524c2db00a166cb582c22caa7d68 Reviewed-on: https://go-review.googlesource.com/39633 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
parent
7e068895c3
commit
5b59b32c97
16 changed files with 351 additions and 344 deletions
|
|
@ -373,7 +373,7 @@ var oprange [ALAST & obj.AMask][]Optab
|
|||
|
||||
var xcmp [C_NCLASS][C_NCLASS]bool
|
||||
|
||||
func span0(ctxt *obj.Link, cursym *obj.LSym) {
|
||||
func span0(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
|
||||
p := cursym.Text
|
||||
if p == nil || p.Link == nil { // handle external functions and ELF section symbols
|
||||
return
|
||||
|
|
@ -430,7 +430,7 @@ func span0(ctxt *obj.Link, cursym *obj.LSym) {
|
|||
if o.type_ == 6 && p.Pcond != nil {
|
||||
otxt = p.Pcond.Pc - c
|
||||
if otxt < -(1<<17)+10 || otxt >= (1<<17)-10 {
|
||||
q = ctxt.NewProg()
|
||||
q = newprog()
|
||||
q.Link = p.Link
|
||||
p.Link = q
|
||||
q.As = AJMP
|
||||
|
|
@ -438,7 +438,7 @@ func span0(ctxt *obj.Link, cursym *obj.LSym) {
|
|||
q.To.Type = obj.TYPE_BRANCH
|
||||
q.Pcond = p.Pcond
|
||||
p.Pcond = q
|
||||
q = ctxt.NewProg()
|
||||
q = newprog()
|
||||
q.Link = p.Link
|
||||
p.Link = q
|
||||
q.As = AJMP
|
||||
|
|
@ -446,8 +446,8 @@ func span0(ctxt *obj.Link, cursym *obj.LSym) {
|
|||
q.To.Type = obj.TYPE_BRANCH
|
||||
q.Pcond = q.Link.Link
|
||||
|
||||
addnop(ctxt, p.Link)
|
||||
addnop(ctxt, p)
|
||||
addnop(ctxt, p.Link, newprog)
|
||||
addnop(ctxt, p, newprog)
|
||||
bflag = 1
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue