...
1
2
3
4
5 package scan
6
7 import (
8 "internal/goarch"
9 "internal/runtime/gc"
10 "unsafe"
11 )
12
13
14
15
16
17
18
19
20
21 func ScanSpanPackedReference(mem unsafe.Pointer, bufp *uintptr, objMarks *gc.ObjMask, sizeClass uintptr, ptrMask *gc.PtrMask) (count int32) {
22 buf := unsafe.Slice(bufp, gc.PageWords)
23 expandBy := uintptr(gc.SizeClassToSize[sizeClass]) / goarch.PtrSize
24 for word := range gc.PageWords {
25 objI := uintptr(word) / expandBy
26 if objMarks[objI/goarch.PtrBits]&(1<<(objI%goarch.PtrBits)) == 0 {
27 continue
28 }
29 if ptrMask[word/goarch.PtrBits]&(1<<(word%goarch.PtrBits)) == 0 {
30 continue
31 }
32 ptr := *(*uintptr)(unsafe.Add(mem, word*goarch.PtrSize))
33 if ptr == 0 {
34 continue
35 }
36 buf[count] = ptr
37 count++
38 }
39 return count
40 }
41
View as plain text