mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-16 10:43:29 +00:00
runtime: refactor GC mark phase into gcMarkReachable
This is a small refactor to prepare GC marking for multithreaded stop-the-world.
This commit is contained in:
@@ -456,8 +456,7 @@ func runGC() (freeBytes uintptr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Mark phase: mark all reachable objects, recursively.
|
// Mark phase: mark all reachable objects, recursively.
|
||||||
markStack()
|
gcMarkReachable()
|
||||||
findGlobals(markRoots)
|
|
||||||
|
|
||||||
if baremetal && hasScheduler {
|
if baremetal && hasScheduler {
|
||||||
// Channel operations in interrupts may move task pointers around while we are marking.
|
// Channel operations in interrupts may move task pointers around while we are marking.
|
||||||
|
|||||||
@@ -8,6 +8,11 @@ import (
|
|||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func gcMarkReachable() {
|
||||||
|
markStack()
|
||||||
|
findGlobals(markRoots)
|
||||||
|
}
|
||||||
|
|
||||||
//go:extern runtime.stackChainStart
|
//go:extern runtime.stackChainStart
|
||||||
var stackChainStart *stackChainObject
|
var stackChainStart *stackChainObject
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,11 @@ package runtime
|
|||||||
|
|
||||||
import "internal/task"
|
import "internal/task"
|
||||||
|
|
||||||
|
func gcMarkReachable() {
|
||||||
|
markStack()
|
||||||
|
findGlobals(markRoots)
|
||||||
|
}
|
||||||
|
|
||||||
// markStack marks all root pointers found on the stack.
|
// markStack marks all root pointers found on the stack.
|
||||||
//
|
//
|
||||||
// This implementation is conservative and relies on the stack top (provided by
|
// This implementation is conservative and relies on the stack top (provided by
|
||||||
|
|||||||
Reference in New Issue
Block a user