mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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 <austin@google.com> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
c776592a4f
commit
181e26b9fa
21 changed files with 263 additions and 278 deletions
|
|
@ -165,7 +165,7 @@ func newdefer(siz int32) *_defer {
|
|||
sc := deferclass(uintptr(siz))
|
||||
mp := acquirem()
|
||||
if sc < uintptr(len(p{}.deferpool)) {
|
||||
pp := mp.p
|
||||
pp := mp.p.ptr()
|
||||
if len(pp.deferpool[sc]) == 0 && sched.deferpool[sc] != nil {
|
||||
lock(&sched.deferlock)
|
||||
for len(pp.deferpool[sc]) < cap(pp.deferpool[sc])/2 && sched.deferpool[sc] != nil {
|
||||
|
|
@ -223,7 +223,7 @@ func freedefer(d *_defer) {
|
|||
sc := deferclass(uintptr(d.siz))
|
||||
if sc < uintptr(len(p{}.deferpool)) {
|
||||
mp := acquirem()
|
||||
pp := mp.p
|
||||
pp := mp.p.ptr()
|
||||
if len(pp.deferpool[sc]) == cap(pp.deferpool[sc]) {
|
||||
// Transfer half of local cache to the central cache.
|
||||
var first, last *_defer
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue