xpcom/reflect/xptcall/src/md/win32/xptcinvoke_asm_x86_64.asm

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:866ebc755fb2
1 ; This Source Code Form is subject to the terms of the Mozilla Public
2 ; License, v. 2.0. If a copy of the MPL was not distributed with this
3 ; file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
5 extrn invoke_copy_to_stack:PROC
6
7
8 .CODE
9
10 ;
11 ;XPTC__InvokebyIndex(nsISupports* that, uint32_t methodIndex,
12 ; uint32_t paramCount, nsXPTCVariant* params)
13 ;
14
15 XPTC__InvokebyIndex PROC FRAME
16
17 ; store register parameters
18
19 mov qword ptr [rsp+32], r9 ; params
20 mov dword ptr [rsp+24], r8d ; paramCount
21 mov dword ptr [rsp+16], edx ; methodIndex
22 mov qword ptr [rsp+8], rcx ; that
23
24 push rbp
25 .PUSHREG rbp
26 mov rbp, rsp ; store current RSP to RBP
27 .SETFRAME rbp, 0
28 .ENDPROLOG
29
30 sub rsp, 32
31
32 ; maybe we don't have any parameters to copy
33
34 test r8d, r8d
35 jz noparams
36
37 ;
38 ; Build stack for stdcall
39 ;
40
41 ; 1st parameter is space for parameters
42
43 mov eax, r8d
44 or eax, 1
45 shl rax, 3 ; *= 8
46 sub rsp, rax
47 mov rcx, rsp
48
49 ; 2nd parameter is parameter count
50
51 mov edx, r8d
52
53 ; 3rd parameter is params
54
55 mov r8, r9
56
57 sub rsp, 40
58 call invoke_copy_to_stack ; rcx = d
59 ; edx = paramCount
60 ; r8 = s
61 add rsp, 32
62
63 ; Current stack is the following.
64 ;
65 ; 0h: [space (for this)]
66 ; 8h: [1st parameter]
67 ; 10h: [2nd parameter]
68 ; 18h: [3rd parameter]
69 ; 20h: [4th parameter]
70 ; ...
71 ;
72 ; On Win64 ABI, the first 4 parameters are passed using registers,
73 ; and others are on stack.
74
75 ; 1st, 2nd and 3rd arguments are passed via registers
76
77 mov rdx, qword ptr [rsp+8] ; 1st parameter
78 movsd xmm1, qword ptr [rsp+8] ; for double
79
80 mov r8, qword ptr [rsp+16] ; 2nd parameter
81 movsd xmm2, qword ptr [rsp+16] ; for double
82
83 mov r9, qword ptr [rsp+24] ; 3rd parameter
84 movsd xmm3, qword ptr [rsp+24] ; for double
85
86 ; rcx register is this
87
88 mov rcx, qword ptr [rbp+8+8] ; that
89
90 noparams:
91
92 ; calculate call address
93
94 mov r11, qword ptr [rcx]
95 mov eax, dword ptr [rbp+16+8] ; methodIndex
96
97 call qword ptr [r11+rax*8] ; stdcall, i.e. callee cleans up stack.
98
99 mov rsp, rbp
100 pop rbp
101
102 ret
103
104 XPTC__InvokebyIndex ENDP
105
106
107 END

mercurial