Skip to content

Commit 57546d6

Browse files
committed
cmd/compile: add reusable []Location to ssa.Config
name old time/op new time/op delta Template 218ms ± 3% 214ms ± 3% -1.70% (p=0.000 n=30+30) Unicode 100ms ± 3% 100ms ± 4% ~ (p=0.614 n=29+30) GoTypes 657ms ± 1% 660ms ± 3% +0.46% (p=0.046 n=29+30) Compiler 2.80s ± 2% 2.80s ± 1% ~ (p=0.451 n=28+29) Flate 131ms ± 2% 132ms ± 4% ~ (p=1.000 n=29+29) GoParser 159ms ± 3% 160ms ± 5% ~ (p=0.341 n=28+30) Reflect 406ms ± 3% 408ms ± 4% ~ (p=0.511 n=28+30) Tar 118ms ± 4% 118ms ± 4% ~ (p=0.827 n=29+30) XML 222ms ± 6% 222ms ± 3% ~ (p=0.532 n=30+30) name old user-ns/op new user-ns/op delta Template 274user-ms ± 3% 272user-ms ± 3% -0.87% (p=0.015 n=29+30) Unicode 140user-ms ± 4% 140user-ms ± 3% ~ (p=0.735 n=29+30) GoTypes 890user-ms ± 1% 897user-ms ± 2% +0.88% (p=0.002 n=29+30) Compiler 3.88user-s ± 2% 3.89user-s ± 1% ~ (p=0.132 n=30+29) Flate 168user-ms ± 2% 157user-ms ± 4% -6.21% (p=0.000 n=25+28) GoParser 211user-ms ± 2% 213user-ms ± 5% ~ (p=0.086 n=28+30) Reflect 539user-ms ± 2% 541user-ms ± 3% ~ (p=0.267 n=27+29) Tar 156user-ms ± 7% 155user-ms ± 5% ~ (p=0.708 n=30+30) XML 291user-ms ± 5% 294user-ms ± 3% +0.83% (p=0.029 n=29+30) name old alloc/op new alloc/op delta Template 40.7MB ± 0% 39.4MB ± 0% -3.26% (p=0.000 n=29+26) Unicode 30.8MB ± 0% 30.7MB ± 0% -0.40% (p=0.000 n=28+30) GoTypes 123MB ± 0% 119MB ± 0% -3.47% (p=0.000 n=30+29) Compiler 472MB ± 0% 455MB ± 0% -3.60% (p=0.000 n=30+30) Flate 26.5MB ± 0% 25.6MB ± 0% -3.21% (p=0.000 n=28+30) GoParser 32.3MB ± 0% 31.4MB ± 0% -2.98% (p=0.000 n=29+30) Reflect 84.4MB ± 0% 82.1MB ± 0% -2.83% (p=0.000 n=30+30) Tar 27.3MB ± 0% 26.5MB ± 0% -2.70% (p=0.000 n=29+29) XML 44.6MB ± 0% 43.1MB ± 0% -3.49% (p=0.000 n=30+30) name old allocs/op new allocs/op delta Template 401k ± 1% 399k ± 0% -0.35% (p=0.000 n=30+28) Unicode 331k ± 0% 331k ± 1% ~ (p=0.907 n=28+30) GoTypes 1.24M ± 0% 1.23M ± 0% -0.43% (p=0.000 n=30+30) Compiler 4.26M ± 0% 4.25M ± 0% -0.34% (p=0.000 n=29+30) Flate 252k ± 1% 251k ± 1% -0.41% (p=0.000 n=30+30) GoParser 325k ± 1% 324k ± 1% -0.31% (p=0.000 n=27+30) Reflect 1.06M ± 0% 1.05M ± 0% -0.69% (p=0.000 n=30+30) Tar 266k ± 1% 265k ± 1% -0.51% (p=0.000 n=29+30) XML 416k ± 1% 415k ± 1% -0.36% (p=0.002 n=30+30) Change-Id: I8f784001324df83b2764c44f0e83a540e5beab34 Reviewed-on: https://go-review.googlesource.com/36212 Run-TryBot: Josh Bleecher Snyder <[email protected]> Reviewed-by: Keith Randall <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent f69a6de commit 57546d6

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

src/cmd/compile/internal/ssa/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ type Config struct {
5151
// Storage for low-numbered values and blocks.
5252
values [2000]Value
5353
blocks [200]Block
54+
locs [2000]Location
5455

5556
// Reusable stackAllocState.
5657
// See stackalloc.go's {new,put}StackAllocState.

src/cmd/compile/internal/ssa/func.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,16 @@ func (f *Func) Free() {
438438
f.Config.blocks[i].ID = ID(i)
439439
}
440440

441+
// Clear locs.
442+
n = len(f.RegAlloc)
443+
if n > len(f.Config.locs) {
444+
n = len(f.Config.locs)
445+
}
446+
head := f.Config.locs[:n]
447+
for i := range head {
448+
head[i] = nil
449+
}
450+
441451
// Unregister from config.
442452
if f.Config.curFunc != f {
443453
f.Fatalf("free of function which isn't the last one allocated")

src/cmd/compile/internal/ssa/regalloc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,7 @@ func isLeaf(f *Func) bool {
476476

477477
func (s *regAllocState) init(f *Func) {
478478
s.f = f
479+
s.f.RegAlloc = s.f.Config.locs[:0]
479480
s.registers = f.Config.registers
480481
if nr := len(s.registers); nr == 0 || nr > int(noRegister) || nr > int(unsafe.Sizeof(regMask(0))*8) {
481482
s.f.Fatalf("bad number of registers: %d", nr)

0 commit comments

Comments
 (0)