]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: fix stale comment for mheap/malloc
authorLidong Yan <yldhome2d2@gmail.com>
Fri, 21 Nov 2025 03:14:46 +0000 (11:14 +0800)
committerKeith Randall <khr@golang.org>
Sun, 23 Nov 2025 17:07:32 +0000 (09:07 -0800)
mheap use pageAlloc to manage free/scav address space instead of
using free/scav treap. The comment on mheap states mheap uses
treaps. Update the comment to reflect the use of pageAlloc.

In the fallback code when sizeSpecializedMalloc is enabled,
heapBitsInSpan is false. Update the comment to reflect that.

Change-Id: I50d2993c84e2c0312a925ab0a33065cc4cd41c41
Reviewed-on: https://go-review.googlesource.com/c/go/+/722700
Reviewed-by: Lidong Yan <yldhome2d2@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Mark Freeman <markfreeman@google.com>
src/runtime/malloc.go
src/runtime/mheap.go

index d49dacaf68604bda02dee9daad933df5dc98b746..4971e16c6aabea3d20bcf10e61bc9a5446a5a0c2 100644 (file)
@@ -1169,7 +1169,7 @@ func mallocgc(size uintptr, typ *_type, needzero bool) unsafe.Pointer {
        var x unsafe.Pointer
        var elemsize uintptr
        if sizeSpecializedMallocEnabled {
-               // we know that heapBitsInSpan is true.
+               // we know that heapBitsInSpan is false.
                if size <= maxSmallSize-gc.MallocHeaderSize {
                        if typ == nil || !typ.Pointers() {
                                x, elemsize = mallocgcSmallNoscan(size, typ, needzero)
index d2ff063b00c70c64aa3291d46be138d663af18d0..0ccaadc891ba9d1e1c24640c175b28154cff3084 100644 (file)
@@ -56,7 +56,7 @@ const (
 )
 
 // Main malloc heap.
-// The heap itself is the "free" and "scav" treaps,
+// The heap use pageAlloc to manage free and scavenged pages,
 // but all the other global data is here too.
 //
 // mheap must not be heap-allocated because it contains mSpanLists,