From 8659b18d6f487e438959bf901c67bdf6b0862d18 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 d58bfd92a..5b0453bb2 100644 --- a/src/runtime/gc_blocks.go +++ b/src/runtime/gc_blocks.go @@ -456,8 +456,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 d35e16e30..750a34ec2 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 5ee18622d..d55522a9f 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