]> Cypherpunks repositories - gostls13.git/commit
runtime, sync/atomic: add write barrier for atomic write of pointer
authorRuss Cox <rsc@golang.org>
Tue, 23 Dec 2014 03:50:42 +0000 (22:50 -0500)
committerRuss Cox <rsc@golang.org>
Tue, 6 Jan 2015 00:27:06 +0000 (00:27 +0000)
commit7b4df8f018ec01df3ecbd9961c769e7199853363
tree08d6f4c8dcd3d95cd2418fe94445edab7025f158
parenteafc482d4f091c4ddd2178098d94831d1e2f25ab
runtime, sync/atomic: add write barrier for atomic write of pointer

Add write barrier to atomic operations manipulating pointers.

In general an atomic write of a pointer word may indicate racy accesses,
so there is no strictly safe way to attempt to keep the shadow copy
in sync with the real one. Instead, mark the shadow copy as not used.

Redirect sync/atomic pointer routines back to the runtime ones,
so that there is only one copy of the write barrier and shadow logic.
In time we might consider doing this for most of the sync/atomic
functions, but for now only the pointer routines need that treatment.

Found with GODEBUG=wbshadow=1 mode.
Eventually that will run automatically, but right now
it still detects other missing write barriers.

Change-Id: I852936b9a111a6cb9079cfaf6bd78b43016c0242
Reviewed-on: https://go-review.googlesource.com/2066
Reviewed-by: Rick Hudson <rlh@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
15 files changed:
src/runtime/atomic_386.go
src/runtime/atomic_amd64x.go
src/runtime/atomic_arm.go
src/runtime/atomic_pointer.go [new file with mode: 0644]
src/runtime/atomic_ppc64x.go
src/runtime/race_amd64.s
src/runtime/stubs.go
src/sync/atomic/asm_386.s
src/sync/atomic/asm_amd64.s
src/sync/atomic/asm_amd64p32.s
src/sync/atomic/asm_freebsd_arm.s
src/sync/atomic/asm_linux_arm.s
src/sync/atomic/asm_nacl_arm.s
src/sync/atomic/asm_netbsd_arm.s
src/sync/atomic/asm_ppc64x.s