runtime (gc): do not scan the runqueue when the platform is not baremetal with a scheduler

This commit is contained in:
Jaden Weiss
2020-06-23 18:48:58 -04:00
committed by Ron Evans
parent a4f3457747
commit e8c84d24a0
3 changed files with 31 additions and 20 deletions
+2
View File
@@ -38,3 +38,5 @@ func libc_malloc(size uintptr) unsafe.Pointer {
func libc_free(ptr unsafe.Pointer) {
free(ptr)
}
const baremetal = true
+24 -20
View File
@@ -297,32 +297,36 @@ func GC() {
markStack()
markGlobals()
// Channel operations in interrupts may move task pointers around while we are marking.
// Therefore we need to scan the runqueue seperately.
var markedTaskQueue task.Queue
runqueueScan:
for !runqueue.Empty() {
// Pop the next task off of the runqueue.
t := runqueue.Pop()
if baremetal && hasScheduler {
// Channel operations in interrupts may move task pointers around while we are marking.
// Therefore we need to scan the runqueue seperately.
var markedTaskQueue task.Queue
runqueueScan:
for !runqueue.Empty() {
// Pop the next task off of the runqueue.
t := runqueue.Pop()
// Mark the task if it has not already been marked.
markRoot(uintptr(unsafe.Pointer(&runqueue)), uintptr(unsafe.Pointer(t)))
// Mark the task if it has not already been marked.
markRoot(uintptr(unsafe.Pointer(&runqueue)), uintptr(unsafe.Pointer(t)))
// Push the task onto our temporary queue.
markedTaskQueue.Push(t)
}
// Push the task onto our temporary queue.
markedTaskQueue.Push(t)
}
finishMark()
finishMark()
// Restore the runqueue.
i := interrupt.Disable()
if !runqueue.Empty() {
// Something new came in while finishing the mark.
// Restore the runqueue.
i := interrupt.Disable()
if !runqueue.Empty() {
// Something new came in while finishing the mark.
interrupt.Restore(i)
goto runqueueScan
}
runqueue = markedTaskQueue
interrupt.Restore(i)
goto runqueueScan
} else {
finishMark()
}
runqueue = markedTaskQueue
interrupt.Restore(i)
// Sweep phase: free all non-marked objects and unmark marked objects for
// the next collection cycle.
+5
View File
@@ -0,0 +1,5 @@
// +build !baremetal
package runtime
const baremetal = false