Skip to content

Commit f1b7b2f

Browse files
committed
runtime: make mSpanStateBox accessors nosplit
get, at least, is called from typedmemclr which must not be interruptible. These were previously nosplit by accident before CL 424395 (the only call they had was an intrinsic, so they were leaf functions, so they had no prologue). After CL 424395 they contained a call (in noinline builds), thus had a prologue, thus had a suspension point. I have no idea how we might test this. This is another motivating use case for having a nosplitrec directive in the runtime. Fixes #55156 Fixes #54779 Fixes #54906 Fixes #54907 Change-Id: I851d733d71bda7172c4c96e027657e22b499ee00 Reviewed-on: https://go-review.googlesource.com/c/go/+/431919 Reviewed-by: Cherry Mui <[email protected]> Run-TryBot: Keith Randall <[email protected]> Reviewed-by: Keith Randall <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent 2d74194 commit f1b7b2f

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/runtime/mbarrier.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,8 @@ func reflect_typedslicecopy(elemType *_type, dst, src slice) int {
311311
// If the caller knows that typ has pointers, it can alternatively
312312
// call memclrHasPointers.
313313
//
314+
// TODO: A "go:nosplitrec" annotation would be perfect for this.
315+
//
314316
//go:nosplit
315317
func typedmemclr(typ *_type, ptr unsafe.Pointer) {
316318
if writeBarrier.needed && typ.ptrdata != 0 {

src/runtime/mheap.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,10 +362,17 @@ type mSpanStateBox struct {
362362
s atomic.Uint8
363363
}
364364

365+
// It is nosplit to match get, below.
366+
367+
//go:nosplit
365368
func (b *mSpanStateBox) set(s mSpanState) {
366369
b.s.Store(uint8(s))
367370
}
368371

372+
// It is nosplit because it's called indirectly by typedmemclr,
373+
// which must not be preempted.
374+
375+
//go:nosplit
369376
func (b *mSpanStateBox) get() mSpanState {
370377
return mSpanState(b.s.Load())
371378
}

0 commit comments

Comments
 (0)