diff options
author | Keith Randall <khr@golang.org> | 2015-11-05 12:39:56 -0800 |
---|---|---|
committer | Keith Randall <khr@golang.org> | 2015-11-07 02:42:12 +0000 |
commit | 4b7d5f0b941c75e678d60e84602155ea9e73bab6 (patch) | |
tree | 14adb10bb9f88fbfcda921032ab192230daccb61 /src/runtime/memmove_amd64.s | |
parent | 321a40721bbfcb9bcf6113d4e8afd1bc030f1d8f (diff) | |
download | go-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/memmove_amd64.s')
-rw-r--r-- | src/runtime/memmove_amd64.s | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/runtime/memmove_amd64.s b/src/runtime/memmove_amd64.s index f968435340..e14614d631 100644 --- a/src/runtime/memmove_amd64.s +++ b/src/runtime/memmove_amd64.s @@ -50,7 +50,8 @@ tail: CMPQ BX, $4 JBE move_3or4 CMPQ BX, $8 - JBE move_5through8 + JB move_5through7 + JE move_8 CMPQ BX, $16 JBE move_9through16 CMPQ BX, $32 @@ -131,12 +132,17 @@ move_3or4: MOVW AX, (DI) MOVW CX, -2(DI)(BX*1) RET -move_5through8: +move_5through7: MOVL (SI), AX MOVL -4(SI)(BX*1), CX MOVL AX, (DI) MOVL CX, -4(DI)(BX*1) RET +move_8: + // We need a separate case for 8 to make sure we write pointers atomically. + MOVQ (SI), AX + MOVQ AX, (DI) + RET move_9through16: MOVQ (SI), AX MOVQ -8(SI)(BX*1), CX |