forked from dotnet/macios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrampolines-i386-objc_msgSend-copyframe.inc
53 lines (46 loc) · 1.72 KB
/
trampolines-i386-objc_msgSend-copyframe.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#
# input stack layout:
# %esp+20: ...
# %esp+16: second arg
# %esp+12: first arg
# %esp+8: sel
# %esp+4: this
# %esp: buffer
# and %ebp+8 = %esp
#
# We extend the stack (big enough for all the arguments again),
# and copy all the arguments as-is there, before
# calling objc_msgSend with those copied arguments.
# The only difference is that this method has an exception handler.
#
call _xamarin_get_frame_length # get_frame_length (this, sel)
# use eax to extend the stack, but it needs to be aligned to 16 bytes first
addl $15,%eax
shrl $4,%eax
sall $4,%eax
subl %eax,%esp
# store the number somewhere so we can restore the stack pointer later
movl %eax,-16(%ebp)
# copy arguments from old location in the stack to new location in the stack
# %ecx will hold the amount of bytes left to copy
# %esi the current src location
# %edi the current dst location
# %ecx will already be a multiple of 4, since the abi requires it
# (arguments smaller than 4 bytes are extended to 4 bytes according to
# http://developer.apple.com/library/mac/#documentation/DeveloperTools/Conceptual/LowLevelABI/130-IA-32_Function_Calling_Conventions/IA32.html#//apple_ref/doc/uid/TP40002492-SW4)
movl -16(%ebp),%ecx # ecx = frame_length
leal 8(%ebp),%esi # esi = address of first argument we got (buffer)
movl %esp,%edi # edi = address of the bottom of the stack
L_start:
cmpl $0,%ecx #
je L_end # while (left != 0) {
subl $4,%ecx # len -= 4
movl (%esi,%ecx),%eax # tmp = src [len]
movl %eax,(%edi,%ecx) # dst [len] = tmp
jmp L_start # }
L_end:
movaps -40(%ebp), %xmm0
movaps -56(%ebp), %xmm1
movaps -72(%ebp), %xmm2
movaps -88(%ebp), %xmm3