mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-21 04:49:04 +00:00
runtime (gc): do not scan the runqueue when the platform is not baremetal with a scheduler
This commit is contained in:
@@ -38,3 +38,5 @@ func libc_malloc(size uintptr) unsafe.Pointer {
|
|||||||
func libc_free(ptr unsafe.Pointer) {
|
func libc_free(ptr unsafe.Pointer) {
|
||||||
free(ptr)
|
free(ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const baremetal = true
|
||||||
|
|||||||
@@ -297,10 +297,11 @@ func GC() {
|
|||||||
markStack()
|
markStack()
|
||||||
markGlobals()
|
markGlobals()
|
||||||
|
|
||||||
|
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.
|
||||||
// Therefore we need to scan the runqueue seperately.
|
// Therefore we need to scan the runqueue seperately.
|
||||||
var markedTaskQueue task.Queue
|
var markedTaskQueue task.Queue
|
||||||
runqueueScan:
|
runqueueScan:
|
||||||
for !runqueue.Empty() {
|
for !runqueue.Empty() {
|
||||||
// Pop the next task off of the runqueue.
|
// Pop the next task off of the runqueue.
|
||||||
t := runqueue.Pop()
|
t := runqueue.Pop()
|
||||||
@@ -323,6 +324,9 @@ runqueueScan:
|
|||||||
}
|
}
|
||||||
runqueue = markedTaskQueue
|
runqueue = markedTaskQueue
|
||||||
interrupt.Restore(i)
|
interrupt.Restore(i)
|
||||||
|
} else {
|
||||||
|
finishMark()
|
||||||
|
}
|
||||||
|
|
||||||
// Sweep phase: free all non-marked objects and unmark marked objects for
|
// Sweep phase: free all non-marked objects and unmark marked objects for
|
||||||
// the next collection cycle.
|
// the next collection cycle.
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
// +build !baremetal
|
||||||
|
|
||||||
|
package runtime
|
||||||
|
|
||||||
|
const baremetal = false
|
||||||
Reference in New Issue
Block a user