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:
Michael Hudson-Doyle 2016-01-12 11:40:17 +13:00 committed by Russ Cox
parent fac8202c3f
commit 040932869e
3 changed files with 5 additions and 15 deletions

View file

@ -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)
}

View file

@ -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
}

View file

@ -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