diff options
| author | Cuong Manh Le <cuong.manhle.vn@gmail.com> | 2022-08-07 17:43:57 +0700 |
|---|---|---|
| committer | Cuong Manh Le <cuong.manhle.vn@gmail.com> | 2022-08-19 00:29:18 +0000 |
| commit | a719a78c1b36141af68d84970695fe95263fb896 (patch) | |
| tree | c985cb9d95db5fdc57c5cf347f544b93bed82b1d /src/runtime/malloc.go | |
| parent | 833367e98af838a2511ee7e4e19dc8f1da7b8ed7 (diff) | |
| download | go-a719a78c1b36141af68d84970695fe95263fb896.tar.xz | |
runtime: add and use runtime/internal/sys.NotInHeap
Updates #46731
Change-Id: Ic2208c8bb639aa1e390be0d62e2bd799ecf20654
Reviewed-on: https://go-review.googlesource.com/c/go/+/421878
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Diffstat (limited to 'src/runtime/malloc.go')
| -rw-r--r-- | src/runtime/malloc.go | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go index 0219401c83..205c6d44a8 100644 --- a/src/runtime/malloc.go +++ b/src/runtime/malloc.go @@ -1330,7 +1330,8 @@ var persistentChunks *notInHeap // The returned memory will be zeroed. // sysStat must be non-nil. // -// Consider marking persistentalloc'd types go:notinheap. +// Consider marking persistentalloc'd types not in heap by embedding +// runtime/internal/sys.NotInHeap. func persistentalloc(size, align uintptr, sysStat *sysMemStat) unsafe.Pointer { var p *notInHeap systemstack(func() { @@ -1471,14 +1472,12 @@ func (l *linearAlloc) alloc(size, align uintptr, sysStat *sysMemStat) unsafe.Poi // notInHeap is off-heap memory allocated by a lower-level allocator // like sysAlloc or persistentAlloc. // -// In general, it's better to use real types marked as go:notinheap, -// but this serves as a generic type for situations where that isn't -// possible (like in the allocators). +// In general, it's better to use real types which embed +// runtime/internal/sys.NotInHeap, but this serves as a generic type +// for situations where that isn't possible (like in the allocators). // // TODO: Use this as the return type of sysAlloc, persistentAlloc, etc? -// -//go:notinheap -type notInHeap struct{} +type notInHeap struct{ _ sys.NotInHeap } func (p *notInHeap) add(bytes uintptr) *notInHeap { return (*notInHeap)(unsafe.Pointer(uintptr(unsafe.Pointer(p)) + bytes)) |
