Skip to content

Commit

Permalink
runtime: refactor GC mark phase into gcMarkReachable
Browse files Browse the repository at this point in the history
This is a small refactor to prepare GC marking for multithreaded
stop-the-world.
  • Loading branch information
aykevl committed Nov 2, 2024
1 parent a8060d4 commit e13f0c4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/runtime/gc_blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 5 additions & 0 deletions src/runtime/gc_stack_portable.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import (
"unsafe"
)

func gcMarkReachable() {
markStack()
findGlobals(markRoots)
}

//go:extern runtime.stackChainStart
var stackChainStart *stackChainObject

Expand Down
5 changes: 5 additions & 0 deletions src/runtime/gc_stack_raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e13f0c4

Please sign in to comment.