runtime: support panic recovery on Xtensa

Use picolibc setjmp and longjmp to save and restore the complete
Xtensa register-window state at TinyGo panic checkpoints.

Provide the target configuration and window spill helper required by
picolibc. Increment its cache version because Xtensa archives now
include another source file.
This commit is contained in:
Jake Bailey
2026-09-04 09:46:55 -07:00
committed by Ron Evans
parent a96cc30257
commit b8b831cf5c
8 changed files with 102 additions and 22 deletions
+3 -1
View File
@@ -11,7 +11,9 @@ const zeroSizeAllocPtr uintptr = 16 // part of early flash: partition table, etc
// The bitness of the CPU (e.g. 8, 32, 64).
const TargetBits = 32
const deferExtraRegs = 0
// Xtensa's windowed ABI uses a 17-word jmp_buf. JumpSP and JumpPC provide the
// first two words.
const deferExtraRegs = 15
const callInstSize = 3 // "callx0 someFunction" (and similar) is 3 bytes
+34
View File
@@ -0,0 +1,34 @@
#ifdef __XTENSA_WINDOWED_ABI__
.section .text.__xtensa_libgcc_window_spill,"ax",@progbits
.global __xtensa_libgcc_window_spill
.type __xtensa_libgcc_window_spill, %function
__xtensa_libgcc_window_spill:
entry sp, 16
movi a6, 15
call4 .Lspill_windows
retw
.size __xtensa_libgcc_window_spill, .-__xtensa_libgcc_window_spill
.balign 4
.Lspill_windows:
entry sp, 16
beqz a2, .Lspill_done
addi a2, a2, -1
mov a6, a2
call4 .Lspill_windows
.Lspill_done:
retw
#endif
.section .text.tinygo_longjmp,"ax",@progbits
.global tinygo_longjmp
.type tinygo_longjmp, %function
tinygo_longjmp:
#ifdef __XTENSA_WINDOWED_ABI__
// longjmp's entry rotates a10/a11 into its a2/a3 arguments.
movi a11, 1
#else
movi a3, 1
#endif
j longjmp
.size tinygo_longjmp, .-tinygo_longjmp