]> Cypherpunks.ru repositories - gostls13.git/commit
[dev.typeparams] runtime: remove unnecessary split-prevention from defer code
authorAustin Clements <austin@google.com>
Mon, 26 Jul 2021 16:04:36 +0000 (12:04 -0400)
committerAustin Clements <austin@google.com>
Tue, 3 Aug 2021 21:05:54 +0000 (21:05 +0000)
commit077925e2b008a258f5204aab8a454294b9cdca96
tree4d8c34968c2e48f736dc5f83628a189cedd6b45f
parent7ab875402985ea5a31512fb9750dc0f809e06861
[dev.typeparams] runtime: remove unnecessary split-prevention from defer code

Prior to regabi, the compiler passed defer arguments to the runtime as
untyped values on the stack. This meant a lot of defer-related runtime
functions had to be very careful not to grow the stack or allow
preemption since the stack could not be safely scanned or moved.
However, with regabi, every defer is now simply a func() from the
runtime's perspective, which means we no longer have untyped values on
the stack when we enter defer-related runtime code.

Hence, this CL removes a lot of the now-unnecessary carefulness in the
defer implementation. Specifically, deferreturn no longer needs to be
nosplit because it doesn't copy untyped defer arguments to its
caller's frame (we also update some stale comments in deferreturn).
freedefer no longer needs to be nosplit because it's none of its
callers are deeply nosplit. And newdefer and freedefer no longer need
to switch to the systemstack on their slow paths to avoid stack
growth.

deferprocStack is the only function that still needs to be nosplit,
but that's because the compiler calls it with uninitialized live
pointer slots on the stack (maybe we should change that, but that's a
very different fix).

This is a retry of CL 337651, which was rolled back. This version
disables preemption in newdefer and freedefer while they hold the
current P.

Change-Id: Ibf469addc0b69dc3ba9a3d1a5e0c2804b7b4b244
Reviewed-on: https://go-review.googlesource.com/c/go/+/339396
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/runtime/panic.go