aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/memmove_wasm.s
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2020-01-06 11:10:26 -0500
committerAustin Clements <austin@google.com>2020-01-22 18:54:48 +0000
commit9b5bd30716914a86619c050f0d75c0da4133b257 (patch)
treee9429c94f4fecb759da0aed31daefa140fb361ed /src/runtime/memmove_wasm.s
parent895b7c85addfffe19b66d8ca71c31799d6e55990 (diff)
downloadgo-9b5bd30716914a86619c050f0d75c0da4133b257.tar.gz
go-9b5bd30716914a86619c050f0d75c0da4133b257.zip
runtime: document special memmove requirements
Unlike C's memmove, Go's memmove must be careful to do indivisible writes of pointer values because it may be racing with the garbage collector reading the heap. We've had various bugs related to this over the years (#36101, #13160, #12552). Indeed, memmove is a great target for optimization and it's easy to forget the special requirements of Go's memmove. The CL documents these (currently unwritten!) requirements. We're also adding a test that should hopefully keep everyone honest going forward, though it's hard to be sure we're hitting all cases of memmove. Change-Id: I2f59f8d8d6fb42d2f10006b55d605b5efd8ddc24 Reviewed-on: https://go-review.googlesource.com/c/go/+/213418 Reviewed-by: Cherry Zhang <cherryyz@google.com>
Diffstat (limited to 'src/runtime/memmove_wasm.s')
-rw-r--r--src/runtime/memmove_wasm.s2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/runtime/memmove_wasm.s b/src/runtime/memmove_wasm.s
index d5e2016930..8525fea35e 100644
--- a/src/runtime/memmove_wasm.s
+++ b/src/runtime/memmove_wasm.s
@@ -4,6 +4,8 @@
#include "textflag.h"
+// See memmove Go doc for important implementation constraints.
+
// func memmove(to, from unsafe.Pointer, n uintptr)
TEXT runtime·memmove(SB), NOSPLIT, $0-24
MOVD to+0(FP), R0