From e13f0c438590a7c78a955fec67fc966b82b2a947 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Sat, 2 Nov 2024 10:47:28 +0100 Subject: [PATCH] runtime: refactor GC mark phase into gcMarkReachable This is a small refactor to prepare GC marking for multithreaded stop-the-world. --- src/runtime/gc_blocks.go | 3 +-- src/runtime/gc_stack_portable.go | 5 +++++ src/runtime/gc_stack_raw.go | 5 +++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/runtime/gc_blocks.go b/src/runtime/gc_blocks.go index cbd401b9e1..24166aebba 100644 --- a/src/runtime/gc_blocks.go +++ b/src/runtime/gc_blocks.go @@ -422,8 +422,7 @@ func runGC() (freeBytes uintptr) { } // Mark phase: mark all reachable objects, recursively. - markStack() - findGlobals(markRoots) + gcMarkReachable() if baremetal && hasScheduler { // Channel operations in interrupts may move task pointers around while we are marking. diff --git a/src/runtime/gc_stack_portable.go b/src/runtime/gc_stack_portable.go index d35e16e30c..750a34ec2c 100644 --- a/src/runtime/gc_stack_portable.go +++ b/src/runtime/gc_stack_portable.go @@ -8,6 +8,11 @@ import ( "unsafe" ) +func gcMarkReachable() { + markStack() + findGlobals(markRoots) +} + //go:extern runtime.stackChainStart var stackChainStart *stackChainObject diff --git a/src/runtime/gc_stack_raw.go b/src/runtime/gc_stack_raw.go index 5ee18622db..d55522a9f6 100644 --- a/src/runtime/gc_stack_raw.go +++ b/src/runtime/gc_stack_raw.go @@ -4,6 +4,11 @@ package runtime import "internal/task" +func gcMarkReachable() { + markStack() + findGlobals(markRoots) +} + // markStack marks all root pointers found on the stack. // // This implementation is conservative and relies on the stack top (provided by