mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-13 07:23:39 +00:00
compiler: implement recover() built-in function
This commit is contained in:
committed by
Ron Evans
parent
79ba6a50c3
commit
8d6b210c09
@@ -0,0 +1,33 @@
|
||||
.section .text.tinygo_scanCurrentStack
|
||||
.global tinygo_scanCurrentStack
|
||||
.type tinygo_scanCurrentStack, %function
|
||||
tinygo_scanCurrentStack:
|
||||
// Sources:
|
||||
// * https://stackoverflow.com/questions/18024672/what-registers-are-preserved-through-a-linux-x86-64-function-call
|
||||
// * https://godbolt.org/z/q7e8dn
|
||||
|
||||
// Save callee-saved registers.
|
||||
pushl %ebx
|
||||
pushl %esi
|
||||
pushl %edi
|
||||
pushl %ebp
|
||||
|
||||
// Scan the stack.
|
||||
subl $8, %esp // adjust the stack before the call to maintain 16-byte alignment
|
||||
pushl %esp
|
||||
calll tinygo_scanstack
|
||||
|
||||
// Restore the stack pointer. Registers do not need to be restored as they
|
||||
// were only pushed to be discoverable by the GC.
|
||||
addl $28, %esp
|
||||
retl
|
||||
|
||||
|
||||
.section .text.tinygo_longjmp
|
||||
.global tinygo_longjmp
|
||||
tinygo_longjmp:
|
||||
// Note: the code we jump to assumes eax is set to a non-zero value if we
|
||||
// jump from here.
|
||||
movl 8(%esp), %eax // jumpPC (stash in volatile register)
|
||||
movl 4(%esp), %esp // jumpSP
|
||||
jmpl *%eax
|
||||
Reference in New Issue
Block a user