mirror of
https://github.com/golang/go
synced 2024-09-15 22:20:06 +00:00
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/18550 Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
parent
fac8202c3f
commit
040932869e
|
@ -8,19 +8,15 @@ package atomic
|
|||
|
||||
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:noinline
|
||||
func Load(ptr *uint32) uint32 {
|
||||
nop()
|
||||
return *ptr
|
||||
}
|
||||
|
||||
//go:nosplit
|
||||
//go:noinline
|
||||
func Loadp(ptr unsafe.Pointer) unsafe.Pointer {
|
||||
nop()
|
||||
return *(*unsafe.Pointer)(ptr)
|
||||
}
|
||||
|
||||
|
|
|
@ -8,25 +8,21 @@ package atomic
|
|||
|
||||
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:noinline
|
||||
func Load(ptr *uint32) uint32 {
|
||||
nop()
|
||||
return *ptr
|
||||
}
|
||||
|
||||
//go:nosplit
|
||||
//go:noinline
|
||||
func Loadp(ptr unsafe.Pointer) unsafe.Pointer {
|
||||
nop()
|
||||
return *(*unsafe.Pointer)(ptr)
|
||||
}
|
||||
|
||||
//go:nosplit
|
||||
//go:noinline
|
||||
func Load64(ptr *uint64) uint64 {
|
||||
nop()
|
||||
return *ptr
|
||||
}
|
||||
|
||||
|
|
|
@ -12,8 +12,6 @@ func Cas(ptr *uint32, old, new uint32) bool
|
|||
// NO go:noescape annotation; see atomic_pointer.go.
|
||||
func Casp1(ptr *unsafe.Pointer, old, new unsafe.Pointer) bool
|
||||
|
||||
func nop() // call to prevent inlining of function body
|
||||
|
||||
//go:noescape
|
||||
func Casuintptr(ptr *uintptr, old, new uintptr) bool
|
||||
|
||||
|
|
Loading…
Reference in a new issue