compiler: implement recover() built-in function

This commit is contained in:
Ayke van Laethem
2021-11-29 14:54:34 +01:00
committed by Ron Evans
parent 79ba6a50c3
commit 8d6b210c09
31 changed files with 868 additions and 191 deletions
+31
View File
@@ -0,0 +1,31 @@
.section .text.tinygo_scanCurrentStack,"ax"
.global tinygo_scanCurrentStack
tinygo_scanCurrentStack:
// Save callee-saved registers.
pushq %rbx
pushq %rbp
pushq %rdi
pushq %rsi
pushq %r12
pushq %r13
pushq %r14
pushq %r15
// Scan the stack.
subq $8, %rsp // adjust the stack before the call to maintain 16-byte alignment
movq %rsp, %rdi
callq tinygo_scanstack
// Restore the stack pointer. Registers do not need to be restored as they
// were only pushed to be discoverable by the GC.
addq $72, %rsp
retq
.section .text.tinygo_longjmp,"ax"
.global tinygo_longjmp
tinygo_longjmp:
// Note: the code we jump to assumes rax is non-zero so we have to load it
// with some value here.
movq $1, %rax
movq %rcx, %rsp // jumpSP
jmpq *%rdx // jumpPC