github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/runtime/mwbbuf.go (about) 1 // Copyright 2017 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // This implements the write barrier buffer. The write barrier itself 6 // is gcWriteBarrier and is implemented in assembly. 7 // 8 // See mbarrier.go for algorithmic details on the write barrier. This 9 // file deals only with the buffer. 10 // 11 // The write barrier has a fast path and a slow path. The fast path 12 // simply enqueues to a per-P write barrier buffer. It's written in 13 // assembly and doesn't clobber any general purpose registers, so it 14 // doesn't have the usual overheads of a Go call. 15 // 16 // When the buffer fills up, the write barrier invokes the slow path 17 // (wbBufFlush) to flush the buffer to the GC work queues. In this 18 // path, since the compiler didn't spill registers, we spill *all* 19 // registers and disallow any GC safe points that could observe the 20 // stack frame (since we don't know the types of the spilled 21 // registers). 22 23 package runtime