aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/export_test.go
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2023-08-10 15:07:43 -0700
committerKeith Randall <khr@google.com>2023-08-11 20:24:56 +0000
commit1f4bb6112bdab6c0320b1ecd28a7da79cf8b74e0 (patch)
tree29f79e0e1dadef80efc41b2b9ef773bbce8929a1 /src/runtime/export_test.go
parent3378adc517f362793acec5adc6cc17f9a1841a4c (diff)
downloadgo-1f4bb6112bdab6c0320b1ecd28a7da79cf8b74e0.tar.xz
runtime: test that write barriers are correctly marked unpreemptible
Followon to CL 518055. Change-Id: I05c4b429f49feb7012070e467fefbf3392260915 Reviewed-on: https://go-review.googlesource.com/c/go/+/518538 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Keith Randall <khr@google.com>
Diffstat (limited to 'src/runtime/export_test.go')
-rw-r--r--src/runtime/export_test.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/runtime/export_test.go b/src/runtime/export_test.go
index a4a1fa580d..bc08b2333c 100644
--- a/src/runtime/export_test.go
+++ b/src/runtime/export_test.go
@@ -7,6 +7,7 @@
package runtime
import (
+ "internal/abi"
"internal/goarch"
"internal/goos"
"runtime/internal/atomic"
@@ -1940,3 +1941,21 @@ func MyGenericFunc[T any]() {
testUintptr = 4
})
}
+
+func UnsafePoint(pc uintptr) bool {
+ fi := findfunc(pc)
+ v := pcdatavalue(fi, abi.PCDATA_UnsafePoint, pc, nil)
+ switch v {
+ case abi.UnsafePointUnsafe:
+ return true
+ case abi.UnsafePointSafe:
+ return false
+ case abi.UnsafePointRestart1, abi.UnsafePointRestart2, abi.UnsafePointRestartAtEntry:
+ // These are all interruptible, they just encode a nonstandard
+ // way of recovering when interrupted.
+ return false
+ default:
+ var buf [20]byte
+ panic("invalid unsafe point code " + string(itoa(buf[:], uint64(v))))
+ }
+}