aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/ssa/func.go
diff options
context:
space:
mode:
authorGiovanni Bajo <rasky@develer.com>2018-05-01 00:57:57 +0200
committerGiovanni Bajo <rasky@develer.com>2018-05-14 14:44:55 +0000
commit3c8545c5f6f6db7de1e9c8186fa9f23f4820ad45 (patch)
tree62696213febf008b4ce28dfdd1cfca549967933e /src/cmd/compile/internal/ssa/func.go
parent67656ba71b54779d9f98995a12ed87e7c7618cad (diff)
downloadgo-3c8545c5f6f6db7de1e9c8186fa9f23f4820ad45.tar.gz
go-3c8545c5f6f6db7de1e9c8186fa9f23f4820ad45.zip
cmd/compile: reduce allocations in prove by reusing posets
In prove, reuse posets between different functions by storing them in the per-worker cache. Allocation count regression caused by prove improvements is down from 5% to 3% after this CL. Updates #25179 Change-Id: I6d14003109833d9b3ef5165fdea00aa9c9e952e8 Reviewed-on: https://go-review.googlesource.com/110455 Run-TryBot: Giovanni Bajo <rasky@develer.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'src/cmd/compile/internal/ssa/func.go')
-rw-r--r--src/cmd/compile/internal/ssa/func.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/ssa/func.go b/src/cmd/compile/internal/ssa/func.go
index a2991040ee..900be71c42 100644
--- a/src/cmd/compile/internal/ssa/func.go
+++ b/src/cmd/compile/internal/ssa/func.go
@@ -130,6 +130,21 @@ func (f *Func) retSparseMap(ss *sparseMap) {
f.Cache.scrSparseMap = append(f.Cache.scrSparseMap, ss)
}
+// newPoset returns a new poset from the internal cache
+func (f *Func) newPoset() *poset {
+ if len(f.Cache.scrPoset) > 0 {
+ po := f.Cache.scrPoset[len(f.Cache.scrPoset)-1]
+ f.Cache.scrPoset = f.Cache.scrPoset[:len(f.Cache.scrPoset)-1]
+ return po
+ }
+ return newPoset()
+}
+
+// retPoset returns a poset to the internal cache
+func (f *Func) retPoset(po *poset) {
+ f.Cache.scrPoset = append(f.Cache.scrPoset, po)
+}
+
// newValue allocates a new Value with the given fields and places it at the end of b.Values.
func (f *Func) newValue(op Op, t *types.Type, b *Block, pos src.XPos) *Value {
var v *Value