Skip to content

Commit 5388f2f

Browse files
mknyszekpull[bot]
authored andcommitted
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 <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Cherry Mui <[email protected]> Auto-Submit: Michael Knyszek <[email protected]>
1 parent a6b90a0 commit 5388f2f

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

src/runtime/mbitmap.go

+21
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,27 @@ import (
4646
"unsafe"
4747
)
4848

49+
// heapArenaPtrScalar contains the per-heapArena pointer/scalar metadata for the GC.
50+
type heapArenaPtrScalar struct {
51+
// bitmap stores the pointer/scalar bitmap for the words in
52+
// this arena. See mbitmap.go for a description.
53+
// This array uses 1 bit per word of heap, or 1.6% of the heap size (for 64-bit).
54+
bitmap [heapArenaBitmapWords]uintptr
55+
56+
// If the ith bit of noMorePtrs is true, then there are no more
57+
// pointers for the object containing the word described by the
58+
// high bit of bitmap[i].
59+
// In that case, bitmap[i+1], ... must be zero until the start
60+
// of the next object.
61+
// We never operate on these entries using bit-parallel techniques,
62+
// so it is ok if they are small. Also, they can't be bigger than
63+
// uint16 because at that size a single noMorePtrs entry
64+
// represents 8K of memory, the minimum size of a span. Any larger
65+
// and we'd have to worry about concurrent updates.
66+
// This array uses 1 bit per word of bitmap, or .024% of the heap size (for 64-bit).
67+
noMorePtrs [heapArenaBitmapWords / 8]uint8
68+
}
69+
4970
// addb returns the byte pointer p+n.
5071
//
5172
//go:nowritebarrier

src/runtime/mheap.go

+2-17
Original file line numberDiff line numberDiff line change
@@ -239,23 +239,8 @@ var mheap_ mheap
239239
type heapArena struct {
240240
_ sys.NotInHeap
241241

242-
// bitmap stores the pointer/scalar bitmap for the words in
243-
// this arena. See mbitmap.go for a description.
244-
// This array uses 1 bit per word of heap, or 1.6% of the heap size (for 64-bit).
245-
bitmap [heapArenaBitmapWords]uintptr
246-
247-
// If the ith bit of noMorePtrs is true, then there are no more
248-
// pointers for the object containing the word described by the
249-
// high bit of bitmap[i].
250-
// In that case, bitmap[i+1], ... must be zero until the start
251-
// of the next object.
252-
// We never operate on these entries using bit-parallel techniques,
253-
// so it is ok if they are small. Also, they can't be bigger than
254-
// uint16 because at that size a single noMorePtrs entry
255-
// represents 8K of memory, the minimum size of a span. Any larger
256-
// and we'd have to worry about concurrent updates.
257-
// This array uses 1 bit per word of bitmap, or .024% of the heap size (for 64-bit).
258-
noMorePtrs [heapArenaBitmapWords / 8]uint8
242+
// heapArenaPtrScalar contains pointer/scalar data about the heap for this heap arena.
243+
heapArenaPtrScalar
259244

260245
// spans maps from virtual address page ID within this arena to *mspan.
261246
// For allocated spans, their pages map to the span itself.

0 commit comments

Comments
 (0)