mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-09-15 17:02:59 +00:00
runtime: precisely scan globals on all platforms
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user