diff options
| author | Michael Anthony Knyszek <mknyszek@google.com> | 2023-10-28 16:20:04 +0000 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2023-11-02 17:24:39 +0000 |
| commit | 7a606fef6697f28ae6edebd64e5e8817349cdd92 (patch) | |
| tree | 8481487eb848a8f69c8a8ac8e06c1c2652600423 /src/runtime | |
| parent | 04575ce53f9af22403371b1b67d1e8bda990a4cd (diff) | |
| download | go-7a606fef6697f28ae6edebd64e5e8817349cdd92.tar.xz | |
runtime: split out pointer/scalar metadata from heapArena
We're going to want to fork this data in the near future for a
GOEXPERIMENT, so break it out now.
Change-Id: Ia7ded850bb693c443fe439c6b7279dcac638512c
Reviewed-on: https://go-review.googlesource.com/c/go/+/537978
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Diffstat (limited to 'src/runtime')
| -rw-r--r-- | src/runtime/mbitmap.go | 21 | ||||
| -rw-r--r-- | src/runtime/mheap.go | 19 |
2 files changed, 23 insertions, 17 deletions
diff --git a/src/runtime/mbitmap.go b/src/runtime/mbitmap.go index 20323ff82d..e918b3d489 100644 --- a/src/runtime/mbitmap.go +++ b/src/runtime/mbitmap.go @@ -46,6 +46,27 @@ import ( "unsafe" ) +// heapArenaPtrScalar contains the per-heapArena pointer/scalar metadata for the GC. +type heapArenaPtrScalar struct { + // bitmap stores the pointer/scalar bitmap for the words in + // this arena. See mbitmap.go for a description. + // This array uses 1 bit per word of heap, or 1.6% of the heap size (for 64-bit). + bitmap [heapArenaBitmapWords]uintptr + + // If the ith bit of noMorePtrs is true, then there are no more + // pointers for the object containing the word described by the + // high bit of bitmap[i]. + // In that case, bitmap[i+1], ... must be zero until the start + // of the next object. + // We never operate on these entries using bit-parallel techniques, + // so it is ok if they are small. Also, they can't be bigger than + // uint16 because at that size a single noMorePtrs entry + // represents 8K of memory, the minimum size of a span. Any larger + // and we'd have to worry about concurrent updates. + // This array uses 1 bit per word of bitmap, or .024% of the heap size (for 64-bit). + noMorePtrs [heapArenaBitmapWords / 8]uint8 +} + // addb returns the byte pointer p+n. // //go:nowritebarrier diff --git a/src/runtime/mheap.go b/src/runtime/mheap.go index 42318ca04c..62ad5e2f29 100644 --- a/src/runtime/mheap.go +++ b/src/runtime/mheap.go @@ -239,23 +239,8 @@ var mheap_ mheap type heapArena struct { _ sys.NotInHeap - // bitmap stores the pointer/scalar bitmap for the words in - // this arena. See mbitmap.go for a description. - // This array uses 1 bit per word of heap, or 1.6% of the heap size (for 64-bit). - bitmap [heapArenaBitmapWords]uintptr - - // If the ith bit of noMorePtrs is true, then there are no more - // pointers for the object containing the word described by the - // high bit of bitmap[i]. - // In that case, bitmap[i+1], ... must be zero until the start - // of the next object. - // We never operate on these entries using bit-parallel techniques, - // so it is ok if they are small. Also, they can't be bigger than - // uint16 because at that size a single noMorePtrs entry - // represents 8K of memory, the minimum size of a span. Any larger - // and we'd have to worry about concurrent updates. - // This array uses 1 bit per word of bitmap, or .024% of the heap size (for 64-bit). - noMorePtrs [heapArenaBitmapWords / 8]uint8 + // heapArenaPtrScalar contains pointer/scalar data about the heap for this heap arena. + heapArenaPtrScalar // spans maps from virtual address page ID within this arena to *mspan. // For allocated spans, their pages map to the span itself. |
