2016-04-21 15:19:32 +03:00
|
|
|
#
|
|
|
|
# store all parameters in a consistent way, and send it off to managed code.
|
|
|
|
# we need to store:
|
|
|
|
# %rdi, %rsi, %rdx, %rcx, %r8, %r9
|
|
|
|
# %xmm0-%xmm7
|
|
|
|
# an unknown amount of stack space, but we can pass a pointer to the start of this area.
|
2019-05-06 08:25:49 +03:00
|
|
|
# in total we need 7*64bits registers + 8*128bits registers + 1*64bit ptr = 192 bytes.
|
|
|
|
# additionally we'll use %r11 to specify the type of trampoline was called, so 200 bytes.
|
|
|
|
# and finally we need to align the long double fields on a 16-byte boundary, so 208 bytes.
|
2016-04-21 15:19:32 +03:00
|
|
|
#
|
|
|
|
#
|
|
|
|
# upon return we may need to write to:
|
|
|
|
# %rax, %rdx
|
|
|
|
# %xmm0-%xmm1
|
|
|
|
# (the spec says %st0 and %st1 are used to return 'long double' arguments, but we won't encounter those)
|
|
|
|
#
|
|
|
|
|
|
|
|
#if __x86_64__
|
|
|
|
|
2016-05-11 13:06:37 +03:00
|
|
|
.subsections_via_symbols
|
|
|
|
.text
|
|
|
|
|
2016-04-21 15:19:32 +03:00
|
|
|
_xamarin_x86_64_common_trampoline:
|
2016-05-11 13:06:37 +03:00
|
|
|
.cfi_startproc
|
2016-04-21 15:19:32 +03:00
|
|
|
pushq %rbp
|
2016-05-11 13:06:37 +03:00
|
|
|
.cfi_def_cfa_offset 16
|
|
|
|
.cfi_offset %rbp, -16
|
2016-04-21 15:19:32 +03:00
|
|
|
movq %rsp, %rbp
|
2016-05-11 13:06:37 +03:00
|
|
|
.cfi_def_cfa_register %rbp
|
2019-05-06 08:25:49 +03:00
|
|
|
subq $0xD0, %rsp # allocate 208 bytes from the stack
|
2016-04-21 15:19:32 +03:00
|
|
|
# todo: verify alignment.
|
|
|
|
movq %r11, (%rsp)
|
|
|
|
movq %rdi, 8(%rsp)
|
|
|
|
movq %rsi, 16(%rsp)
|
|
|
|
movq %rdx, 24(%rsp)
|
2019-05-06 08:25:49 +03:00
|
|
|
movq %rdx, 72(%rsp) # store a copy of rdx where we read the rdx return value from.
|
2016-04-21 15:19:32 +03:00
|
|
|
movq %rcx, 32(%rsp)
|
|
|
|
movq %r8, 40(%rsp)
|
|
|
|
movq %r9, 48(%rsp)
|
|
|
|
movq %rbp, 56(%rsp)
|
2019-05-06 08:25:49 +03:00
|
|
|
movaps %xmm0, 80(%rsp)
|
|
|
|
movaps %xmm1, 96(%rsp)
|
|
|
|
movaps %xmm2, 112(%rsp)
|
|
|
|
movaps %xmm3, 128(%rsp)
|
|
|
|
movaps %xmm4, 144(%rsp)
|
|
|
|
movaps %xmm5, 160(%rsp)
|
|
|
|
movaps %xmm6, 176(%rsp)
|
|
|
|
movaps %xmm7, 192(%rsp)
|
2016-04-21 15:19:32 +03:00
|
|
|
|
|
|
|
movq %rsp, %rdi
|
|
|
|
callq _xamarin_arch_trampoline
|
|
|
|
|
|
|
|
# get return value(s)
|
|
|
|
|
2019-05-06 08:25:49 +03:00
|
|
|
movq 64(%rsp), %rax
|
|
|
|
movq 72(%rsp), %rdx
|
|
|
|
movaps 80(%rsp), %xmm0
|
|
|
|
movaps 96(%rsp), %xmm1
|
2016-04-21 15:19:32 +03:00
|
|
|
|
2019-05-06 08:25:49 +03:00
|
|
|
addq $0xD0, %rsp # deallocate 208 bytes from the stack
|
2016-04-21 15:19:32 +03:00
|
|
|
popq %rbp
|
|
|
|
|
|
|
|
ret
|
2016-05-11 13:06:37 +03:00
|
|
|
.cfi_endproc
|
2016-04-21 15:19:32 +03:00
|
|
|
|
|
|
|
#
|
|
|
|
# trampolines
|
|
|
|
#
|
|
|
|
|
|
|
|
.globl _xamarin_trampoline
|
|
|
|
_xamarin_trampoline:
|
|
|
|
movq $0x0, %r11
|
|
|
|
jmp _xamarin_x86_64_common_trampoline
|
|
|
|
|
|
|
|
.globl _xamarin_static_trampoline
|
|
|
|
_xamarin_static_trampoline:
|
|
|
|
movq $0x1, %r11
|
|
|
|
jmp _xamarin_x86_64_common_trampoline
|
|
|
|
|
|
|
|
.globl _xamarin_ctor_trampoline
|
|
|
|
_xamarin_ctor_trampoline:
|
|
|
|
movq $0x2, %r11
|
|
|
|
jmp _xamarin_x86_64_common_trampoline
|
|
|
|
|
|
|
|
.globl _xamarin_fpret_single_trampoline
|
|
|
|
_xamarin_fpret_single_trampoline:
|
|
|
|
movq $0x4, %r11
|
|
|
|
jmp _xamarin_x86_64_common_trampoline
|
|
|
|
|
|
|
|
.globl _xamarin_static_fpret_single_trampoline
|
|
|
|
_xamarin_static_fpret_single_trampoline:
|
|
|
|
movq $0x5, %r11
|
|
|
|
jmp _xamarin_x86_64_common_trampoline
|
|
|
|
|
|
|
|
.globl _xamarin_fpret_double_trampoline
|
|
|
|
_xamarin_fpret_double_trampoline:
|
|
|
|
movq $0x8, %r11
|
|
|
|
jmp _xamarin_x86_64_common_trampoline
|
|
|
|
|
|
|
|
.globl _xamarin_static_fpret_double_trampoline
|
|
|
|
_xamarin_static_fpret_double_trampoline:
|
|
|
|
movq $0x9, %r11
|
|
|
|
jmp _xamarin_x86_64_common_trampoline
|
|
|
|
|
|
|
|
.globl _xamarin_stret_trampoline
|
|
|
|
_xamarin_stret_trampoline:
|
|
|
|
movq $0x10, %r11
|
|
|
|
jmp _xamarin_x86_64_common_trampoline
|
|
|
|
|
|
|
|
.globl _xamarin_static_stret_trampoline
|
|
|
|
_xamarin_static_stret_trampoline:
|
|
|
|
movq $0x11, %r11
|
|
|
|
jmp _xamarin_x86_64_common_trampoline
|
|
|
|
|
|
|
|
.globl _xamarin_longret_trampoline
|
|
|
|
_xamarin_longret_trampoline:
|
|
|
|
movq $0x20, %r11
|
|
|
|
jmp _xamarin_x86_64_common_trampoline
|
|
|
|
|
|
|
|
.globl _xamarin_static_longret_trampoline
|
|
|
|
_xamarin_static_longret_trampoline:
|
|
|
|
movq $0x21, %r11
|
|
|
|
jmp _xamarin_x86_64_common_trampoline
|
|
|
|
|
|
|
|
# etc...
|
|
|
|
|
|
|
|
#endif
|