1
0
mirror of https://github.com/golang/go synced 2024-11-17 14:04:48 -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
must never be allocated from the GC'd heap. Specifically, pointers to
this type must always fail the `runtime.inheap` check. The type may be
used for global variables, for stack variables, or for objects in
unmanaged memory (e.g., allocated with `sysAlloc`, `persistentalloc`,
`fixalloc`, or from a manually-managed span). Specifically:
must never be allocated from the GC'd heap or on the stack.
Specifically, pointers to this type must always fail the
`runtime.inheap` check. The type may be used for global variables, or
for objects in unmanaged memory (e.g., allocated with `sysAlloc`,
`persistentalloc`, `fixalloc`, or from a manually-managed span).
Specifically:
1. `new(T)`, `make([]T)`, `append([]T, ...)` and implicit heap
allocation of T are disallowed. (Though implicit allocations are