]> Cypherpunks.ru repositories - gostls13.git/blobdiff - src/runtime/mbitmap.go
runtime: split out pointer/scalar metadata from heapArena
[gostls13.git] / src / runtime / mbitmap.go
index 20323ff82d6731503ea90d5db1ceb78185a0bdc5..e918b3d48938fa3a1a1b372b055a6bfc6744e9bd 100644 (file)
@@ -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