runtime: precisely scan globals on all platforms

This commit is contained in:
Jake Bailey
2026-08-07 12:08:32 -07:00
committed by Ron Evans
parent ede501ae2b
commit 59fb104004
18 changed files with 136 additions and 324 deletions
+20
View File
@@ -0,0 +1,20 @@
//go:build gc.boehm
package runtime
import "unsafe"
func markGlobals() {
for i := uintptr(0); i < gcGlobalRootCount(); i++ {
addr := gcGlobalRoot(uintptr(i))
// GC_push_all queues one range per call and overflows Boehm's mark
// stack for programs with thousands of roots. Scan each range now.
libgc_push_all_eager(uintptr(addr), uintptr(addr)+gcGlobalRootSize(i))
}
}
// These functions are generated by the compiler from the pointer layouts of
// mutable globals. Each range contains only pointer slots.
func gcGlobalRootCount() uintptr
func gcGlobalRoot(index uintptr) unsafe.Pointer
func gcGlobalRootSize(index uintptr) uintptr