1
0
mirror of https://github.com/golang/go synced 2024-09-23 09:13:25 -06:00
The Go programming language
Go to file
amusman af0c40311e cmd/compile: emit tail call wrappers when possible
Use OTAILCALL in wrapper if the receiver and method are both pointers and it is
not going to be inlined, similar to how it is done in reflectdata.methodWrapper.
Currently tail call may be used for functions with identical argument types.
This change updates wrappers where both wrapper and the wrapped method's
receiver are pointers. In this case, we have the same signature for the
wrapper and the wrapped method (modulo the receiver's pointed-to types),
and do not need any local variables in the generated wrapper (on stack)
because the arguments are immediately passed to the wrapped method in place
(without need to move some value passed to other register or to change any
argument/return passed through stack). Thus, the wrapper does not need its
own stack frame.

This applies to promoted methods, e.g. when we have some struct type U with
an embedded type *T and construct a wrapper like
func (recv *U) M(arg int) bool { return recv.T.M(i) }

See also test/abi/method_wrapper.go for a running example.

Code size difference measured with this change (tried for x86_64):
etcd binary:
.text section size: 21472251 -> 21432350 (0.2%)
total binary size:  32226640 -> 32191136 (0.1%)

compile binary:
.text section size: 17419073 -> 17413929 (0.03%)
total binary size:  26744743 -> 26737567 (0.03%)

Change-Id: I9bbe730568f6def21a8e61118a6b6f503d98049c
Reviewed-on: https://go-review.googlesource.com/c/go/+/578235
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2024-09-09 20:20:10 +00:00
.github
api net/http: add HTTP2Config 2024-08-29 17:38:46 +00:00
doc encoding/json: add embedded structs to the UnmarshalTypeError's Field 2024-09-03 15:49:47 +00:00
lib misc/wasm: move wasm runtime files to lib/wasm 2024-08-30 19:15:21 +00:00
misc misc/wasm: move wasm runtime files to lib/wasm 2024-08-30 19:15:21 +00:00
src cmd/compile: emit tail call wrappers when possible 2024-09-09 20:20:10 +00:00
test cmd/compile: emit tail call wrappers when possible 2024-09-09 20:20:10 +00:00
.gitattributes
.gitignore
codereview.cfg
CONTRIBUTING.md
go.env
LICENSE LICENSE: update per Google Legal 2024-08-09 14:54:31 +00:00
PATENTS
README.md
SECURITY.md

The Go Programming Language

Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.

Gopher image Gopher image by Renee French, licensed under Creative Commons 4.0 Attribution license.

Our canonical Git repository is located at https://go.googlesource.com/go. There is a mirror of the repository at https://github.com/golang/go.

Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file.

Download and Install

Binary Distributions

Official binary distributions are available at https://go.dev/dl/.

After downloading a binary release, visit https://go.dev/doc/install for installation instructions.

Install From Source

If a binary distribution is not available for your combination of operating system and architecture, visit https://go.dev/doc/install/source for source installation instructions.

Contributing

Go is the work of thousands of contributors. We appreciate your help!

To contribute, please read the contribution guidelines at https://go.dev/doc/contribute.

Note that the Go project uses the issue tracker for bug reports and proposals only. See https://go.dev/wiki/Questions for a list of places to ask questions about the Go language.