mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00: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
2 changed files with 18 additions and 2 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue