From d3daeb5267b626db36adf2f39c36f6caf94447e3 Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Tue, 25 Oct 2022 17:58:07 -0700 Subject: runtime: remove the restriction that write barrier ptrs come in pairs Future CLs will remove the invariant that pointers are always put in the write barrier in pairs. The behavior of the assembly code changes a bit, where instead of writing the pointers unconditionally and then checking for overflow, check for overflow first and then write the pointers. Also changed the write barrier flush function to not take the src/dst as arguments. Change-Id: I2ef708038367b7b82ea67cbaf505a1d5904c775c Reviewed-on: https://go-review.googlesource.com/c/go/+/447779 Run-TryBot: Keith Randall Reviewed-by: Cherry Mui Reviewed-by: Michael Knyszek TryBot-Bypass: Keith Randall --- src/runtime/atomic_pointer.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/runtime/atomic_pointer.go') diff --git a/src/runtime/atomic_pointer.go b/src/runtime/atomic_pointer.go index 26dfbfc2cc..b61bf0b8b2 100644 --- a/src/runtime/atomic_pointer.go +++ b/src/runtime/atomic_pointer.go @@ -21,9 +21,9 @@ import ( //go:nosplit func atomicwb(ptr *unsafe.Pointer, new unsafe.Pointer) { slot := (*uintptr)(unsafe.Pointer(ptr)) - if !getg().m.p.ptr().wbBuf.putFast(*slot, uintptr(new)) { - wbBufFlush() - } + buf := getg().m.p.ptr().wbBuf.get2() + buf[0] = *slot + buf[1] = uintptr(new) } // atomicstorep performs *ptr = new atomically and invokes a write barrier. -- cgit v1.3