]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: mark panicshift and panicdivide as //go:yeswritebarrierrec
authorMatthew Dempsky <mdempsky@google.com>
Fri, 13 May 2022 23:06:53 +0000 (16:06 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Mon, 16 May 2022 09:31:07 +0000 (09:31 +0000)
When compiling package runtime, cmd/compile logically has two copies
of package runtime: the actual source files being compiled, and the
internal description used for emitting compiler-generated calls.

Notably, CL 393715 will cause the compiler's write barrier validation
to start recognizing that compiler-generated calls are actually calls
to the corresponding functions from the source package. And today,
there are some code paths in nowritebarrierrec code paths that
actually end up generating code to call panicshift or panicdivide.

In preparation, this CL marks those functions as
//go:yeswritebarrierrec. We probably want to actually cleanup those
code paths to avoid these calls actually (e.g., explicitly convert
shift count expressions to an unsigned integer type). But for now,
this at least unblocks CL 393715 while preserving the status quo.

Updates #51734.

Change-Id: I01f89adb72466c0260a9cd363e3e09246e39cff9
Reviewed-on: https://go-review.googlesource.com/c/go/+/406316
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/runtime/panic.go

index 3cea14758ce4b760b94d4b6f4ea700e383f59f77..121f2022a4ef2587138a3f059fade138e806fb40 100644 (file)
@@ -225,6 +225,7 @@ func panicSliceConvert(x int, y int)
 
 var shiftError = error(errorString("negative shift amount"))
 
+//go:yeswritebarrierrec
 func panicshift() {
        panicCheck1(getcallerpc(), "negative shift amount")
        panic(shiftError)
@@ -232,6 +233,7 @@ func panicshift() {
 
 var divideError = error(errorString("integer divide by zero"))
 
+//go:yeswritebarrierrec
 func panicdivide() {
        panicCheck2("integer divide by zero")
        panic(divideError)