From 4e1bf8ed3840632b4781d3c4abb4704dca468dd4 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Wed, 24 Mar 2021 10:45:20 -0400 Subject: 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 Run-TryBot: Austin Clements TryBot-Result: Go Bot Reviewed-by: Michael Pratt Reviewed-by: Than McIntosh --- src/runtime/export_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/runtime/export_test.go') 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) +} -- cgit v1.3-5-g9baa