mirror of
https://github.com/golang/go
synced 2024-11-26 15:06:52 -07:00
runtime: eliminate write barriers from dropg
Currently this contains no write barriers because it's writing nil pointers, but with the hybrid barrier, even these will produce write barriers. However, since these are *gs and *ms, they don't need write barriers, so we can simply eliminate them. Updates #17503. Change-Id: Ib188a60492c5cfb352814bf9b2bcb2941fb7d6c0 Reviewed-on: https://go-review.googlesource.com/31570 Reviewed-by: Rick Hudson <rlh@golang.org>
This commit is contained in:
parent
85c22bc3a5
commit
8044b77a57
@ -2175,8 +2175,8 @@ top:
|
||||
func dropg() {
|
||||
_g_ := getg()
|
||||
|
||||
_g_.m.curg.m = nil
|
||||
_g_.m.curg = nil
|
||||
setMNoWB(&_g_.m.curg.m, nil)
|
||||
setGNoWB(&_g_.m.curg, nil)
|
||||
}
|
||||
|
||||
func parkunlock_c(gp *g, lock unsafe.Pointer) bool {
|
||||
|
@ -205,6 +205,14 @@ func (gp *guintptr) cas(old, new guintptr) bool {
|
||||
return atomic.Casuintptr((*uintptr)(unsafe.Pointer(gp)), uintptr(old), uintptr(new))
|
||||
}
|
||||
|
||||
// setGNoWB performs *gp = new without a write barrier.
|
||||
// For times when it's impractical to use a guintptr.
|
||||
//go:nosplit
|
||||
//go:nowritebarrier
|
||||
func setGNoWB(gp **g, new *g) {
|
||||
(*guintptr)(unsafe.Pointer(gp)).set(new)
|
||||
}
|
||||
|
||||
type puintptr uintptr
|
||||
|
||||
//go:nosplit
|
||||
@ -221,6 +229,14 @@ func (mp muintptr) ptr() *m { return (*m)(unsafe.Pointer(mp)) }
|
||||
//go:nosplit
|
||||
func (mp *muintptr) set(m *m) { *mp = muintptr(unsafe.Pointer(m)) }
|
||||
|
||||
// setMNoWB performs *mp = new without a write barrier.
|
||||
// For times when it's impractical to use an muintptr.
|
||||
//go:nosplit
|
||||
//go:nowritebarrier
|
||||
func setMNoWB(mp **m, new *m) {
|
||||
(*muintptr)(unsafe.Pointer(mp)).set(new)
|
||||
}
|
||||
|
||||
type gobuf struct {
|
||||
// The offsets of sp, pc, and g are known to (hard-coded in) libmach.
|
||||
sp uintptr
|
||||
|
Loading…
Reference in New Issue
Block a user