asm_amd64.s 926 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright 2009 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_amd64.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. // This signature is known to SWIG, so we can't change it.
  11. TEXT crosscall2(SB), NOSPLIT, $0-0
  12. PUSH_REGS_HOST_TO_ABI0()
  13. // Make room for arguments to cgocallback.
  14. ADJSP $0x18
  15. #ifndef GOOS_windows
  16. MOVQ DI, 0x0(SP) // fn
  17. MOVQ SI, 0x8(SP) // arg
  18. // Skip n in DX.
  19. MOVQ CX, 0x10(SP) // ctxt
  20. #else
  21. MOVQ CX, 0x0(SP) // fn
  22. MOVQ DX, 0x8(SP) // arg
  23. // Skip n in R8.
  24. MOVQ R9, 0x10(SP) // ctxt
  25. #endif
  26. CALL runtime·cgocallback(SB)
  27. ADJSP $-0x18
  28. POP_REGS_HOST_TO_ABI0()
  29. RET