github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/src/runtime/asm_386.S (about)

     1  .section .text.tinygo_scanCurrentStack
     2  .global tinygo_scanCurrentStack
     3  .type tinygo_scanCurrentStack, %function
     4  tinygo_scanCurrentStack:
     5      // Sources:
     6      //   * https://stackoverflow.com/questions/18024672/what-registers-are-preserved-through-a-linux-x86-64-function-call
     7      //   * https://godbolt.org/z/q7e8dn
     8  
     9      // Save callee-saved registers.
    10      pushl %ebx
    11      pushl %esi
    12      pushl %edi
    13      pushl %ebp
    14  
    15      // Scan the stack.
    16      subl $8, %esp // adjust the stack before the call to maintain 16-byte alignment
    17      pushl %esp
    18      calll tinygo_scanstack
    19  
    20      // Restore the stack pointer. Registers do not need to be restored as they
    21      // were only pushed to be discoverable by the GC.
    22      addl $28, %esp
    23      retl
    24  
    25  
    26  .section .text.tinygo_longjmp
    27  .global tinygo_longjmp
    28  tinygo_longjmp:
    29      // Note: the code we jump to assumes eax is set to a non-zero value if we
    30      // jump from here.
    31      movl 4(%esp), %eax
    32      movl 0(%eax), %esp // jumpSP
    33      movl 4(%eax), %eax // jumpPC (stash in volatile register)
    34      jmpl *%eax