Commit 546a54bb authored by Rick Hudson's avatar Rick Hudson

runtime: Remove write barrier on g

There are calls to stdcall when the GC thinks the world is stopped
and stdcall write a *g for the CPU profiler. This produces a write
barrier but the GC is not prepared to deal with write barriers when
it thinks the world is stopped. Since the g is on allg it does not
need a write barrier to keep it alive so eliminate the write barrier.

Change-Id: I937633409a66553d7d292d87d7d58caba1fad0b6
Reviewed-on: https://go-review.googlesource.com/7979Reviewed-by: default avatarAustin Clements <austin@google.com>
Run-TryBot: Rick Hudson <rlh@golang.org>
parent 9b691969
...@@ -359,6 +359,8 @@ func nanotime() int64 { ...@@ -359,6 +359,8 @@ func nanotime() int64 {
} }
// Calling stdcall on os stack. // Calling stdcall on os stack.
// May run during STW, so write barriers are not allowed.
//go:nowritebarrier
//go:nosplit //go:nosplit
func stdcall(fn stdFunction) uintptr { func stdcall(fn stdFunction) uintptr {
gp := getg() gp := getg()
...@@ -367,7 +369,8 @@ func stdcall(fn stdFunction) uintptr { ...@@ -367,7 +369,8 @@ func stdcall(fn stdFunction) uintptr {
if mp.profilehz != 0 { if mp.profilehz != 0 {
// leave pc/sp for cpu profiler // leave pc/sp for cpu profiler
mp.libcallg = gp // gp is on allg, so this WB can be eliminated.
setGNoWriteBarrier(&mp.libcallg, gp)
mp.libcallpc = getcallerpc(unsafe.Pointer(&fn)) mp.libcallpc = getcallerpc(unsafe.Pointer(&fn))
// sp must be the last, because once async cpu profiler finds // sp must be the last, because once async cpu profiler finds
// all three values to be non-zero, it will use them // all three values to be non-zero, it will use them
......
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