aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/memclr_amd64.s
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2015-11-05 12:39:56 -0800
committerKeith Randall <khr@golang.org>2015-11-07 02:42:12 +0000
commit4b7d5f0b941c75e678d60e84602155ea9e73bab6 (patch)
tree14adb10bb9f88fbfcda921032ab192230daccb61 /src/runtime/memclr_amd64.s
parent321a40721bbfcb9bcf6113d4e8afd1bc030f1d8f (diff)
downloadgo-4b7d5f0b941c75e678d60e84602155ea9e73bab6.tar.gz
go-4b7d5f0b941c75e678d60e84602155ea9e73bab6.zip
runtime: memmove/memclr pointers atomically
Make sure that we're moving or zeroing pointers atomically. Anything that is a multiple of pointer size and at least pointer aligned might have pointers in it. All the code looks ok except for the 1-pointer-sized moves. Fixes #13160 Update #12552 Change-Id: Ib97d9b918fa9f4cc5c56c67ed90255b7fdfb7b45 Reviewed-on: https://go-review.googlesource.com/16668 Reviewed-by: Dmitry Vyukov <dvyukov@google.com> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/runtime/memclr_amd64.s')
-rw-r--r--src/runtime/memclr_amd64.s9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/runtime/memclr_amd64.s b/src/runtime/memclr_amd64.s
index ec24f1db23..3e2c4b241a 100644
--- a/src/runtime/memclr_amd64.s
+++ b/src/runtime/memclr_amd64.s
@@ -23,7 +23,8 @@ tail:
CMPQ BX, $4
JBE _3or4
CMPQ BX, $8
- JBE _5through8
+ JB _5through7
+ JE _8
CMPQ BX, $16
JBE _9through16
PXOR X0, X0
@@ -71,10 +72,14 @@ _3or4:
MOVW AX, (DI)
MOVW AX, -2(DI)(BX*1)
RET
-_5through8:
+_5through7:
MOVL AX, (DI)
MOVL AX, -4(DI)(BX*1)
RET
+_8:
+ // We need a separate case for 8 to make sure we clear pointers atomically.
+ MOVQ AX, (DI)
+ RET
_9through16:
MOVQ AX, (DI)
MOVQ AX, -8(DI)(BX*1)