Skip to content

Commit 2b0dc62

Browse files
committed
internal/task: rename tinygo_pause to tinygo_task_exit
This is more descriptive: the call is to exit a task, not to pause it. This also makes it more obvious that there's an optimization opportunity: to free the stack explicitly after the goroutine returns (or to keep it as a cache for the next stack allocation).
1 parent 120d17c commit 2b0dc62

12 files changed

+17
-16
lines changed

src/internal/task/task_stack.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ func Pause() {
5454
currentTask.state.pause()
5555
}
5656

57-
//export tinygo_pause
58-
func pause() {
57+
//export tinygo_task_exit
58+
func taskExit() {
59+
// TODO: explicitly free the stack after switching back to the scheduler.
5960
Pause()
6061
}
6162

src/internal/task/task_stack_386.S

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ tinygo_startTask:
2424
addl $4, %esp
2525

2626
// After return, exit this goroutine. This is a tail call.
27-
jmp tinygo_pause
27+
jmp tinygo_task_exit
2828
.cfi_endproc
2929

3030
.global tinygo_swapTask

src/internal/task/task_stack_amd64.S

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ tinygo_startTask:
3030

3131
// After return, exit this goroutine. This is a tail call.
3232
#ifdef __MACH__
33-
jmp _tinygo_pause
33+
jmp _tinygo_task_exit
3434
#else
35-
jmp tinygo_pause
35+
jmp tinygo_task_exit
3636
#endif
3737
.cfi_endproc
3838

src/internal/task/task_stack_amd64_windows.S

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ tinygo_startTask:
2222

2323
// After return, exit this goroutine.
2424
// This has to be a call, not a jump, to keep the stack correctly aligned.
25-
callq tinygo_pause
25+
callq tinygo_task_exit
2626

2727
.global tinygo_swapTask
2828
.section .text.tinygo_swapTask,"ax"

src/internal/task/task_stack_arm.S

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ tinygo_startTask:
2828
blx r4
2929

3030
// After return, exit this goroutine. This is a tail call.
31-
bl tinygo_pause
31+
bl tinygo_task_exit
3232
.cfi_endproc
3333
.size tinygo_startTask, .-tinygo_startTask
3434

src/internal/task/task_stack_arm64.S

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ tinygo_startTask:
2727

2828
// After return, exit this goroutine. This is a tail call.
2929
#ifdef __MACH__
30-
b _tinygo_pause
30+
b _tinygo_task_exit
3131
#else
32-
b tinygo_pause
32+
b tinygo_task_exit
3333
#endif
3434
.cfi_endproc
3535
#ifndef __MACH__

src/internal/task/task_stack_avr.S

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ tinygo_startTask:
3232
// Note that they will probably not be able to run more than the main
3333
// goroutine anyway, but this file is compiled for all AVRs so it needs to
3434
// compile at least.
35-
rcall tinygo_pause
35+
rcall tinygo_task_exit
3636
#else
3737
// Other devices can (and must) use the regular call instruction.
38-
call tinygo_pause
38+
call tinygo_task_exit
3939
#endif
4040

4141
.global tinygo_swapTask

src/internal/task/task_stack_cortexm.S

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ tinygo_startTask:
2828
blx r4
2929

3030
// After return, exit this goroutine. This is a tail call.
31-
bl tinygo_pause
31+
bl tinygo_task_exit
3232
.cfi_endproc
3333
.size tinygo_startTask, .-tinygo_startTask
3434

src/internal/task/task_stack_esp32.S

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ tinygo_startTask:
2727
callx4 a3
2828

2929
// After return, exit this goroutine. This call never returns.
30-
call4 tinygo_pause
30+
call4 tinygo_task_exit
3131

3232
.section .text.tinygo_swapTask,"ax",@progbits
3333
.global tinygo_swapTask

src/internal/task/task_stack_esp8266.S

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ tinygo_startTask:
1818
callx0 a12
1919

2020
// After return, exit this goroutine. This is a tail call.
21-
call0 tinygo_pause
21+
call0 tinygo_task_exit
2222
.size tinygo_startTask, .-tinygo_startTask
2323

2424
.global tinygo_swapTask

src/internal/task/task_stack_mipsx.S

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ tinygo_startTask:
2222
nop
2323

2424
// After return, exit this goroutine. This is a tail call.
25-
j tinygo_pause
25+
j tinygo_task_exit
2626
nop
2727

2828
.section .text.tinygo_swapTask

src/internal/task/task_stack_tinygoriscv.S

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ tinygo_startTask:
1919
jalr s0
2020

2121
// After return, exit this goroutine. This is a tail call.
22-
tail tinygo_pause
22+
tail tinygo_task_exit
2323

2424
.section .text.tinygo_swapTask
2525
.global tinygo_swapTask

0 commit comments

Comments
 (0)