1
0
mirror of https://github.com/golang/go synced 2024-11-23 20:20:01 -07:00
go/src
Austin Clements 9b331189c1 cmd/internal/obj/x86: adjust SP correctly for tail calls
Currently, tail calls on x86 don't adjust the SP on return, so it's
important that the compiler produce a zero-sized frame and disable the
frame pointer. However, these constraints aren't necessary. For
example, on other architectures it's generally necessary to restore
the saved LR before a tail call, so obj simply makes this work.
Likewise, on x86, there's no reason we can't simply make this work.

Hence, this CL adjusts the compiler to use the same tail call
convention for x86 that we use on LR machines by producing a RET with
a target, rather than a JMP with a target. In fact, obj already
understands this convention for x86 except that it's buggy with
non-zero frame sizes. So we also fix this bug obj. As a result of
these fixes, the compiler no longer needs to mark wrappers as
NoFramePointer since it's now perfectly fine to save the frame
pointer.

In fact, this eliminates the only use of NoFramePointer in the
compiler, which will enable further cleanups.

This also fixes what is very nearly, but not quite, a code generation
bug. NoFramePointer becomes obj.NOFRAME in the object file, which on
ppc64 and s390x means to omit the saved LR. Hence, on these
architectures, NoFramePointer (and NOFRAME) is only safe to set on
leaf functions. However, on *most* architectures, wrappers aren't
necessarily leaf functions because they may call DUFFZERO. We're saved
on ppc64 and s390x only because the compiler doesn't have the rules to
produce DUFFZERO calls on these architectures. Hence, this only works
because the set of LR architectures that implement NOFRAME is disjoint
from the set where the compiler produces DUFFZERO operations. (I
discovered this whole mess when I attempted to add NOFRAME support to
arm.)

Change-Id: Icc589aeb86beacb850d0a6a80bd3024974a33947
Reviewed-on: https://go-review.googlesource.com/92035
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2018-02-12 21:41:19 +00:00
..
archive archive/zip: add test for Modified vs ModTime behavior 2017-12-01 00:22:21 +00:00
bufio bufio: Use maxConsecutiveEmptyReads instead of 100 2017-11-14 05:21:00 +00:00
builtin builtin: improve docs for make slice 2017-11-18 01:48:52 +00:00
bytes bytes: mention strings.Builder in Buffer.String docs 2017-11-30 01:46:50 +00:00
cmd cmd/internal/obj/x86: adjust SP correctly for tail calls 2018-02-12 21:41:19 +00:00
compress
container container/list: document nil values more 2018-01-08 18:06:27 +00:00
context
crypto crypto/x509: better document Verify's behaviour. 2018-01-18 14:43:29 +00:00
database/sql database/sql: buffers provided to Rows.Next should not be modified by drivers 2018-01-25 19:14:14 +00:00
debug debug/gosym: update docs for changes in Go 1.3 2017-11-30 22:49:27 +00:00
encoding encoding/gob: avoid race on idToType 2018-01-04 02:17:33 +00:00
errors
expvar
flag flag: clarify comment to avoid shell syntax confusion 2017-12-06 04:36:03 +00:00
fmt
go go/types: use check.lookup consistently where possible (cleanup) 2018-02-12 21:40:31 +00:00
hash hash: add MarshalBinary/UnmarshalBinary round trip + golden test for all implementations 2017-12-06 07:45:46 +00:00
html html/template: check for duplicates when inserting escapers 2018-01-10 17:36:27 +00:00
image Revert "go/printer: forbid empty line before first comment in block" 2017-12-01 01:12:26 +00:00
index/suffixarray
internal cmd/trace: init goroutine info entries with GoCreate event 2017-12-20 23:04:21 +00:00
io io: eliminate full copy of copy loop in CopyN 2017-11-16 02:24:37 +00:00
log
math math/rand: typo fixed in documentation of seedPos 2018-01-04 20:27:29 +00:00
mime
net net: fix the kernel state name for TCP listen queue on FreeBSD 2018-02-02 00:04:20 +00:00
os os/signal: skip TestTerminalSignal if posix_openpt fails with EACCES 2018-01-31 00:50:06 +00:00
path
plugin plugin: document support for macOS 2017-12-12 00:59:50 +00:00
reflect reflect: fix doc nit 2018-01-09 21:48:16 +00:00
regexp Revert "go/printer: forbid empty line before first comment in block" 2017-12-01 01:12:26 +00:00
runtime runtime: restore RSB for sigpanic call on mips64x 2018-01-31 20:57:53 +00:00
sort
strconv
strings strings: prevent copyCheck from forcing Builder to escape and allocate 2018-01-09 22:01:28 +00:00
sync sync: consistently use article "a" for RWMutex 2018-01-16 23:09:57 +00:00
syscall syscall: use SYS_GETDENTS64 on linux/mips64{,le} 2018-01-31 20:42:49 +00:00
testing cmd/go, testing: test names don't have to be alphanumeric 2018-01-04 01:52:55 +00:00
text text/template: revert CL 66410 "add break, continue actions in ranges" 2018-02-06 05:00:01 +00:00
time time: revert CL 78735 (was: space padding using underscore) 2018-01-03 20:50:44 +00:00
unicode Revert "go/printer: forbid empty line before first comment in block" 2017-12-01 01:12:26 +00:00
unsafe
vendor/golang_org/x vendor: update golang.org/x/net/nettest from upstream 2017-11-29 19:55:02 +00:00
all.bash
all.bat
all.rc
androidtest.bash misc,src: add support for specifying adb flags to the android harness 2018-01-20 21:13:30 +00:00
bootstrap.bash bootstrap.bash: only fetch git revision if we need it 2018-01-30 15:11:56 +00:00
buildall.bash
clean.bash
clean.bat
clean.rc
cmp.bash
iostest.bash
make.bash cmd/dist: fix bad LC_TIME assumption in 'date' invocation 2017-11-03 13:42:33 +00:00
make.bat
Make.dist
make.rc
naclmake.bash
nacltest.bash
race.bash
race.bat
run.bash
run.bat
run.rc