aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorCherry Zhang <cherryyz@google.com>2019-10-20 17:24:14 -0400
committerCherry Zhang <cherryyz@google.com>2019-11-05 03:42:00 +0000
commit11db7e44692a2389b7e9bc2e157b363cf7be5ed8 (patch)
tree7124a722a87b98b00c654733e2cfda4c36d3f01b /src/runtime
parenta866b48e4a3cb0c034cb98401e654317023188d9 (diff)
downloadgo-11db7e44692a2389b7e9bc2e157b363cf7be5ed8.tar.xz
runtime: test a frameless function for async preemption
Frameless function is an interesting case for call injection espcially for LR architectures. Extend the test for this case. Change-Id: I074090d09eeaf642e71e3f44fea216f66d39b817 Reviewed-on: https://go-review.googlesource.com/c/go/+/202339 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/testdata/testprog/preempt.go20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/runtime/testdata/testprog/preempt.go b/src/runtime/testdata/testprog/preempt.go
index cf004fcb28..c08b29b65a 100644
--- a/src/runtime/testdata/testprog/preempt.go
+++ b/src/runtime/testdata/testprog/preempt.go
@@ -22,16 +22,23 @@ func AsyncPreempt() {
debug.SetGCPercent(-1)
// Start a goroutine with no sync safe-points.
- var ready uint32
+ var ready, ready2 uint32
go func() {
for {
atomic.StoreUint32(&ready, 1)
}
}()
+ // Also start one with a frameless function.
+ // This is an especially interesting case for
+ // LR machines.
+ go func() {
+ atomic.StoreUint32(&ready2, 1)
+ frameless()
+ }()
// Wait for the goroutine to stop passing through sync
// safe-points.
- for atomic.LoadUint32(&ready) == 0 {
+ for atomic.LoadUint32(&ready) == 0 || atomic.LoadUint32(&ready2) == 0 {
runtime.Gosched()
}
@@ -42,3 +49,12 @@ func AsyncPreempt() {
println("OK")
}
+
+//go:noinline
+func frameless() {
+ for i := int64(0); i < 1<<62; i++ {
+ out += i
+ }
+}
+
+var out int64