]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: mark atomic methods which call nosplit functions as nosplit
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Fri, 12 Aug 2022 09:38:56 +0000 (16:38 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Fri, 12 Aug 2022 15:47:04 +0000 (15:47 +0000)
Fixes #54411

Change-Id: I482ebca7365862bfb82a9daf8111c6f395aa1170
Reviewed-on: https://go-review.googlesource.com/c/go/+/423255
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/runtime/internal/atomic/types.go

index 784acaadc1dd1b1036823423677d7addd63ee730..dbacb86704a53f2bedbeb723c3bb2deb5f55c049 100644 (file)
@@ -100,6 +100,8 @@ type Uint8 struct {
 }
 
 // Load accesses and returns the value atomically.
+//
+//go:nosplit
 func (u *Uint8) Load() uint8 {
        return Load8(&u.value)
 }
@@ -136,6 +138,8 @@ type Bool struct {
 }
 
 // Load accesses and returns the value atomically.
+//
+//go:nosplit
 func (b *Bool) Load() bool {
        return b.u.Load() != 0
 }
@@ -158,6 +162,8 @@ type Uint32 struct {
 }
 
 // Load accesses and returns the value atomically.
+//
+//go:nosplit
 func (u *Uint32) Load() uint32 {
        return Load(&u.value)
 }
@@ -169,6 +175,8 @@ func (u *Uint32) Load() uint32 {
 // on this thread can be observed to occur before it.
 //
 // WARNING: Use sparingly and with great care.
+//
+//go:nosplit
 func (u *Uint32) LoadAcquire() uint32 {
        return LoadAcq(&u.value)
 }
@@ -255,6 +263,8 @@ type Uint64 struct {
 }
 
 // Load accesses and returns the value atomically.
+//
+//go:nosplit
 func (u *Uint64) Load() uint64 {
        return Load64(&u.value)
 }
@@ -283,6 +293,8 @@ func (u *Uint64) Swap(value uint64) uint64 {
 //
 // This operation wraps around in the usual
 // two's-complement way.
+//
+//go:nosplit
 func (u *Uint64) Add(delta int64) uint64 {
        return Xadd64(&u.value, delta)
 }
@@ -307,6 +319,8 @@ func (u *Uintptr) Load() uintptr {
 // on this thread can be observed to occur before it.
 //
 // WARNING: Use sparingly and with great care.
+//
+//go:nosplit
 func (u *Uintptr) LoadAcquire() uintptr {
        return LoadAcquintptr(&u.value)
 }
@@ -361,6 +375,8 @@ type Float64 struct {
 }
 
 // Load accesses and returns the value atomically.
+//
+//go:nosplit
 func (f *Float64) Load() float64 {
        r := f.u.Load()
        return *(*float64)(unsafe.Pointer(&r))
@@ -386,6 +402,8 @@ type UnsafePointer struct {
 }
 
 // Load accesses and returns the value atomically.
+//
+//go:nosplit
 func (u *UnsafePointer) Load() unsafe.Pointer {
        return Loadp(unsafe.Pointer(&u.value))
 }
@@ -420,6 +438,8 @@ type Pointer[T any] struct {
 }
 
 // Load accesses and returns the value atomically.
+//
+//go:nosplit
 func (p *Pointer[T]) Load() *T {
        return (*T)(p.u.Load())
 }