Source File
expand_reference.go
Belonging Package
internal/runtime/gc/scan
// Copyright 2025 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.package scanimport ()// ExpandReference is a reference implementation of an expander function// that translates object mark bits into a bitmap of one bit per word of// marked object, assuming the object is of the provided size class.func ( int, *gc.ObjMask, *gc.PtrMask) {// Look up the size and derive the number of objects in a span.// We're only concerned with small objects in single-page spans,// and gc.PtrMask enforces this by being statically sized to// accommodate only such spans.:= uintptr(gc.SizeClassToSize[]):= uintptr(gc.SizeClassToNPages[]) * gc.PageSize /// f is the expansion factor. For example, if our objects are of size 48,// then each mark bit will translate into 6 (48/8 = 6) set bits in the// pointer bitmap.:= / goarch.PtrSizefor := range {// Check if the object is marked.if [/goarch.PtrBits]&(uintptr(1)<<(%goarch.PtrBits)) == 0 {continue}// Propagate that mark into the destination into one bit per the// expansion factor f, offset to the object's offset within the span.for := range {:= * + // i*f is the start bit for the object, j indexes into each corresponding word after.[/goarch.PtrBits] |= uintptr(1) << ( % goarch.PtrBits)}}}
![]() |
The pages are generated with Golds v0.8.3-preview. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |