@@ -44,6 +44,7 @@ using v8::internal::Label;
44
44
using v8::internal::rax;
45
45
using v8::internal::rsi;
46
46
using v8::internal::rdi;
47
+ using v8::internal::rcx;
47
48
using v8::internal::rdx;
48
49
using v8::internal::rbp;
49
50
using v8::internal::rsp;
@@ -53,20 +54,28 @@ using v8::internal::less_equal;
53
54
using v8::internal::not_equal;
54
55
using v8::internal::greater;
55
56
56
-
57
57
// Test the x64 assembler by compiling some simple functions into
58
58
// a buffer and executing them. These tests do not initialize the
59
59
// V8 library, create a context, or use any V8 objects.
60
- // The AMD64 calling convention is used, with the first five arguments
61
- // in RSI, RDI , RDX, RCX, R8, and R9, and floating point arguments in
60
+ // The AMD64 calling convention is used, with the first six arguments
61
+ // in RDI, RSI , RDX, RCX, R8, and R9, and floating point arguments in
62
62
// the XMM registers. The return value is in RAX.
63
63
// This calling convention is used on Linux, with GCC, and on Mac OS,
64
- // with GCC. A different convention is used on 64-bit windows.
64
+ // with GCC. A different convention is used on 64-bit windows,
65
+ // where the first four integer arguments are passed in RCX, RDX, R8 and R9.
65
66
66
67
typedef int (*F0)();
67
68
typedef int (*F1)(int64_t x);
68
69
typedef int (*F2)(int64_t x, int64_t y);
69
70
71
+ #ifdef _WIN64
72
+ static const v8::internal::Register arg1 = rcx;
73
+ static const v8::internal::Register arg2 = rdx;
74
+ #else
75
+ static const v8::internal::Register arg1 = rdi;
76
+ static const v8::internal::Register arg2 = rsi;
77
+ #endif
78
+
70
79
#define __ assm.
71
80
72
81
@@ -80,7 +89,7 @@ TEST(AssemblerX64ReturnOperation) {
80
89
Assembler assm (buffer, actual_size);
81
90
82
91
// Assemble a simple function that copies argument 2 and returns it.
83
- __ movq (rax, rsi );
92
+ __ movq (rax, arg2 );
84
93
__ nop ();
85
94
__ ret (0 );
86
95
@@ -105,9 +114,9 @@ TEST(AssemblerX64StackOperations) {
105
114
// incorrect stack frames when debugging this function (which has them).
106
115
__ push (rbp);
107
116
__ movq (rbp, rsp);
108
- __ push (rsi ); // Value at (rbp - 8)
109
- __ push (rsi ); // Value at (rbp - 16)
110
- __ push (rdi ); // Value at (rbp - 24)
117
+ __ push (arg2 ); // Value at (rbp - 8)
118
+ __ push (arg2 ); // Value at (rbp - 16)
119
+ __ push (arg1 ); // Value at (rbp - 24)
111
120
__ pop (rax);
112
121
__ pop (rax);
113
122
__ pop (rax);
@@ -132,8 +141,8 @@ TEST(AssemblerX64ArithmeticOperations) {
132
141
Assembler assm (buffer, actual_size);
133
142
134
143
// Assemble a simple function that adds arguments returning the sum.
135
- __ movq (rax, rsi );
136
- __ addq (rax, rdi );
144
+ __ movq (rax, arg2 );
145
+ __ addq (rax, arg1 );
137
146
__ ret (0 );
138
147
139
148
CodeDesc desc;
@@ -154,8 +163,8 @@ TEST(AssemblerX64ImulOperation) {
154
163
155
164
// Assemble a simple function that multiplies arguments returning the high
156
165
// word.
157
- __ movq (rax, rsi );
158
- __ imul (rdi );
166
+ __ movq (rax, arg2 );
167
+ __ imul (arg1 );
159
168
__ movq (rax, rdx);
160
169
__ ret (0 );
161
170
@@ -182,14 +191,16 @@ TEST(AssemblerX64MemoryOperands) {
182
191
// Assemble a simple function that copies argument 2 and returns it.
183
192
__ push (rbp);
184
193
__ movq (rbp, rsp);
185
- __ push (rsi); // Value at (rbp - 8)
186
- __ push (rsi); // Value at (rbp - 16)
187
- __ push (rdi); // Value at (rbp - 24)
194
+
195
+ __ push (arg2); // Value at (rbp - 8)
196
+ __ push (arg2); // Value at (rbp - 16)
197
+ __ push (arg1); // Value at (rbp - 24)
198
+
188
199
const int kStackElementSize = 8 ;
189
200
__ movq (rax, Operand (rbp, -3 * kStackElementSize ));
190
- __ pop (rsi );
191
- __ pop (rsi );
192
- __ pop (rsi );
201
+ __ pop (arg2 );
202
+ __ pop (arg2 );
203
+ __ pop (arg2 );
193
204
__ pop (rbp);
194
205
__ nop ();
195
206
__ ret (0 );
@@ -210,13 +221,14 @@ TEST(AssemblerX64ControlFlow) {
210
221
CHECK (buffer);
211
222
Assembler assm (buffer, actual_size);
212
223
213
- // Assemble a simple function that copies argument 2 and returns it.
224
+ // Assemble a simple function that copies argument 1 and returns it.
214
225
__ push (rbp);
226
+
215
227
__ movq (rbp, rsp);
216
- __ movq (rax, rdi );
228
+ __ movq (rax, arg1 );
217
229
Label target;
218
230
__ jmp (&target);
219
- __ movq (rax, rsi );
231
+ __ movq (rax, arg2 );
220
232
__ bind (&target);
221
233
__ pop (rbp);
222
234
__ ret (0 );
0 commit comments