diff options
| author | Russ Cox <rsc@golang.org> | 2023-06-30 16:18:44 -0400 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2023-08-16 16:20:06 +0000 |
| commit | 390763aed84189cb360e7ceb94aef56125fb140d (patch) | |
| tree | 67a8bf4e5b118b7cac05abfd8069d16c9d7da137 /src/runtime/runtime2.go | |
| parent | ade5a6232fd8f8a63549adf6cb6362fe6908e1f0 (diff) | |
| download | go-390763aed84189cb360e7ceb94aef56125fb140d.tar.xz | |
cmd/compile, runtime: make room for rangefunc defers
This is subtle and the compiler and runtime be in sync.
It is easier to develop the rest of the changes (especially when using
toolstash save/restore) if this change is separated out and done first.
Preparation for proposal #61405. The actual logic in the
compiler will be guarded by a GOEXPERIMENT, but it is
easier not to have GOEXPERIMENT-specific data structures
in the runtime, so just make the field always.
Change-Id: I7ec7049b99ae98bf0db365d42966baeec56e3774
Reviewed-on: https://go-review.googlesource.com/c/go/+/510539
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/runtime/runtime2.go')
| -rw-r--r-- | src/runtime/runtime2.go | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/runtime/runtime2.go b/src/runtime/runtime2.go index 54fab050ea..5017a7a80a 100644 --- a/src/runtime/runtime2.go +++ b/src/runtime/runtime2.go @@ -1001,11 +1001,16 @@ func extendRandom(r []byte, n int) { // initialize them are not required. All defers must be manually scanned, // and for heap defers, marked. type _defer struct { - heap bool - sp uintptr // sp at time of defer - pc uintptr // pc at time of defer - fn func() // can be nil for open-coded defers - link *_defer // next defer on G; can point to either heap or stack! + heap bool + rangefunc bool // true for rangefunc list + sp uintptr // sp at time of defer + pc uintptr // pc at time of defer + fn func() // can be nil for open-coded defers + link *_defer // next defer on G; can point to either heap or stack! + + // If rangefunc is true, *head is the head of the atomic linked list + // during a range-over-func execution. + head *atomic.Pointer[_defer] } // A _panic holds information about an active panic. |
