From: Michael Hudson-Doyle Date: Mon, 11 Jan 2016 22:40:17 +0000 (+1300) Subject: runtime/internal/atomic: use //go:noinline to prevent inlining, not assembly nop X-Git-Tag: go1.6beta2~24 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=040932869ed8c9549e18f7b3ca2ea844b0e28978;p=gostls13.git 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 --- diff --git a/src/runtime/internal/atomic/atomic_386.go b/src/runtime/internal/atomic/atomic_386.go index ae7b58325a..f4c50b0be1 100644 --- a/src/runtime/internal/atomic/atomic_386.go +++ b/src/runtime/internal/atomic/atomic_386.go @@ -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) } diff --git a/src/runtime/internal/atomic/atomic_amd64x.go b/src/runtime/internal/atomic/atomic_amd64x.go index 7f6c892364..bd40fb3ea2 100644 --- a/src/runtime/internal/atomic/atomic_amd64x.go +++ b/src/runtime/internal/atomic/atomic_amd64x.go @@ -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 } diff --git a/src/runtime/internal/atomic/stubs.go b/src/runtime/internal/atomic/stubs.go index 826829938d..497b98046d 100644 --- a/src/runtime/internal/atomic/stubs.go +++ b/src/runtime/internal/atomic/stubs.go @@ -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