
The only architecture that actually needs special support for scanning the stack is WebAssembly. All others allow raw access to the stack with a small bit of assembly. Therefore, don't manually keep track of all these objects on the stack manually and instead just use conservative stack scanning. This results in a massive code size decrease in the affected targets (only tested linux/amd64 for code size) - sometimes around 33%. It also allows for future improvements such as using proper stackful goroutines.
23 строки
711 Б
ArmAsm
23 строки
711 Б
ArmAsm
.section .text.tinygo_scanCurrentStack
|
|
.global tinygo_scanCurrentStack
|
|
.type tinygo_scanCurrentStack, %function
|
|
tinygo_scanCurrentStack:
|
|
// Sources:
|
|
// * https://developer.arm.com/architectures/learn-the-architecture/armv8-a-instruction-set-architecture/procedure-call-standard
|
|
// * https://godbolt.org/z/qrvrEh
|
|
|
|
// Save callee-saved registers.
|
|
stp x29, x30, [sp, #-96]!
|
|
stp x28, x27, [sp, #16]
|
|
stp x26, x25, [sp, #32]
|
|
stp x24, x23, [sp, #48]
|
|
stp x22, x21, [sp, #64]
|
|
stp x20, x19, [sp, #80]
|
|
|
|
// Scan the stack.
|
|
mov x0, sp
|
|
bl tinygo_scanstack
|
|
|
|
// Restore stack state and return.
|
|
ldp x29, x30, [sp], #96
|
|
ret
|