arm: automatically determine stack sizes

This is a big change that will determine the stack size for many
goroutines automatically. Functions that aren't recursive and don't call
function pointers can in many cases have an automatically determined
worst case stack size. This is useful, as the stack size is usually much
lower than the previous hardcoded default of 1024 bytes: somewhere
around 200-500 bytes is common.

A side effect of this change is that the default stack sizes (including
the stack size for other architectures such as AVR) can now be changed
in the config JSON file, making it tunable per application.
This commit is contained in:
Ayke van Laethem
2020-07-18 13:36:28 +02:00
committed by Ron Evans
parent a761f556ff
commit a21a039ac7
27 changed files with 416 additions and 77 deletions
+5
View File
@@ -16,6 +16,11 @@ SECTIONS
. = ALIGN(4);
} >FLASH_TEXT
.tinygo_stacksizes :
{
*(.tinygo_stacksizes)
} > FLASH_TEXT
/* Put the stack at the bottom of RAM, so that the application will
* crash on stack overflow instead of silently corrupting memory.
* See: http://blog.japaric.io/stack-overflow-protection/ */
+1
View File
@@ -7,6 +7,7 @@
"gc": "conservative",
"linker": "avr-gcc",
"scheduler": "none",
"default-stack-size": 256,
"ldflags": [
"-T", "targets/avr.ld",
"-Wl,--gc-sections"
+4
View File
@@ -1,6 +1,7 @@
// Generic Cortex-M interrupt vector.
// This vector is used by the Cortex-M QEMU target.
.cfi_sections .debug_frame
.syntax unified
// This is the default handler for interrupts, if triggered but not defined.
@@ -8,8 +9,11 @@
.global Default_Handler
.type Default_Handler, %function
Default_Handler:
.cfi_startproc
wfe
b Default_Handler
.cfi_endproc
.size Default_Handler, .-Default_Handler
// Avoid the need for repeated .weak and .set instructions.
.macro IRQ handler
+2
View File
@@ -8,6 +8,8 @@
"linker": "ld.lld",
"rtlib": "compiler-rt",
"libc": "picolibc",
"automatic-stack-size": true,
"default-stack-size": 1024,
"cflags": [
"-Oz",
"-mthumb",