asm_arm64.s 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright 2015 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. #include "textflag.h"
  5. #include "abi_arm64.h"
  6. // Called by C code generated by cmd/cgo.
  7. // func crosscall2(fn, a unsafe.Pointer, n int32, ctxt uintptr)
  8. // Saves C callee-saved registers and calls cgocallback with three arguments.
  9. // fn is the PC of a func(a unsafe.Pointer) function.
  10. TEXT crosscall2(SB), NOSPLIT|NOFRAME, $0
  11. /*
  12. * We still need to save all callee save register as before, and then
  13. * push 3 args for fn (R0, R1, R3), skipping R2.
  14. * Also note that at procedure entry in gc world, 8(RSP) will be the
  15. * first arg.
  16. */
  17. SUB $(8*24), RSP
  18. STP (R0, R1), (8*1)(RSP)
  19. MOVD R3, (8*3)(RSP)
  20. SAVE_R19_TO_R28(8*4)
  21. SAVE_F8_TO_F15(8*14)
  22. STP (R29, R30), (8*22)(RSP)
  23. // Initialize Go ABI environment
  24. BL runtime·load_g(SB)
  25. BL runtime·cgocallback(SB)
  26. RESTORE_R19_TO_R28(8*4)
  27. RESTORE_F8_TO_F15(8*14)
  28. LDP (8*22)(RSP), (R29, R30)
  29. ADD $(8*24), RSP
  30. RET