refactor coroutine lowering and tasks

This commit is contained in:
Jaden Weiss
2020-01-03 00:23:37 -05:00
committed by Ayke
parent 2521cacb51
commit 6a50f25a48
40 changed files with 1830 additions and 1515 deletions
+4 -5
View File
@@ -17,7 +17,7 @@ tinygo_startTask:
blx r4
// After return, exit this goroutine. This is a tail call.
bl runtime.yield
bl tinygo_pause
.section .text.tinygo_getSystemStackPointer
.global tinygo_getSystemStackPointer
@@ -35,24 +35,23 @@ tinygo_getSystemStackPointer:
.global tinygo_switchToScheduler
.type tinygo_switchToScheduler, %function
tinygo_switchToScheduler:
// r0 = oldTask *task
// r0 = sp *uintptr
// Currently on the task stack (SP=PSP). We need to store the position on
// the stack where the in-use registers will be stored.
mov r1, sp
subs r1, #36
str r1, [r0, #36]
str r1, [r0]
b tinygo_swapTask
.global tinygo_switchToTask
.type tinygo_switchToTask, %function
tinygo_switchToTask:
// r0 = newTask *task
// r0 = sp uintptr
// Currently on the scheduler stack (SP=MSP). We'll have to update the PSP,
// and then we can invoke swapTask.
ldr r0, [r0, #36]
msr PSP, r0
// Continue executing in the swapTask function, which swaps the stack