From 181e26b9fa3c85ca5a512a51278b3f22f6e64dc9 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Fri, 17 Apr 2015 00:21:30 -0400 Subject: runtime: replace func-based write barrier skipping with type-based This CL revises CL 7504 to use explicitly uintptr types for the struct fields that are going to be updated sometimes without write barriers. The result is that the fields are now updated *always* without write barriers. This approach has two important properties: 1) Now the GC never looks at the field, so if the missing reference could cause a problem, it will do so all the time, not just when the write barrier is missed at just the right moment. 2) Now a write barrier never happens for the field, avoiding the (correct) detection of inconsistent write barriers when GODEBUG=wbshadow=1. Change-Id: Iebd3962c727c0046495cc08914a8dc0808460e0e Reviewed-on: https://go-review.googlesource.com/9019 Reviewed-by: Austin Clements Run-TryBot: Russ Cox TryBot-Result: Gobot Gobot --- src/runtime/netpoll_kqueue.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/runtime/netpoll_kqueue.go') diff --git a/src/runtime/netpoll_kqueue.go b/src/runtime/netpoll_kqueue.go index 080964bb72..01445dc231 100644 --- a/src/runtime/netpoll_kqueue.go +++ b/src/runtime/netpoll_kqueue.go @@ -62,9 +62,9 @@ func netpollarm(pd *pollDesc, mode int) { // Polls for ready network connections. // Returns list of goroutines that become runnable. -func netpoll(block bool) (gp *g) { +func netpoll(block bool) *g { if kq == -1 { - return + return nil } var tp *timespec var ts timespec @@ -81,6 +81,7 @@ retry: } goto retry } + var gp guintptr for i := 0; i < int(n); i++ { ev := &events[i] var mode int32 @@ -91,11 +92,11 @@ retry: mode += 'w' } if mode != 0 { - netpollready((**g)(noescape(unsafe.Pointer(&gp))), (*pollDesc)(unsafe.Pointer(ev.udata)), mode) + netpollready(&gp, (*pollDesc)(unsafe.Pointer(ev.udata)), mode) } } - if block && gp == nil { + if block && gp == 0 { goto retry } - return gp + return gp.ptr() } -- cgit v1.3-5-g9baa