aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCherry Zhang <cherryyz@google.com>2021-01-28 14:57:55 -0500
committerCherry Zhang <cherryyz@google.com>2021-01-29 19:11:07 +0000
commit68058edc39edae96e34225ca163002233b623c97 (patch)
tree91575d0d1ffbde63ed98642fc94c629a02d60a37
parentc8bd8010ff7c0115bf186443119216ba51f09d2b (diff)
downloadgo-68058edc39edae96e34225ca163002233b623c97.tar.gz
go-68058edc39edae96e34225ca163002233b623c97.zip
runtime: document pointer write atomicity for memclrNoHeapPointers
memclrNoHeapPointers is the underlying implementation of typedmemclr and memclrHasPointers, so it still needs to write pointer-aligned words atomically. Document this requirement. Updates #41428. Change-Id: Ice00dee5de7a96a50e51ff019fcef069e8a8406a Reviewed-on: https://go-review.googlesource.com/c/go/+/287692 Trust: Cherry Zhang <cherryyz@google.com> Reviewed-by: Keith Randall <khr@golang.org>
-rw-r--r--src/runtime/memclr_386.s2
-rw-r--r--src/runtime/memclr_amd64.s2
-rw-r--r--src/runtime/memclr_arm.s2
-rw-r--r--src/runtime/memclr_arm64.s2
-rw-r--r--src/runtime/memclr_mips64x.s2
-rw-r--r--src/runtime/memclr_mipsx.s2
-rw-r--r--src/runtime/memclr_plan9_386.s2
-rw-r--r--src/runtime/memclr_plan9_amd64.s2
-rw-r--r--src/runtime/memclr_ppc64x.s2
-rw-r--r--src/runtime/memclr_riscv64.s2
-rw-r--r--src/runtime/memclr_s390x.s2
-rw-r--r--src/runtime/memclr_wasm.s2
-rw-r--r--src/runtime/stubs.go8
13 files changed, 32 insertions, 0 deletions
diff --git a/src/runtime/memclr_386.s b/src/runtime/memclr_386.s
index 65f7196312c..5e090ef09eb 100644
--- a/src/runtime/memclr_386.s
+++ b/src/runtime/memclr_386.s
@@ -9,6 +9,8 @@
// NOTE: Windows externalthreadhandler expects memclr to preserve DX.
+// See memclrNoHeapPointers Go doc for important implementation constraints.
+
// func memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr)
TEXT runtime·memclrNoHeapPointers(SB), NOSPLIT, $0-8
MOVL ptr+0(FP), DI
diff --git a/src/runtime/memclr_amd64.s b/src/runtime/memclr_amd64.s
index d79078fd00b..37fe9745b1b 100644
--- a/src/runtime/memclr_amd64.s
+++ b/src/runtime/memclr_amd64.s
@@ -9,6 +9,8 @@
// NOTE: Windows externalthreadhandler expects memclr to preserve DX.
+// See memclrNoHeapPointers Go doc for important implementation constraints.
+
// func memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr)
TEXT runtime·memclrNoHeapPointers(SB), NOSPLIT, $0-16
MOVQ ptr+0(FP), DI
diff --git a/src/runtime/memclr_arm.s b/src/runtime/memclr_arm.s
index 7326b8be340..f113a1aa2dd 100644
--- a/src/runtime/memclr_arm.s
+++ b/src/runtime/memclr_arm.s
@@ -30,6 +30,8 @@
#define N R12
#define TMP R12 /* N and TMP don't overlap */
+// See memclrNoHeapPointers Go doc for important implementation constraints.
+
// func memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr)
TEXT runtime·memclrNoHeapPointers(SB),NOSPLIT,$0-8
MOVW ptr+0(FP), TO
diff --git a/src/runtime/memclr_arm64.s b/src/runtime/memclr_arm64.s
index a56a6dfb85d..bef77651e48 100644
--- a/src/runtime/memclr_arm64.s
+++ b/src/runtime/memclr_arm64.s
@@ -4,6 +4,8 @@
#include "textflag.h"
+// See memclrNoHeapPointers Go doc for important implementation constraints.
+
// func memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr)
TEXT runtime·memclrNoHeapPointers(SB),NOSPLIT,$0-16
MOVD ptr+0(FP), R0
diff --git a/src/runtime/memclr_mips64x.s b/src/runtime/memclr_mips64x.s
index 4c2292eae85..d7a3251e204 100644
--- a/src/runtime/memclr_mips64x.s
+++ b/src/runtime/memclr_mips64x.s
@@ -7,6 +7,8 @@
#include "go_asm.h"
#include "textflag.h"
+// See memclrNoHeapPointers Go doc for important implementation constraints.
+
// func memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr)
TEXT runtime·memclrNoHeapPointers(SB),NOSPLIT,$0-16
MOVV ptr+0(FP), R1
diff --git a/src/runtime/memclr_mipsx.s b/src/runtime/memclr_mipsx.s
index 1561a23dbe2..eb2a8a7219c 100644
--- a/src/runtime/memclr_mipsx.s
+++ b/src/runtime/memclr_mipsx.s
@@ -14,6 +14,8 @@
#define MOVWLO MOVWL
#endif
+// See memclrNoHeapPointers Go doc for important implementation constraints.
+
// func memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr)
TEXT runtime·memclrNoHeapPointers(SB),NOSPLIT,$0-8
MOVW n+4(FP), R2
diff --git a/src/runtime/memclr_plan9_386.s b/src/runtime/memclr_plan9_386.s
index 5b880ae86f8..54701a94536 100644
--- a/src/runtime/memclr_plan9_386.s
+++ b/src/runtime/memclr_plan9_386.s
@@ -4,6 +4,8 @@
#include "textflag.h"
+// See memclrNoHeapPointers Go doc for important implementation constraints.
+
// func memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr)
TEXT runtime·memclrNoHeapPointers(SB), NOSPLIT, $0-8
MOVL ptr+0(FP), DI
diff --git a/src/runtime/memclr_plan9_amd64.s b/src/runtime/memclr_plan9_amd64.s
index ad383cd6b3d..8c6a1cc7809 100644
--- a/src/runtime/memclr_plan9_amd64.s
+++ b/src/runtime/memclr_plan9_amd64.s
@@ -4,6 +4,8 @@
#include "textflag.h"
+// See memclrNoHeapPointers Go doc for important implementation constraints.
+
// func memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr)
TEXT runtime·memclrNoHeapPointers(SB),NOSPLIT,$0-16
MOVQ ptr+0(FP), DI
diff --git a/src/runtime/memclr_ppc64x.s b/src/runtime/memclr_ppc64x.s
index 072963f7568..75126208942 100644
--- a/src/runtime/memclr_ppc64x.s
+++ b/src/runtime/memclr_ppc64x.s
@@ -6,6 +6,8 @@
#include "textflag.h"
+// See memclrNoHeapPointers Go doc for important implementation constraints.
+
// func memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr)
TEXT runtime·memclrNoHeapPointers(SB), NOSPLIT|NOFRAME, $0-16
MOVD ptr+0(FP), R3
diff --git a/src/runtime/memclr_riscv64.s b/src/runtime/memclr_riscv64.s
index ba7704e805d..54ddaa4560c 100644
--- a/src/runtime/memclr_riscv64.s
+++ b/src/runtime/memclr_riscv64.s
@@ -4,6 +4,8 @@
#include "textflag.h"
+// See memclrNoHeapPointers Go doc for important implementation constraints.
+
// void runtime·memclrNoHeapPointers(void*, uintptr)
TEXT runtime·memclrNoHeapPointers(SB),NOSPLIT,$0-16
MOV ptr+0(FP), T1
diff --git a/src/runtime/memclr_s390x.s b/src/runtime/memclr_s390x.s
index dd14a441cc2..fa657ef66e6 100644
--- a/src/runtime/memclr_s390x.s
+++ b/src/runtime/memclr_s390x.s
@@ -4,6 +4,8 @@
#include "textflag.h"
+// See memclrNoHeapPointers Go doc for important implementation constraints.
+
// func memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr)
TEXT runtime·memclrNoHeapPointers(SB),NOSPLIT|NOFRAME,$0-16
MOVD ptr+0(FP), R4
diff --git a/src/runtime/memclr_wasm.s b/src/runtime/memclr_wasm.s
index 68ffe2f67b5..5a053049f81 100644
--- a/src/runtime/memclr_wasm.s
+++ b/src/runtime/memclr_wasm.s
@@ -4,6 +4,8 @@
#include "textflag.h"
+// See memclrNoHeapPointers Go doc for important implementation constraints.
+
// func memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr)
TEXT runtime·memclrNoHeapPointers(SB), NOSPLIT, $0-16
MOVD ptr+0(FP), R0
diff --git a/src/runtime/stubs.go b/src/runtime/stubs.go
index b55c3c05900..2ee2c74dfe0 100644
--- a/src/runtime/stubs.go
+++ b/src/runtime/stubs.go
@@ -73,7 +73,15 @@ func badsystemstack() {
// *ptr is uninitialized memory (e.g., memory that's being reused
// for a new allocation) and hence contains only "junk".
//
+// memclrNoHeapPointers ensures that if ptr is pointer-aligned, and n
+// is a multiple of the pointer size, then any pointer-aligned,
+// pointer-sized portion is cleared atomically. Despite the function
+// name, this is necessary because this function is the underlying
+// implementation of typedmemclr and memclrHasPointers. See the doc of
+// memmove for more details.
+//
// The (CPU-specific) implementations of this function are in memclr_*.s.
+//
//go:noescape
func memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr)