Mercurial > pub > dyncall > dyncall
annotate dyncallback/dyncall_callback_x64.S @ 588:dfc2e6ee8782 r1.4-RC3
- more robust endian detection, on some platforms inclusion of endian.h led to assuming wrong endianness (subtle if inclusion was in
- syscall test: added newline to output
author | Tassilo Philipp |
---|---|
date | Mon, 19 Sep 2022 09:54:21 +0200 |
parents | 951cbfb5020a |
children |
rev | line source |
---|---|
0 | 1 /* |
2 | |
3 Package: dyncall | |
4 Library: dyncallback | |
5 File: dyncallback/dyncall_callback_x64.S | |
6 Description: Callback Thunk entry for x64 (portasm version) | |
7 License: | |
8 | |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
9 Copyright (c) 2011-2022 Daniel Adler <dadler@uni-goettingen.de>, |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
10 Tassilo Philipp <tphilipp@potion-studios.com> |
0 | 11 |
12 Permission to use, copy, modify, and distribute this software for any | |
13 purpose with or without fee is hereby granted, provided that the above | |
14 copyright notice and this permission notice appear in all copies. | |
15 | |
16 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
17 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
18 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
19 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
20 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
21 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
22 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
23 | |
24 */ | |
25 | |
26 | |
27 | |
165
572aff021627
- file name/layout cleanup, removed "-att" from x64 .S filenames, as unnecessary and also misleading
cslag
parents:
0
diff
changeset
|
28 #include "../portasm/portasm-x64.S" |
0 | 29 |
30 /* structure sizes */ | |
31 | |
32 SET(DCThunk_size,24) | |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
33 SET(DCArgs_size_win64,96) /* 8 (stack_ptr) + 4 (reg_count) + 4 (pad_w) + 4 (aggr_return_register) + 4 (pad) + 8*4 (int regs) + 8 (aggrs) + 8*4 (float regs) */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
34 SET(DCArgs_size_sysv,144) /* 8 (stack_ptr) + 8 (reg_count) + 4 (aggr_return_register) + 4 (pad) + 8*6 (int regs) + 8 (aggrs) + 8*8 (float regs) */ |
0 | 35 SET(DCValue_size,8) |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
36 SET(DCRetRegs_SystemV_size,32) |
0 | 37 |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
38 /* frame local variable offsets relative to %rbp */ |
0 | 39 |
40 SET(FRAME_arg0_win64,48) | |
41 SET(FRAME_arg0_sysv,16) | |
42 SET(FRAME_return,8) | |
43 SET(FRAME_parent,0) | |
44 | |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
45 /* struct DCCallback layout, relative to ptr passed to functions below via RAX */ |
0 | 46 |
47 SET(CTX_thunk,0) | |
48 SET(CTX_handler,24) | |
49 SET(CTX_userdata,32) | |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
50 SET(CTX_aggr_ret_reg,40) |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
51 SET(CTX_pad,44) |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
52 SET(CTX_aggrs_pp,48) |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
53 SET(DCCallback_size,56) |
0 | 54 |
55 | |
56 | |
57 GLOBAL(dcCallback_x64_sysv) | |
58 BEGIN_PROC(dcCallback_x64_sysv) | |
165
572aff021627
- file name/layout cleanup, removed "-att" from x64 .S filenames, as unnecessary and also misleading
cslag
parents:
0
diff
changeset
|
59 |
0 | 60 PUSH(RBP) |
61 MOV(RSP,RBP) | |
62 | |
63 /* initialize DCArgs */ | |
64 | |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
65 /* float parameters (8 registers spill to DCArgs.reg_data) */ |
165
572aff021627
- file name/layout cleanup, removed "-att" from x64 .S filenames, as unnecessary and also misleading
cslag
parents:
0
diff
changeset
|
66 SUB(LIT(8*8),RSP) |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
67 MOVSD(XMM7, QWORD(RSP,8*7)) /* DCArgs offset 136: float parameter 7 */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
68 MOVSD(XMM6, QWORD(RSP,8*6)) /* DCArgs offset 128: float parameter 6 */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
69 MOVSD(XMM5, QWORD(RSP,8*5)) /* DCArgs offset 120: float parameter 5 */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
70 MOVSD(XMM4, QWORD(RSP,8*4)) /* DCArgs offset 112: float parameter 4 */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
71 MOVSD(XMM3, QWORD(RSP,8*3)) /* DCArgs offset 104: float parameter 3 */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
72 MOVSD(XMM2, QWORD(RSP,8*2)) /* DCArgs offset 96: float parameter 2 */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
73 MOVSD(XMM1, QWORD(RSP,8*1)) /* DCArgs offset 88: float parameter 1 */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
74 MOVSD(XMM0, QWORD(RSP,8*0)) /* DCArgs offset 80: float parameter 0 */ |
0 | 75 |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
76 /* integer parameters (6 registers spill to DCArgs.reg_data) */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
77 PUSH(R9) /* DCArgs offset 72: parameter 5 */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
78 PUSH(R8) /* DCArgs offset 64: parameter 4 */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
79 PUSH(RCX) /* DCArgs offset 56: parameter 3 */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
80 PUSH(RDX) /* DCArgs offset 48: parameter 2 */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
81 PUSH(RSI) /* DCArgs offset 40: parameter 1 */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
82 PUSH(RDI) /* DCArgs offset 32: parameter 0 */ |
0 | 83 |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
84 MOV(QWORD(RAX, CTX_aggrs_pp), R8) |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
85 PUSH(R8) /* DCArgs offset 24: **aggrs */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
86 |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
87 /* get val of aggr_return_register from DCCallback struct into r8's LSBs, clear */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
88 /* MSBs, write DCarg's pad and aggr_return_register at once */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
89 MOVL(DWORD(RAX, CTX_aggr_ret_reg), R8D) /* implicitly zeroes the high bits of R8 */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
90 PUSH(R8) /* DCArgs offset 16: pad=0, aggr_return_register=DCCallback.aggr_return_register */ |
0 | 91 /* register counts for integer/pointer and float regs */ |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
92 PUSH(LIT(0)) /* DCArgs offset 12: fcount */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
93 /* DCArgs offset 8: icount */ |
0 | 94 |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
95 LEA(QWORD(RBP,FRAME_arg0_sysv),RDX) /* DCArgs offset 0: *stack_ptr */ |
0 | 96 PUSH(RDX) |
97 | |
98 MOV(RSP,RSI) /* arg 1 RSI : DCArgs* */ | |
165
572aff021627
- file name/layout cleanup, removed "-att" from x64 .S filenames, as unnecessary and also misleading
cslag
parents:
0
diff
changeset
|
99 |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
100 /* stack space for DCValue or DCRetRegs_SysV (passed to handler as DCValue*) and padding */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
101 SUB(LIT(4*8),RSP) /* 4 qwords for DCRetRegs_SysV */ |
0 | 102 |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
103 /* call handler(*ctx, *args, *value, *userdata) - stack must be 16b aligned, here */ |
0 | 104 MOV(RAX,RDI) /* arg 0 RDI : DCCallback* (RAX) */ |
105 MOV(QWORD(RDI,CTX_userdata),RCX) /* arg 3 RCX : userdata* */ | |
106 MOV(RSP,RDX) /* arg 2 RDX : DCValue* */ | |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
107 |
0 | 108 CALL_REG(QWORD(RAX,CTX_handler)) |
109 | |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
110 /* get info about return type, use to select how to store reg-based retval */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
111 CMPL(LIT(-2/*see C*/), DWORD(RSP, 48)) /* rsp+48 = where r8 (aggr_return_register) was pushed */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
112 |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
113 /* if retval is small aggregate via regs */ |
540
951cbfb5020a
- fixed wrong symbol naming on some platforms
Tassilo Philipp
parents:
533
diff
changeset
|
114 JE(CSYM(scalar_retval)) |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
115 |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
116 MOV(QWORD(RSP,0),RAX) |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
117 MOV(QWORD(RSP,8),RDX) |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
118 MOVSD(QWORD(RSP,16),XMM0) /* @@@AGGR needed to be put in xmm in this case? @@@ also not what doc/appendix says, actually */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
119 MOVSD(QWORD(RSP,24),XMM1) /* @@@AGGR needed to be put in xmm in this case? @@@ also not what doc/appendix says, actually */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
120 |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
121 /* else (retval is int, float, or ptr to aggregate) */ |
540
951cbfb5020a
- fixed wrong symbol naming on some platforms
Tassilo Philipp
parents:
533
diff
changeset
|
122 JMP(CSYM(epilog)) |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
123 CSYM(scalar_retval): |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
124 |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
125 /* pass return type via registers, handle ints and floats */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
126 MOV(QWORD(RSP,0),RAX) |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
127 MOVD(RAX,XMM0) |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
128 |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
129 CSYM(epilog): |
0 | 130 |
131 MOV(RBP,RSP) | |
132 POP(RBP) | |
133 RET() | |
134 | |
135 END_PROC(dcCallback_x64_sysv) | |
136 | |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
137 |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
138 GLOBAL_FRAME(dcCallback_x64_win64) |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
139 FRAME_BEGIN_PROC(dcCallback_x64_win64) |
165
572aff021627
- file name/layout cleanup, removed "-att" from x64 .S filenames, as unnecessary and also misleading
cslag
parents:
0
diff
changeset
|
140 |
0 | 141 PUSH(RBP) |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
142 FRAME_PUSH_REG(RBP) |
0 | 143 MOV(RSP,RBP) |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
144 FRAME_SET(0, RBP) |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
145 FRAME_ENDPROLOG() |
0 | 146 |
147 /* initialize DCArgs */ | |
148 | |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
149 /* float parameters (4 registers spill to DCArgs.reg_data) */ |
165
572aff021627
- file name/layout cleanup, removed "-att" from x64 .S filenames, as unnecessary and also misleading
cslag
parents:
0
diff
changeset
|
150 SUB(LIT(4*8),RSP) |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
151 MOVSD(XMM3, QWORD(RSP,8*3)) /* DCArgs offset 88: float parameter 3 */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
152 MOVSD(XMM2, QWORD(RSP,8*2)) /* DCArgs offset 80: float parameter 2 */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
153 MOVSD(XMM1, QWORD(RSP,8*1)) /* DCArgs offset 72: float parameter 1 */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
154 MOVSD(XMM0, QWORD(RSP,8*0)) /* DCArgs offset 64: float parameter 0 */ |
0 | 155 |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
156 /* integer parameters (4 registers spill to DCArgs.reg_data) */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
157 PUSH(R9) /* DCArgs offset 56: parameter 3 */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
158 PUSH(R8) /* DCArgs offset 48: parameter 2 */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
159 PUSH(RDX) /* DCArgs offset 40: parameter 1 */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
160 PUSH(RCX) /* DCArgs offset 32: parameter 0 */ |
0 | 161 |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
162 MOV(QWORD(RAX, CTX_aggrs_pp), R8) |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
163 PUSH(R8) /* DCArgs offset 24: **aggrs */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
164 |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
165 /* get val of aggr_return_register from DCCallback struct into r8's LSBs, clear */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
166 /* MSBs, write DCarg's pad and aggr_return_register at once */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
167 MOVL(DWORD(RAX, CTX_aggr_ret_reg), R8D) /* implicitly zeroes the high bits of R8 */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
168 PUSH(R8) /* DCArgs offset 16: pad=0, aggr_return_register=DCCallback.aggr_return_register */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
169 |
0 | 170 /* register counts for integer/pointer and float regs */ |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
171 PUSH(LIT(0)) /* DCArgs offset 12: pad_w */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
172 /* DCArgs offset 8: reg_count */ |
0 | 173 |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
174 LEA(QWORD(RBP,FRAME_arg0_win64),RDX) /* DCArgs offset 0: *stack_ptr */ |
0 | 175 PUSH(RDX) |
176 | |
177 MOV(RSP,RDX) /* arg 1 RDX : DCArgs* */ | |
178 | |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
179 /* space for retval (also aligns stack to 16b) */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
180 SUB(LIT(2*8),RSP) |
0 | 181 |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
182 /* call handler(*ctx, *args, *value, *userdata) - stack must be 16b aligned, here */ |
0 | 183 MOV(RAX,RCX) /* arg 0 RCX : DCCallback* (RAX) */ |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
184 MOV(QWORD(RAX,CTX_userdata),R9) /* arg 3 R9 : userdata* */ |
0 | 185 MOV(RSP,R8) /* arg 2 R8 : DCValue* */ |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
186 |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
187 /* spill area */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
188 SUB(LIT(4*8),RSP) /* 4 qwords for spill area */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
189 |
0 | 190 CALL_REG(QWORD(RAX,CTX_handler)) |
191 | |
192 /* pass return type via registers, handle ints and floats */ | |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
193 MOV(QWORD(RSP,4*8),RAX) |
0 | 194 MOVD(RAX,XMM0) |
195 | |
196 MOV(RBP,RSP) | |
197 POP(RBP) | |
198 RET() | |
199 | |
165
572aff021627
- file name/layout cleanup, removed "-att" from x64 .S filenames, as unnecessary and also misleading
cslag
parents:
0
diff
changeset
|
200 END_PROC(dcCallback_x64_win64) |
0 | 201 |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
202 |
0 | 203 END_ASM |
204 | |
533
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
205 /* vim: set ts=8: */ |
71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents:
402
diff
changeset
|
206 |