asm_arm64.S raw

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