]> Cypherpunks repositories - gostls13.git/commit
cmd/compile,runtime: redo growslice calling convention
authorKeith Randall <khr@golang.org>
Thu, 14 Jul 2022 03:22:53 +0000 (20:22 -0700)
committerKeith Randall <khr@golang.org>
Thu, 1 Sep 2022 21:28:35 +0000 (21:28 +0000)
commitdd323fe205b04da837e12aabf0bebfbe171aa7c2
treedb2ec355eb308c06a40d74f445f468d3f7031de3
parent1e7f535475febc247c9e27249ee35e3a00dfa769
cmd/compile,runtime: redo growslice calling convention

Instead of passing the original length and the new length, pass
the new length and the length increment. Also use the new length
in all the post-growslice calculations so that the original length
is dead and does not need to be spilled/restored around the growslice.

old: growslice(typ, oldPtr, oldLen, oldCap, newLen) (newPtr, newLen, newCap)
new: growslice(oldPtr, newLen, oldCap, inc, typ) (newPtr, newLen, newCap)

where inc = # of elements added = newLen-oldLen

Also move the element type to the end of the call. This makes register
allocation more efficient, as oldPtr and newPtr can often be in the
same register (e.g. AX on amd64) and thus the phi takes no instructions.

Makes the go binary 0.3% smaller.

Change-Id: I7295a60227dbbeecec2bf039eeef2950a72df760
Reviewed-on: https://go-review.googlesource.com/c/go/+/418554
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
src/cmd/compile/internal/ssagen/ssa.go
src/cmd/compile/internal/typecheck/builtin.go
src/cmd/compile/internal/typecheck/builtin/runtime.go
src/cmd/compile/internal/walk/assign.go
src/cmd/compile/internal/walk/builtin.go
src/runtime/slice.go