From 568590b0856d457f38404505f96d21032c35f844 Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Fri, 13 May 2022 16:06:53 -0700 Subject: [PATCH] runtime: mark panicshift and panicdivide as //go:yeswritebarrierrec 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 Reviewed-by: David Chase Run-TryBot: Matthew Dempsky TryBot-Result: Gopher Robot --- src/runtime/panic.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/runtime/panic.go b/src/runtime/panic.go index 3cea14758c..121f2022a4 100644 --- a/src/runtime/panic.go +++ b/src/runtime/panic.go @@ -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) -- 2.48.1