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

     1  #ifdef __MACH__
     2  .global _tinygo_scanCurrentStack
     3  _tinygo_scanCurrentStack:
     4  #else
     5  .section .text.tinygo_scanCurrentStack
     6  .global tinygo_scanCurrentStack
     7  tinygo_scanCurrentStack:
     8  #endif
     9      // Sources:
    10      //   * https://developer.arm.com/architectures/learn-the-architecture/armv8-a-instruction-set-architecture/procedure-call-standard
    11      //   * https://godbolt.org/z/qrvrEh
    12  
    13      // Save callee-saved registers.
    14      stp     x29, x30, [sp, #-160]!
    15      stp     x28, x27, [sp, #16]
    16      stp     x26, x25, [sp, #32]
    17      stp     x24, x23, [sp, #48]
    18      stp     x22, x21, [sp, #64]
    19      stp     x20, x19, [sp, #80]
    20      stp     d8,  d9,  [sp, #96]
    21      stp     d10, d11, [sp, #112]
    22      stp     d12, d13, [sp, #128]
    23      stp     d14, d15, [sp, #144]
    24  
    25      // Scan the stack.
    26      mov     x0, sp
    27  #ifdef __MACH__
    28      bl      _tinygo_scanstack
    29  #else
    30      bl      tinygo_scanstack
    31  #endif
    32  
    33      // Restore stack state and return.
    34      ldp     x29, x30, [sp], #160
    35      ret
    36  
    37  
    38  #ifdef __MACH__
    39  .global _tinygo_longjmp
    40  _tinygo_longjmp:
    41  #else
    42  .section .text.tinygo_longjmp
    43  .global tinygo_longjmp
    44  tinygo_longjmp:
    45  #endif
    46      // Note: the code we jump to assumes x0 is set to a non-zero value if we
    47      // jump from here (which is conveniently already the case).
    48      ldp x1, x2, [x0] // jumpSP, jumpPC
    49      mov sp, x1
    50      br  x2