Commit 9e6f7aac authored by Austin Clements's avatar Austin Clements

runtime: make "write barriers are not allowed" comments more precise

Currently, various functions are marked with the comment

  // May run without a P, so write barriers are not allowed.

However, "running without a P" is ambiguous. We intended these to mean
that m.p may be nil (which is the condition checked by the write
barrier). The comment could also be taken to mean that a
stop-the-world may happen, which is not the case for these functions
because they run in situations where there is in fact a function on
the stack holding a P locally, it just isn't in m.p.

Change these comments to state precisely what we mean, that m.p may be
nil.

Change-Id: I4a4a1d26aebd455e5067540e13b9f96a7482146c
Reviewed-on: https://go-review.googlesource.com/8209Reviewed-by: default avatarMinux Ma <minux@golang.org>
Reviewed-by: default avatarRick Hudson <rlh@golang.org>
parent fa3ad1eb
......@@ -71,7 +71,7 @@ func goenvs() {
}
}
// May run without a P, so write barriers are not allowed.
// May run with m.p==nil, so write barriers are not allowed.
//go:nowritebarrier
func newosproc(mp *m, stk unsafe.Pointer) {
mp.tls[0] = uintptr(mp.id) // so 386 asm can find it
......
......@@ -71,7 +71,7 @@ func futexwakeup(addr *uint32, cnt uint32) {
func lwp_start(uintptr)
// May run without a P, so write barriers are not allowed.
// May run with m.p==nil, so write barriers are not allowed.
//go:nowritebarrier
func newosproc(mp *m, stk unsafe.Pointer) {
if false {
......
......@@ -67,7 +67,7 @@ func futexwakeup(addr *uint32, cnt uint32) {
func thr_start()
// May run without a P, so write barriers are not allowed.
// May run with m.p==nil, so write barriers are not allowed.
//go:nowritebarrier
func newosproc(mp *m, stk unsafe.Pointer) {
if false {
......
......@@ -113,7 +113,7 @@ const (
_CLONE_NEWIPC = 0x8000000
)
// May run without a P, so write barriers are not allowed.
// May run with m.p==nil, so write barriers are not allowed.
//go:nowritebarrier
func newosproc(mp *m, stk unsafe.Pointer) {
/*
......
......@@ -67,7 +67,7 @@ func usleep(us uint32) {
func mstart_nacl()
// May run without a P, so write barriers are not allowed.
// May run with m.p==nil, so write barriers are not allowed.
//go:nowritebarrier
func newosproc(mp *m, stk unsafe.Pointer) {
mp.tls[0] = uintptr(unsafe.Pointer(mp.g0))
......
......@@ -89,7 +89,7 @@ func semawakeup(mp *m) {
}
}
// May run without a P, so write barriers are not allowed.
// May run with m.p==nil, so write barriers are not allowed.
//go:nowritebarrier
func newosproc(mp *m, stk unsafe.Pointer) {
if false {
......
......@@ -98,7 +98,7 @@ func semawakeup(mp *m) {
}
}
// May run without a P, so write barriers are not allowed.
// May run with m.p==nil, so write barriers are not allowed.
//go:nowritebarrier
func newosproc(mp *m, stk unsafe.Pointer) {
if false {
......
......@@ -183,7 +183,7 @@ func exit(e int) {
exits(&status[0])
}
// May run without a P, so write barriers are not allowed.
// May run with m.p==nil, so write barriers are not allowed.
//go:nowritebarrier
func newosproc(mp *m, stk unsafe.Pointer) {
if false {
......
......@@ -295,7 +295,7 @@ func semacreate() uintptr {
return stdcall4(_CreateEventA, 0, 0, 0, 0)
}
// May run without a P, so write barriers are not allowed.
// May run with m.p==nil, so write barriers are not allowed.
//go:nowritebarrier
func newosproc(mp *m, stk unsafe.Pointer) {
const _STACK_SIZE_PARAM_IS_A_RESERVATION = 0x00010000
......
......@@ -131,7 +131,7 @@ func osinit() {
func tstart_sysvicall()
// May run without a P, so write barriers are not allowed.
// May run with m.p==nil, so write barriers are not allowed.
//go:nowritebarrier
func newosproc(mp *m, _ unsafe.Pointer) {
var (
......
......@@ -973,7 +973,7 @@ func unlockextra(mp *m) {
// Create a new m. It will start off with a call to fn, or else the scheduler.
// fn needs to be static and not a heap allocated closure.
// May run without a P, so write barriers are not allowed.
// May run with m.p==nil, so write barriers are not allowed.
//go:nowritebarrier
func newm(fn func(), _p_ *p) {
mp := allocm(_p_)
......@@ -1035,7 +1035,7 @@ func mspinning() {
// Schedules some M to run the p (creates an M if necessary).
// If p==nil, tries to get an idle P, if no idle P's does nothing.
// May run without a P, so write barriers are not allowed.
// May run with m.p==nil, so write barriers are not allowed.
//go:nowritebarrier
func startm(_p_ *p, spinning bool) {
lock(&sched.lock)
......
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