Skip to content
This repository has been archived by the owner on May 2, 2018. It is now read-only.

Commit

Permalink
runtime: make "write barriers are not allowed" comments more precise
Browse files Browse the repository at this point in the history
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/8209
Reviewed-by: Minux Ma <[email protected]>
Reviewed-by: Rick Hudson <[email protected]>
  • Loading branch information
aclements committed Mar 30, 2015
1 parent fa3ad1e commit 9e6f7aa
Show file tree
Hide file tree
Showing 11 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/runtime/os1_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/os1_dragonfly.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/os1_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/os1_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
/*
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/os1_nacl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/os1_netbsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/os1_openbsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/os1_plan9.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/os1_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/os3_solaris.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/proc1.go
Original file line number Diff line number Diff line change
Expand Up @@ -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_)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 9e6f7aa

Please sign in to comment.