lab.nexedi.com will be down from Thursday, 20 March 2025, 07:30:00 UTC for a duration of approximately 2 hours

Commit 04093286 authored by Michael Hudson-Doyle's avatar Michael Hudson-Doyle Committed by Russ Cox

runtime/internal/atomic: use //go:noinline to prevent inlining, not assembly nop

A bit cleanuppy for 1.6 maybe, but something I happened to notice.

Change-Id: I70f3b48445f4f527d67f7b202b6171195440b09f
Reviewed-on: https://go-review.googlesource.com/18550Reviewed-by: default avatarRuss Cox <rsc@golang.org>
parent fac8202c
...@@ -8,19 +8,15 @@ package atomic ...@@ -8,19 +8,15 @@ package atomic
import "unsafe" import "unsafe"
// The calls to nop are to keep these functions from being inlined.
// If they are inlined we have no guarantee that later rewrites of the
// code by optimizers will preserve the relative order of memory accesses.
//go:nosplit //go:nosplit
//go:noinline
func Load(ptr *uint32) uint32 { func Load(ptr *uint32) uint32 {
nop()
return *ptr return *ptr
} }
//go:nosplit //go:nosplit
//go:noinline
func Loadp(ptr unsafe.Pointer) unsafe.Pointer { func Loadp(ptr unsafe.Pointer) unsafe.Pointer {
nop()
return *(*unsafe.Pointer)(ptr) return *(*unsafe.Pointer)(ptr)
} }
......
...@@ -8,25 +8,21 @@ package atomic ...@@ -8,25 +8,21 @@ package atomic
import "unsafe" import "unsafe"
// The calls to nop are to keep these functions from being inlined.
// If they are inlined we have no guarantee that later rewrites of the
// code by optimizers will preserve the relative order of memory accesses.
//go:nosplit //go:nosplit
//go:noinline
func Load(ptr *uint32) uint32 { func Load(ptr *uint32) uint32 {
nop()
return *ptr return *ptr
} }
//go:nosplit //go:nosplit
//go:noinline
func Loadp(ptr unsafe.Pointer) unsafe.Pointer { func Loadp(ptr unsafe.Pointer) unsafe.Pointer {
nop()
return *(*unsafe.Pointer)(ptr) return *(*unsafe.Pointer)(ptr)
} }
//go:nosplit //go:nosplit
//go:noinline
func Load64(ptr *uint64) uint64 { func Load64(ptr *uint64) uint64 {
nop()
return *ptr return *ptr
} }
......
...@@ -12,8 +12,6 @@ func Cas(ptr *uint32, old, new uint32) bool ...@@ -12,8 +12,6 @@ func Cas(ptr *uint32, old, new uint32) bool
// NO go:noescape annotation; see atomic_pointer.go. // NO go:noescape annotation; see atomic_pointer.go.
func Casp1(ptr *unsafe.Pointer, old, new unsafe.Pointer) bool func Casp1(ptr *unsafe.Pointer, old, new unsafe.Pointer) bool
func nop() // call to prevent inlining of function body
//go:noescape //go:noescape
func Casuintptr(ptr *uintptr, old, new uintptr) bool func Casuintptr(ptr *uintptr, old, new uintptr) bool
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment