Source File
scan_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 ()// ScanSpanPackedReference is the reference implementation of ScanScanPacked. It prioritizes clarity over performance.//// Concretely, ScanScanPacked functions read pointers from mem, assumed to be gc.PageSize-aligned and gc.PageSize in size,// and writes them to bufp, which is large enough to guarantee that even if pointer-word of mem is a pointer, it will fit.// Therefore bufp, is always at least gc.PageSize in size.//// ScanSpanPacked is supposed to identify pointers by first filtering words by objMarks, where each bit of the mask// represents gc.SizeClassToSize[sizeClass] bytes of memory, and then filtering again by the bits in ptrMask.func ( unsafe.Pointer, *uintptr, *gc.ObjMask, uintptr, *gc.PtrMask) ( int32) {:= unsafe.Slice(, gc.PageWords):= uintptr(gc.SizeClassToSize[]) / goarch.PtrSizefor := range gc.PageWords {:= uintptr() /if [/goarch.PtrBits]&(1<<(%goarch.PtrBits)) == 0 {continue}if [/goarch.PtrBits]&(1<<(%goarch.PtrBits)) == 0 {continue}:= *(*uintptr)(unsafe.Add(, *goarch.PtrSize))if == 0 {continue}[] =++}return}
![]() |
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. |