1 //go:build (gc.conservative || gc.precise || gc.boehm) && !moxie.wasm && !scheduler.threads && !scheduler.cores
2 3 package runtime
4 5 import (
6 "internal/task"
7 "sync/atomic"
8 )
9 10 // Unused.
11 var gcScanState atomic.Uint32
12 13 func gcMarkReachable() {
14 markStack()
15 findGlobals(markRoots)
16 }
17 18 // markStack marks all root pointers found on the stack.
19 //
20 // This implementation is conservative and relies on the stack top (provided by
21 // the linker) and getting the current stack pointer from a register. Also, it
22 // assumes a descending stack. Thus, it is not very portable.
23 func markStack() {
24 // Scan the current stack, and all current registers.
25 scanCurrentStack()
26 27 if !task.OnSystemStack() {
28 // Mark system stack.
29 markRoots(task.SystemStack(), stackTop)
30 }
31 }
32 33 //go:export moxie_scanCurrentStack
34 func scanCurrentStack()
35 36 //go:export moxie_scanstack
37 func scanstack(sp uintptr) {
38 // Mark current stack.
39 // This function is called by scanCurrentStack, after pushing all registers onto the stack.
40 // Callee-saved registers have been pushed onto stack by moxie_localscan, so this will scan them too.
41 if task.OnSystemStack() {
42 // This is the system stack.
43 // Scan all words on the stack.
44 markRoots(sp, stackTop)
45 } else {
46 // This is a goroutine stack.
47 markCurrentGoroutineStack(sp)
48 }
49 }
50 51 func gcResumeWorld() {
52 // Nothing to do here (single threaded).
53 }
54