aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2015-06-07 21:45:39 -0400
committerRuss Cox <rsc@golang.org>2015-06-17 14:23:00 +0000
commit08e25fc1ba397e02ec776561ed73b7f9a8b94392 (patch)
tree5cfcfdf406d173039a1894ee61c6e99044389bff /src/runtime
parente3dc59f33d87f93a28a913ec56db25de3a654f0c (diff)
downloadgo-08e25fc1ba397e02ec776561ed73b7f9a8b94392.tar.xz
cmd/compile: introduce //go:systemstack annotation
//go:systemstack means that the function must run on the system stack. Add one use in runtime as a demonstration. Fixes #9174. Change-Id: I8d4a509cb313541426157da703f1c022e964ace4 Reviewed-on: https://go-review.googlesource.com/10840 Reviewed-by: Austin Clements <austin@google.com> Run-TryBot: Austin Clements <austin@google.com>
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/malloc.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go
index 7fd54983ec..25371ab776 100644
--- a/src/runtime/malloc.go
+++ b/src/runtime/malloc.go
@@ -797,6 +797,17 @@ var globalAlloc struct {
// Intended for things like function/type/debug-related persistent data.
// If align is 0, uses default align (currently 8).
func persistentalloc(size, align uintptr, sysStat *uint64) unsafe.Pointer {
+ var p unsafe.Pointer
+ systemstack(func() {
+ p = persistentalloc1(size, align, sysStat)
+ })
+ return p
+}
+
+// Must run on system stack because stack growth can (re)invoke it.
+// See issue 9174.
+//go:systemstack
+func persistentalloc1(size, align uintptr, sysStat *uint64) unsafe.Pointer {
const (
chunk = 256 << 10
maxBlock = 64 << 10 // VM reservation granularity is 64K on windows