1
0
mirror of https://github.com/golang/go synced 2024-11-17 16:14:42 -07:00

runtime: update go:notinheap documentation

The rules for go:notinheap were recently tweaked to disallow stack
allocation (CL 249917). This CL updates the documentation about
go:notinheap in runtime/HACKING.md.

Change-Id: Ibca5d9b9d02e1c22c6af1d303aa84c6303a86d92
Reviewed-on: https://go-review.googlesource.com/c/go/+/257357
Trust: Austin Clements <austin@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
Austin Clements 2020-09-24 20:58:33 -04:00
parent 2333c6299f
commit 2e0f8c379f

View File

@ -281,11 +281,12 @@ go:notinheap
------------ ------------
`go:notinheap` applies to type declarations. It indicates that a type `go:notinheap` applies to type declarations. It indicates that a type
must never be allocated from the GC'd heap. Specifically, pointers to must never be allocated from the GC'd heap or on the stack.
this type must always fail the `runtime.inheap` check. The type may be Specifically, pointers to this type must always fail the
used for global variables, for stack variables, or for objects in `runtime.inheap` check. The type may be used for global variables, or
unmanaged memory (e.g., allocated with `sysAlloc`, `persistentalloc`, for objects in unmanaged memory (e.g., allocated with `sysAlloc`,
`fixalloc`, or from a manually-managed span). Specifically: `persistentalloc`, `fixalloc`, or from a manually-managed span).
Specifically:
1. `new(T)`, `make([]T)`, `append([]T, ...)` and implicit heap 1. `new(T)`, `make([]T)`, `append([]T, ...)` and implicit heap
allocation of T are disallowed. (Though implicit allocations are allocation of T are disallowed. (Though implicit allocations are