]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.typeparams] runtime: simplify freedefer
authorAustin Clements <austin@google.com>
Tue, 3 Aug 2021 21:03:42 +0000 (17:03 -0400)
committerAustin Clements <austin@google.com>
Tue, 3 Aug 2021 21:23:25 +0000 (21:23 +0000)
Currently, freedefer manually zeros all the fields in the _defer
because simply assigning _defer{} used to cause a nosplit stack
overflow. freedefer is no longer nosplit, so go back to the simpler,
more robust code.

Change-Id: I881f557bab3b1ee7ab29b68e7fb56d0fe6d35d8d
Reviewed-on: https://go-review.googlesource.com/c/go/+/339669
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

index b2158d376e4e16342f56cf98c59993328d57844b..48b1b5dd9db63b6489009eb01630c6db61585c41 100644 (file)
@@ -372,19 +372,7 @@ func freedefer(d *_defer) {
                unlock(&sched.deferlock)
        }
 
-       // These lines used to be simply `*d = _defer{}` but that
-       // started causing a nosplit stack overflow via typedmemmove.
-       d.started = false
-       d.openDefer = false
-       d.sp = 0
-       d.pc = 0
-       d.framepc = 0
-       d.varp = 0
-       d.fd = nil
-       // d._panic and d.fn must be nil already.
-       // If not, we would have called freedeferpanic or freedeferfn above,
-       // both of which throw.
-       d.link = nil
+       *d = _defer{}
 
        pp.deferpool = append(pp.deferpool, d)