aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/export_test.go
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2021-03-24 10:45:20 -0400
committerAustin Clements <austin@google.com>2021-03-29 21:50:16 +0000
commit4e1bf8ed3840632b4781d3c4abb4704dca468dd4 (patch)
treeb1137dc58e46403a9454d0acd6f8e5f1078459fd /src/runtime/export_test.go
parent1ef114d12c39e8467d3e905d0a050bd7ce03123a (diff)
downloadgo-4e1bf8ed3840632b4781d3c4abb4704dca468dd4.tar.gz
go-4e1bf8ed3840632b4781d3c4abb4704dca468dd4.zip
runtime: add GC testing helpers for regabi signature fuzzer
This CL adds a set of helper functions for testing GC interactions. These are intended for use in the regabi signature fuzzer, but are generally useful for GC tests, so we make them generally available to runtime tests. These provide: 1. An easy way to force stack movement, for testing stack copying. 2. A simple and robust way to check the reachability of a set of pointers. 3. A way to check what general category of memory a pointer points to, mostly so tests can make sure they're testing what they mean to. For #40724, but generally useful. Change-Id: I15d33ccb3f5a792c0472a19c2cc9a8b4a9356a66 Reviewed-on: https://go-review.googlesource.com/c/go/+/305330 Trust: Austin Clements <austin@google.com> Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
Diffstat (limited to 'src/runtime/export_test.go')
-rw-r--r--src/runtime/export_test.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/runtime/export_test.go b/src/runtime/export_test.go
index 1650541fda..961c1c1a26 100644
--- a/src/runtime/export_test.go
+++ b/src/runtime/export_test.go
@@ -1244,3 +1244,24 @@ func FinalizerGAsleep() bool {
unlock(&finlock)
return result
}
+
+// For GCTestMoveStackOnNextCall, it's important not to introduce an
+// extra layer of call, since then there's a return before the "real"
+// next call.
+var GCTestMoveStackOnNextCall = gcTestMoveStackOnNextCall
+
+// For GCTestIsReachable, it's important that we do this as a call so
+// escape analysis can see through it.
+func GCTestIsReachable(ptrs ...unsafe.Pointer) (mask uint64) {
+ return gcTestIsReachable(ptrs...)
+}
+
+// For GCTestPointerClass, it's important that we do this as a call so
+// escape analysis can see through it.
+//
+// This is nosplit because gcTestPointerClass is.
+//
+//go:nosplit
+func GCTestPointerClass(p unsafe.Pointer) string {
+ return gcTestPointerClass(p)
+}