runtime: fix GC to take goroutines into account
This fix is needed because with the new task-based scheduler, the current stack pointer may not be on the system stack.
Этот коммит содержится в:
родитель
db4de46d88
коммит
6917faabf5
3 изменённых файлов: 20 добавлений и 1 удалений
|
@ -9,5 +9,6 @@ package runtime
|
||||||
// the linker) and getting the current stack pointer from a register. Also, it
|
// the linker) and getting the current stack pointer from a register. Also, it
|
||||||
// assumes a descending stack. Thus, it is not very portable.
|
// assumes a descending stack. Thus, it is not very portable.
|
||||||
func markStack() {
|
func markStack() {
|
||||||
markRoots(getCurrentStackPointer(), stackTop)
|
// Mark system stack.
|
||||||
|
markRoots(getSystemStackPointer(), stackTop)
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,3 +93,9 @@ func chanYield() {
|
||||||
// Nothing to do here, simply returning from the channel operation also exits
|
// Nothing to do here, simply returning from the channel operation also exits
|
||||||
// the goroutine temporarily.
|
// the goroutine temporarily.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getSystemStackPointer returns the current stack pointer of the system stack.
|
||||||
|
// This is always the current stack pointer.
|
||||||
|
func getSystemStackPointer() uintptr {
|
||||||
|
return getCurrentStackPointer()
|
||||||
|
}
|
||||||
|
|
|
@ -129,3 +129,15 @@ func reactivateParent(t *task) {
|
||||||
func chanYield() {
|
func chanYield() {
|
||||||
Goexit()
|
Goexit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getSystemStackPointer returns the current stack pointer of the system stack.
|
||||||
|
// This is not necessarily the same as the current stack pointer.
|
||||||
|
func getSystemStackPointer() uintptr {
|
||||||
|
if currentTask == nil {
|
||||||
|
// Currently on the system stack.
|
||||||
|
return getCurrentStackPointer()
|
||||||
|
} else {
|
||||||
|
// Currently in a goroutine.
|
||||||
|
return schedulerState.sp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче