Skip to content

Commit befd1fb

Browse files
committed
runtime: refactor obtaining the system stack
The system stack is only needed when we're not on it. So we can directly call task.SystemStack() without problems. This also saves a tiny bit of binary size.
1 parent 3ce840e commit befd1fb

File tree

5 files changed

+10
-27
lines changed

5 files changed

+10
-27
lines changed

builder/sizes_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ func TestBinarySize(t *testing.T) {
4242
// This is a small number of very diverse targets that we want to test.
4343
tests := []sizeTest{
4444
// microcontrollers
45-
{"hifive1b", "examples/echo", 4560, 280, 0, 2268},
46-
{"microbit", "examples/serial", 2924, 388, 8, 2272},
47-
{"wioterminal", "examples/pininterrupt", 7383, 1489, 116, 6912},
45+
{"hifive1b", "examples/echo", 4556, 280, 0, 2268},
46+
{"microbit", "examples/serial", 2920, 388, 8, 2272},
47+
{"wioterminal", "examples/pininterrupt", 7379, 1489, 116, 6912},
4848

4949
// TODO: also check wasm. Right now this is difficult, because
5050
// wasm binaries are run through wasm-opt and therefore the

src/internal/task/task_none.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,9 @@ func OnSystemStack() bool {
3636
// This scheduler does not do any stack switching.
3737
return true
3838
}
39+
40+
func SystemStack() uintptr {
41+
// System stack is the current stack, so this shouldn't be called.
42+
runtimePanic("scheduler is disabled")
43+
return 0 // unreachable
44+
}

src/runtime/gc_stack_raw.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func markStack() {
2020

2121
if !task.OnSystemStack() {
2222
// Mark system stack.
23-
markRoots(getSystemStackPointer(), stackTop)
23+
markRoots(task.SystemStack(), stackTop)
2424
}
2525
}
2626

src/runtime/scheduler_none.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,3 @@ func scheduler(returnAtDeadlock bool) {
7373
// this code should be unreachable.
7474
runtimePanic("unreachable: scheduler must not be called with the 'none' scheduler")
7575
}
76-
77-
// getSystemStackPointer returns the current stack pointer of the system stack.
78-
// This is always the current stack pointer.
79-
func getSystemStackPointer() uintptr {
80-
return getCurrentStackPointer()
81-
}

src/runtime/scheduler_tasks.go

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)