]> Cypherpunks repositories - gostls13.git/commitdiff
runtime/internal/atomic: use //go:noinline to prevent inlining, not assembly nop
authorMichael Hudson-Doyle <michael.hudson@canonical.com>
Mon, 11 Jan 2016 22:40:17 +0000 (11:40 +1300)
committerRuss Cox <rsc@golang.org>
Wed, 13 Jan 2016 01:51:48 +0000 (01:51 +0000)
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>
src/runtime/internal/atomic/atomic_386.go
src/runtime/internal/atomic/atomic_amd64x.go
src/runtime/internal/atomic/stubs.go

index ae7b58325a66e887ec076e3ac9edae2bbf988dd2..f4c50b0be155277ae6439ffd7693beb92b50ab7c 100644 (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)
 }
 
index 7f6c892364e5f3c6e35463fef17e2e5619274865..bd40fb3ea25bcf26bdfc84cc1ee9f6ffdcbf270d 100644 (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
 }
 
index 826829938d7a43c394c05d3d92f564f219099d40..497b98046d864cb3f64013b997b46f13ed2e632b 100644 (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