Commit 11db7e44 authored by Cherry Zhang's avatar Cherry Zhang

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: default avatarAustin Clements <austin@google.com>
parent a866b48e
...@@ -22,16 +22,23 @@ func AsyncPreempt() { ...@@ -22,16 +22,23 @@ func AsyncPreempt() {
debug.SetGCPercent(-1) debug.SetGCPercent(-1)
// Start a goroutine with no sync safe-points. // Start a goroutine with no sync safe-points.
var ready uint32 var ready, ready2 uint32
go func() { go func() {
for { for {
atomic.StoreUint32(&ready, 1) 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 // Wait for the goroutine to stop passing through sync
// safe-points. // safe-points.
for atomic.LoadUint32(&ready) == 0 { for atomic.LoadUint32(&ready) == 0 || atomic.LoadUint32(&ready2) == 0 {
runtime.Gosched() runtime.Gosched()
} }
...@@ -42,3 +49,12 @@ func AsyncPreempt() { ...@@ -42,3 +49,12 @@ func AsyncPreempt() {
println("OK") println("OK")
} }
//go:noinline
func frameless() {
for i := int64(0); i < 1<<62; i++ {
out += i
}
}
var out int64
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment