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

     1  #ifdef __ELF__
     2  .section .text.tinygo_scanCurrentStack
     3  .global tinygo_scanCurrentStack
     4  tinygo_scanCurrentStack:
     5  #else // Darwin
     6  .global _tinygo_scanCurrentStack
     7  _tinygo_scanCurrentStack:
     8  #endif
     9      // Save callee-saved registers.
    10      pushq %rbx
    11      pushq %rbp
    12      pushq %r12
    13      pushq %r13
    14      pushq %r14
    15      pushq %r15
    16  
    17      // Scan the stack.
    18      subq $8, %rsp // adjust the stack before the call to maintain 16-byte alignment
    19      movq %rsp, %rdi
    20  #ifdef __ELF__
    21      callq tinygo_scanstack
    22  #else
    23      callq _tinygo_scanstack // Darwin
    24  #endif
    25  
    26      // Restore the stack pointer. Registers do not need to be restored as they
    27      // were only pushed to be discoverable by the GC.
    28      addq $56, %rsp
    29      retq
    30  
    31  
    32  #ifdef __ELF__
    33  .section .text.tinygo_longjmp
    34  .global tinygo_longjmp
    35  tinygo_longjmp:
    36  #else // Darwin
    37  .global _tinygo_longjmp
    38  _tinygo_longjmp:
    39  #endif
    40      // Note: the code we jump to assumes rax is set to a non-zero value if we
    41      // jump from here, so we use rax as the temporary value for jumpPC.
    42      movq 0(%rdi), %rsp // jumpSP
    43      movq 8(%rdi), %rax // jumpPC
    44      jmpq *%rax
    45  
    46  
    47  #ifdef __MACH__ // Darwin
    48  // allow these symbols to stripped as dead code
    49  .subsections_via_symbols
    50  #endif