diff --git a/src/runtime/mbarrier.go b/src/runtime/mbarrier.go index c3b45415a9533..efe6c4f2d6346 100644 --- a/src/runtime/mbarrier.go +++ b/src/runtime/mbarrier.go @@ -311,6 +311,8 @@ func reflect_typedslicecopy(elemType *_type, dst, src slice) int { // If the caller knows that typ has pointers, it can alternatively // call memclrHasPointers. // +// TODO: A "go:nosplitrec" annotation would be perfect for this. +// //go:nosplit func typedmemclr(typ *_type, ptr unsafe.Pointer) { if writeBarrier.needed && typ.ptrdata != 0 { diff --git a/src/runtime/mheap.go b/src/runtime/mheap.go index c8a6cd29362e9..995cb2ae9c2cc 100644 --- a/src/runtime/mheap.go +++ b/src/runtime/mheap.go @@ -362,10 +362,17 @@ type mSpanStateBox struct { s atomic.Uint8 } +// It is nosplit to match get, below. + +//go:nosplit func (b *mSpanStateBox) set(s mSpanState) { b.s.Store(uint8(s)) } +// It is nosplit because it's called indirectly by typedmemclr, +// which must not be preempted. + +//go:nosplit func (b *mSpanStateBox) get() mSpanState { return mSpanState(b.s.Load()) }