]> Cypherpunks.ru repositories - gostls13.git/commit
runtime: make the span allocation purpose more explicit
authorMichael Anthony Knyszek <mknyszek@google.com>
Wed, 29 Jul 2020 19:00:37 +0000 (19:00 +0000)
committerMichael Knyszek <mknyszek@google.com>
Mon, 26 Oct 2020 17:27:14 +0000 (17:27 +0000)
commitdc02578ac8bb27359c7d0451ca249e47bdef2a9e
treeded07c5efca6a2266a8a033d715282a3705f796d
parentc8638498008f9874dc5a48734418e0fbea08cee9
runtime: make the span allocation purpose more explicit

This change modifies mheap's span allocation API to have each caller
declare a purpose, defined as a new enum called spanAllocType.

The purpose behind this change is two-fold:
1. Tight control over who gets to allocate heap memory is, generally
   speaking, a good thing. Every codepath that allocates heap memory
   places additional implicit restrictions on the allocator. A notable
   example of a restriction is work bufs coming from heap memory: write
   barriers are not allowed in allocation paths because then we could
   have a situation where the allocator calls into the allocator.
2. Memory statistic updating is explicit. Instead of passing an opaque
   pointer for statistic updating, which places restrictions on how that
   statistic may be updated, we use the spanAllocType to determine which
   statistic to update and how.

We also take this opportunity to group all the statistic updating code
together, which should make the accounting code a little easier to
follow.

Change-Id: Ic0b0898959ba2a776f67122f0e36c9d7d60e3085
Reviewed-on: https://go-review.googlesource.com/c/go/+/246970
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
src/runtime/mbitmap.go
src/runtime/mgcwork.go
src/runtime/mheap.go
src/runtime/stack.go