]> Cypherpunks repositories - gostls13.git/commit
runtime: add support for range-over-func
authorRuss Cox <rsc@golang.org>
Wed, 12 Jul 2023 19:40:11 +0000 (15:40 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 16 Aug 2023 16:51:05 +0000 (16:51 +0000)
commite82cb14255cc63099e5c728676506cb4d0d97378
treeaf7682e6486c70e8611025c0adc8c2cb52a34062
parent9cf209f6b87f46795c3eadbeaceeeca7d429752b
runtime: add support for range-over-func

Add runtime support for range over functions, specifically
for defer in the loop body. The defer is running in one
function but needs to append to the deferred function list
for a parent function. This CL implements the runtime
support for that, in the form of two new functions:
deferrangefunc, which obtains a token representing the
current frame, and deferprocat, which is like deferproc
but adds to the list for frame denoted by the token.

Preparation for proposal #61405. The actual logic in the
compiler will be guarded by a GOEXPERIMENT; this code
will only run if the compiler emits calls to deferprocat.

Change-Id: I08adf359100856d21d7ff4b493afa229c9471e70
Reviewed-on: https://go-review.googlesource.com/c/go/+/510540
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/runtime/panic.go