]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: add cache of sizeable objects so they can be reused
authorKeith Randall <khr@golang.org>
Tue, 18 Oct 2022 23:07:36 +0000 (16:07 -0700)
committerKeith Randall <khr@google.com>
Mon, 31 Oct 2022 21:41:20 +0000 (21:41 +0000)
commit68bd383368b5958f8f02c49bc75134a0ef61daec
tree49c5272deb4f1416918a11644e351c491dd5a647
parent7ddc45263c739db254a07bb04848e3e5da4982ed
cmd/compile: add cache of sizeable objects so they can be reused

We kind of have this mechanism already, just normalizing it and
using it in a bunch of places. Previously a bunch of places cached
slices only for the duration of a single function compilation. Now
we can reuse slices across a whole compiler run.

Use a sync.Pool of powers-of-two sizes. This lets us use not
too much memory, and avoid holding onto memory we're no longer
using when a GC happens.

There's a few different types we need, so generate the code for it.
Generics would be useful here, but we can't use generics in the
compiler because of bootstrapping.

Change-Id: I6cf37e7b7b2e802882aaa723a0b29770511ccd82
Reviewed-on: https://go-review.googlesource.com/c/go/+/444820
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
21 files changed:
src/cmd/compile/internal/ssa/_gen/allocators.go [new file with mode: 0644]
src/cmd/compile/internal/ssa/_gen/main.go
src/cmd/compile/internal/ssa/allocators.go [new file with mode: 0644]
src/cmd/compile/internal/ssa/cache.go
src/cmd/compile/internal/ssa/critical.go
src/cmd/compile/internal/ssa/cse.go
src/cmd/compile/internal/ssa/deadcode.go
src/cmd/compile/internal/ssa/dom.go
src/cmd/compile/internal/ssa/flagalloc.go
src/cmd/compile/internal/ssa/func.go
src/cmd/compile/internal/ssa/layout.go
src/cmd/compile/internal/ssa/likelyadjust.go
src/cmd/compile/internal/ssa/loopreschedchecks.go
src/cmd/compile/internal/ssa/looprotate.go
src/cmd/compile/internal/ssa/nilcheck.go
src/cmd/compile/internal/ssa/print.go
src/cmd/compile/internal/ssa/regalloc.go
src/cmd/compile/internal/ssa/schedule.go
src/cmd/compile/internal/ssa/stackalloc.go
src/cmd/compile/internal/ssa/tighten.go
src/cmd/compile/internal/ssa/writebarrier.go