blob: 6cd58ec209bb92a3ff8e0e4123ae236e6b894f92 [file] [log] [blame]
Ben Murdoch3ef787d2012-04-12 10:51:47 +01001// Copyright 2011 the V8 project authors. All rights reserved.
2// Redistribution and use in source and binary forms, with or without
3// modification, are permitted provided that the following conditions are
4// met:
5//
6// * Redistributions of source code must retain the above copyright
7// notice, this list of conditions and the following disclaimer.
8// * Redistributions in binary form must reproduce the above
9// copyright notice, this list of conditions and the following
10// disclaimer in the documentation and/or other materials provided
11// with the distribution.
12// * Neither the name of Google Inc. nor the names of its
13// contributors may be used to endorse or promote products derived
14// from this software without specific prior written permission.
15//
16// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28#include <stdlib.h>
29
Ben Murdochb8a8cc12014-11-26 15:28:44 +000030#include "src/v8.h"
Ben Murdoch3ef787d2012-04-12 10:51:47 +010031
Ben Murdochb8a8cc12014-11-26 15:28:44 +000032#include "src/debug.h"
33#include "src/disasm.h"
34#include "src/disassembler.h"
35#include "src/ic/ic.h"
36#include "src/macro-assembler.h"
37#include "src/serialize.h"
38#include "test/cctest/cctest.h"
Ben Murdoch3ef787d2012-04-12 10:51:47 +010039
40using namespace v8::internal;
41
Ben Murdoch3ef787d2012-04-12 10:51:47 +010042
43#define __ assm.
44
45
46static void DummyStaticFunction(Object* result) {
47}
48
49
50TEST(DisasmX64) {
Ben Murdochb8a8cc12014-11-26 15:28:44 +000051 CcTest::InitializeVM();
52 Isolate* isolate = CcTest::i_isolate();
53 HandleScope scope(isolate);
Emily Bernierd0a1eb72015-03-24 16:35:39 -040054 v8::internal::byte buffer[4096];
Ben Murdochb8a8cc12014-11-26 15:28:44 +000055 Assembler assm(isolate, buffer, sizeof buffer);
Ben Murdoch3ef787d2012-04-12 10:51:47 +010056 DummyStaticFunction(NULL); // just bloody use it (DELETE; debugging)
57
58 // Short immediate instructions
59 __ addq(rax, Immediate(12345678));
Ben Murdochb8a8cc12014-11-26 15:28:44 +000060 __ orq(rax, Immediate(12345678));
Ben Murdoch3ef787d2012-04-12 10:51:47 +010061 __ subq(rax, Immediate(12345678));
Ben Murdochb8a8cc12014-11-26 15:28:44 +000062 __ xorq(rax, Immediate(12345678));
63 __ andq(rax, Immediate(12345678));
Ben Murdoch3ef787d2012-04-12 10:51:47 +010064
65 // ---- This one caused crash
66 __ movq(rbx, Operand(rsp, rcx, times_2, 0)); // [rsp+rcx*4]
67
68 // ---- All instructions that I can think of
69 __ addq(rdx, rbx);
70 __ addq(rdx, Operand(rbx, 0));
71 __ addq(rdx, Operand(rbx, 16));
72 __ addq(rdx, Operand(rbx, 1999));
Ben Murdochb8a8cc12014-11-26 15:28:44 +000073 __ addq(rdx, Operand(rbx, -4));
74 __ addq(rdx, Operand(rbx, -1999));
Ben Murdoch3ef787d2012-04-12 10:51:47 +010075 __ addq(rdx, Operand(rsp, 0));
76 __ addq(rdx, Operand(rsp, 16));
77 __ addq(rdx, Operand(rsp, 1999));
Ben Murdochb8a8cc12014-11-26 15:28:44 +000078 __ addq(rdx, Operand(rsp, -4));
79 __ addq(rdx, Operand(rsp, -1999));
80 __ nop();
81 __ addq(rsi, Operand(rcx, times_4, 0));
82 __ addq(rsi, Operand(rcx, times_4, 24));
83 __ addq(rsi, Operand(rcx, times_4, -4));
84 __ addq(rsi, Operand(rcx, times_4, -1999));
Ben Murdoch3ef787d2012-04-12 10:51:47 +010085 __ nop();
86 __ addq(rdi, Operand(rbp, rcx, times_4, 0));
87 __ addq(rdi, Operand(rbp, rcx, times_4, 12));
Ben Murdochb8a8cc12014-11-26 15:28:44 +000088 __ addq(rdi, Operand(rbp, rcx, times_4, -8));
89 __ addq(rdi, Operand(rbp, rcx, times_4, -3999));
Ben Murdoch3ef787d2012-04-12 10:51:47 +010090 __ addq(Operand(rbp, rcx, times_4, 12), Immediate(12));
91
92 __ nop();
93 __ addq(rbx, Immediate(12));
94 __ nop();
95 __ nop();
Ben Murdochb8a8cc12014-11-26 15:28:44 +000096 __ andq(rdx, Immediate(3));
97 __ andq(rdx, Operand(rsp, 4));
Ben Murdoch3ef787d2012-04-12 10:51:47 +010098 __ cmpq(rdx, Immediate(3));
99 __ cmpq(rdx, Operand(rsp, 4));
100 __ cmpq(Operand(rbp, rcx, times_4, 0), Immediate(1000));
101 __ cmpb(rbx, Operand(rbp, rcx, times_2, 0));
102 __ cmpb(Operand(rbp, rcx, times_2, 0), rbx);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000103 __ orq(rdx, Immediate(3));
104 __ xorq(rdx, Immediate(3));
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100105 __ nop();
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000106 __ cpuid();
107 __ movsxbl(rdx, Operand(rcx, 0));
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100108 __ movsxbq(rdx, Operand(rcx, 0));
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000109 __ movsxwl(rdx, Operand(rcx, 0));
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100110 __ movsxwq(rdx, Operand(rcx, 0));
111 __ movzxbl(rdx, Operand(rcx, 0));
112 __ movzxwl(rdx, Operand(rcx, 0));
113 __ movzxbq(rdx, Operand(rcx, 0));
114 __ movzxwq(rdx, Operand(rcx, 0));
115
116 __ nop();
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000117 __ imulq(rdx, rcx);
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100118 __ shld(rdx, rcx);
119 __ shrd(rdx, rcx);
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400120 __ shlq(Operand(rdi, rax, times_4, 100), Immediate(1));
121 __ shlq(Operand(rdi, rax, times_4, 100), Immediate(6));
122 __ shlq(Operand(r15, 0), Immediate(1));
123 __ shlq(Operand(r15, 0), Immediate(6));
124 __ shlq_cl(Operand(r15, 0));
125 __ shlq_cl(Operand(r15, 0));
126 __ shlq_cl(Operand(rdi, rax, times_4, 100));
127 __ shlq_cl(Operand(rdi, rax, times_4, 100));
128 __ shlq(rdx, Immediate(1));
129 __ shlq(rdx, Immediate(6));
130 __ shll(Operand(rdi, rax, times_4, 100), Immediate(1));
131 __ shll(Operand(rdi, rax, times_4, 100), Immediate(6));
132 __ shll(Operand(r15, 0), Immediate(1));
133 __ shll(Operand(r15, 0), Immediate(6));
134 __ shll_cl(Operand(r15, 0));
135 __ shll_cl(Operand(r15, 0));
136 __ shll_cl(Operand(rdi, rax, times_4, 100));
137 __ shll_cl(Operand(rdi, rax, times_4, 100));
138 __ shll(rdx, Immediate(1));
139 __ shll(rdx, Immediate(6));
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100140 __ bts(Operand(rdx, 0), rcx);
141 __ bts(Operand(rbx, rcx, times_4, 0), rcx);
142 __ nop();
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000143 __ pushq(Immediate(12));
144 __ pushq(Immediate(23456));
145 __ pushq(rcx);
146 __ pushq(rsi);
147 __ pushq(Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
148 __ pushq(Operand(rbx, rcx, times_4, 0));
149 __ pushq(Operand(rbx, rcx, times_4, 0));
150 __ pushq(Operand(rbx, rcx, times_4, 10000));
151 __ popq(rdx);
152 __ popq(rax);
153 __ popq(Operand(rbx, rcx, times_4, 0));
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100154 __ nop();
155
156 __ addq(rdx, Operand(rsp, 16));
157 __ addq(rdx, rcx);
158 __ movb(rdx, Operand(rcx, 0));
159 __ movb(rcx, Immediate(6));
160 __ movb(Operand(rsp, 16), rdx);
161 __ movw(Operand(rsp, 16), rdx);
162 __ nop();
163 __ movsxwq(rdx, Operand(rsp, 12));
164 __ movsxbq(rdx, Operand(rsp, 12));
165 __ movsxlq(rdx, Operand(rsp, 12));
166 __ movzxwq(rdx, Operand(rsp, 12));
167 __ movzxbq(rdx, Operand(rsp, 12));
168 __ nop();
169 __ movq(rdx, Immediate(1234567));
170 __ movq(rdx, Operand(rsp, 12));
171 __ movq(Operand(rbx, rcx, times_4, 10000), Immediate(12345));
172 __ movq(Operand(rbx, rcx, times_4, 10000), rdx);
173 __ nop();
174 __ decb(rdx);
175 __ decb(Operand(rax, 10));
176 __ decb(Operand(rbx, rcx, times_4, 10000));
177 __ decq(rdx);
178 __ cdq();
179
180 __ nop();
181 __ idivq(rdx);
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400182 __ mull(rdx);
183 __ mulq(rdx);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000184 __ negq(rdx);
185 __ notq(rdx);
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100186 __ testq(Operand(rbx, rcx, times_4, 10000), rdx);
187
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000188 __ imulq(rdx, rcx, Immediate(12));
189 __ imulq(rdx, rcx, Immediate(1000));
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400190 __ imulq(rdx, Operand(rbx, rcx, times_4, 10000));
191 __ imulq(rdx, Operand(rbx, rcx, times_4, 10000), Immediate(12));
192 __ imulq(rdx, Operand(rbx, rcx, times_4, 10000), Immediate(1000));
193 __ imull(r15, rcx, Immediate(12));
194 __ imull(r15, rcx, Immediate(1000));
195 __ imull(r15, Operand(rbx, rcx, times_4, 10000));
196 __ imull(r15, Operand(rbx, rcx, times_4, 10000), Immediate(12));
197 __ imull(r15, Operand(rbx, rcx, times_4, 10000), Immediate(1000));
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100198
199 __ incq(rdx);
200 __ incq(Operand(rbx, rcx, times_4, 10000));
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000201 __ pushq(Operand(rbx, rcx, times_4, 10000));
202 __ popq(Operand(rbx, rcx, times_4, 10000));
203 // TODO(mstarzinger): The following is protected.
204 // __ jmp(Operand(rbx, rcx, times_4, 10000));
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100205
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000206 __ leaq(rdx, Operand(rbx, rcx, times_4, 10000));
207 __ orq(rdx, Immediate(12345));
208 __ orq(rdx, Operand(rbx, rcx, times_4, 10000));
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100209
210 __ nop();
211
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000212 __ rclq(rdx, Immediate(1));
213 __ rclq(rdx, Immediate(7));
214 __ rcrq(rdx, Immediate(1));
215 __ rcrq(rdx, Immediate(7));
216 __ sarq(rdx, Immediate(1));
217 __ sarq(rdx, Immediate(6));
218 __ sarq_cl(rdx);
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100219 __ sbbq(rdx, rbx);
220 __ shld(rdx, rbx);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000221 __ shlq(rdx, Immediate(1));
222 __ shlq(rdx, Immediate(6));
223 __ shlq_cl(rdx);
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100224 __ shrd(rdx, rbx);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000225 __ shrq(rdx, Immediate(1));
226 __ shrq(rdx, Immediate(7));
227 __ shrq_cl(rdx);
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100228
229
230 // Immediates
231
232 __ addq(rbx, Immediate(12));
233 __ addq(Operand(rdx, rcx, times_4, 10000), Immediate(12));
234
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000235 __ andq(rbx, Immediate(12345));
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100236
237 __ cmpq(rbx, Immediate(12345));
238 __ cmpq(rbx, Immediate(12));
239 __ cmpq(Operand(rdx, rcx, times_4, 10000), Immediate(12));
240 __ cmpb(rax, Immediate(100));
241
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000242 __ orq(rbx, Immediate(12345));
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100243
244 __ subq(rbx, Immediate(12));
245 __ subq(Operand(rdx, rcx, times_4, 10000), Immediate(12));
246
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000247 __ xorq(rbx, Immediate(12345));
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100248
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000249 __ imulq(rdx, rcx, Immediate(12));
250 __ imulq(rdx, rcx, Immediate(1000));
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100251
252 __ cld();
253
254 __ subq(rdx, Operand(rbx, rcx, times_4, 10000));
255 __ subq(rdx, rbx);
256
257 __ testq(rdx, Immediate(12345));
258 __ testq(Operand(rbx, rcx, times_8, 10000), rdx);
259 __ testb(Operand(rcx, rbx, times_2, 1000), rdx);
260 __ testb(Operand(rax, -20), Immediate(0x9A));
261 __ nop();
262
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000263 __ xorq(rdx, Immediate(12345));
264 __ xorq(rdx, Operand(rbx, rcx, times_8, 10000));
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100265 __ bts(Operand(rbx, rcx, times_8, 10000), rdx);
266 __ hlt();
267 __ int3();
268 __ ret(0);
269 __ ret(8);
270
271 // Calls
272
273 Label L1, L2;
274 __ bind(&L1);
275 __ nop();
276 __ call(&L1);
277 __ call(&L2);
278 __ nop();
279 __ bind(&L2);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000280 // TODO(mstarzinger): The following is protected.
281 // __ call(Operand(rbx, rcx, times_4, 10000));
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100282 __ nop();
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000283 Handle<Code> ic(LoadIC::initialize_stub(isolate, NOT_CONTEXTUAL));
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100284 __ call(ic, RelocInfo::CODE_TARGET);
285 __ nop();
286 __ nop();
287
288 __ jmp(&L1);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000289 // TODO(mstarzinger): The following is protected.
290 // __ jmp(Operand(rbx, rcx, times_4, 10000));
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100291 ExternalReference after_break_target =
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000292 ExternalReference::debug_after_break_target_address(isolate);
293 USE(after_break_target);
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100294 __ jmp(ic, RelocInfo::CODE_TARGET);
295 __ nop();
296
297
298 Label Ljcc;
299 __ nop();
300 // long jumps
301 __ j(overflow, &Ljcc);
302 __ j(no_overflow, &Ljcc);
303 __ j(below, &Ljcc);
304 __ j(above_equal, &Ljcc);
305 __ j(equal, &Ljcc);
306 __ j(not_equal, &Ljcc);
307 __ j(below_equal, &Ljcc);
308 __ j(above, &Ljcc);
309 __ j(sign, &Ljcc);
310 __ j(not_sign, &Ljcc);
311 __ j(parity_even, &Ljcc);
312 __ j(parity_odd, &Ljcc);
313 __ j(less, &Ljcc);
314 __ j(greater_equal, &Ljcc);
315 __ j(less_equal, &Ljcc);
316 __ j(greater, &Ljcc);
317 __ nop();
318 __ bind(&Ljcc);
319 // short jumps
320 __ j(overflow, &Ljcc);
321 __ j(no_overflow, &Ljcc);
322 __ j(below, &Ljcc);
323 __ j(above_equal, &Ljcc);
324 __ j(equal, &Ljcc);
325 __ j(not_equal, &Ljcc);
326 __ j(below_equal, &Ljcc);
327 __ j(above, &Ljcc);
328 __ j(sign, &Ljcc);
329 __ j(not_sign, &Ljcc);
330 __ j(parity_even, &Ljcc);
331 __ j(parity_odd, &Ljcc);
332 __ j(less, &Ljcc);
333 __ j(greater_equal, &Ljcc);
334 __ j(less_equal, &Ljcc);
335 __ j(greater, &Ljcc);
336
337 // 0xD9 instructions
338 __ nop();
339
340 __ fld(1);
341 __ fld1();
342 __ fldz();
343 __ fldpi();
344 __ fabs();
345 __ fchs();
346 __ fprem();
347 __ fprem1();
348 __ fincstp();
349 __ ftst();
350 __ fxch(3);
351 __ fld_s(Operand(rbx, rcx, times_4, 10000));
352 __ fstp_s(Operand(rbx, rcx, times_4, 10000));
353 __ ffree(3);
354 __ fld_d(Operand(rbx, rcx, times_4, 10000));
355 __ fstp_d(Operand(rbx, rcx, times_4, 10000));
356 __ nop();
357
358 __ fild_s(Operand(rbx, rcx, times_4, 10000));
359 __ fistp_s(Operand(rbx, rcx, times_4, 10000));
360 __ fild_d(Operand(rbx, rcx, times_4, 10000));
361 __ fistp_d(Operand(rbx, rcx, times_4, 10000));
362 __ fnstsw_ax();
363 __ nop();
364 __ fadd(3);
365 __ fsub(3);
366 __ fmul(3);
367 __ fdiv(3);
368
369 __ faddp(3);
370 __ fsubp(3);
371 __ fmulp(3);
372 __ fdivp(3);
373 __ fcompp();
374 __ fwait();
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000375 __ frndint();
376 __ fninit();
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100377 __ nop();
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100378
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000379 // SSE instruction
380 {
381 // Move operation
382 __ cvttss2si(rdx, Operand(rbx, rcx, times_4, 10000));
383 __ cvttss2si(rdx, xmm1);
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400384 __ cvtsd2ss(xmm0, xmm1);
385 __ cvtsd2ss(xmm0, Operand(rbx, rcx, times_4, 10000));
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000386 __ movaps(xmm0, xmm1);
387
388 // logic operation
389 __ andps(xmm0, xmm1);
390 __ andps(xmm0, Operand(rbx, rcx, times_4, 10000));
391 __ orps(xmm0, xmm1);
392 __ orps(xmm0, Operand(rbx, rcx, times_4, 10000));
393 __ xorps(xmm0, xmm1);
394 __ xorps(xmm0, Operand(rbx, rcx, times_4, 10000));
395
396 // Arithmetic operation
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400397 __ addss(xmm1, xmm0);
398 __ addss(xmm1, Operand(rbx, rcx, times_4, 10000));
399 __ mulss(xmm1, xmm0);
400 __ mulss(xmm1, Operand(rbx, rcx, times_4, 10000));
401 __ subss(xmm1, xmm0);
402 __ subss(xmm1, Operand(rbx, rcx, times_4, 10000));
403 __ divss(xmm1, xmm0);
404 __ divss(xmm1, Operand(rbx, rcx, times_4, 10000));
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000405 __ addps(xmm1, xmm0);
406 __ addps(xmm1, Operand(rbx, rcx, times_4, 10000));
407 __ subps(xmm1, xmm0);
408 __ subps(xmm1, Operand(rbx, rcx, times_4, 10000));
409 __ mulps(xmm1, xmm0);
410 __ mulps(xmm1, Operand(rbx, rcx, times_4, 10000));
411 __ divps(xmm1, xmm0);
412 __ divps(xmm1, Operand(rbx, rcx, times_4, 10000));
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400413
414 __ ucomiss(xmm0, xmm1);
415 __ ucomiss(xmm0, Operand(rbx, rcx, times_4, 10000));
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000416 }
417 // SSE 2 instructions
418 {
419 __ cvttsd2si(rdx, Operand(rbx, rcx, times_4, 10000));
420 __ cvttsd2si(rdx, xmm1);
421 __ cvttsd2siq(rdx, xmm1);
422 __ cvttsd2siq(rdx, Operand(rbx, rcx, times_4, 10000));
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400423 __ cvtqsi2sd(xmm1, Operand(rbx, rcx, times_4, 10000));
424 __ cvtqsi2sd(xmm1, rdx);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000425 __ movsd(xmm1, Operand(rbx, rcx, times_4, 10000));
426 __ movsd(Operand(rbx, rcx, times_4, 10000), xmm1);
427 // 128 bit move instructions.
428 __ movdqa(xmm0, Operand(rbx, rcx, times_4, 10000));
429 __ movdqa(Operand(rbx, rcx, times_4, 10000), xmm0);
430
431 __ addsd(xmm1, xmm0);
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400432 __ addsd(xmm1, Operand(rbx, rcx, times_4, 10000));
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000433 __ mulsd(xmm1, xmm0);
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400434 __ mulsd(xmm1, Operand(rbx, rcx, times_4, 10000));
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000435 __ subsd(xmm1, xmm0);
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400436 __ subsd(xmm1, Operand(rbx, rcx, times_4, 10000));
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000437 __ divsd(xmm1, xmm0);
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400438 __ divsd(xmm1, Operand(rbx, rcx, times_4, 10000));
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000439 __ ucomisd(xmm0, xmm1);
440
441 __ andpd(xmm0, xmm1);
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400442
443 __ pslld(xmm0, 6);
444 __ psrld(xmm0, 6);
445 __ psllq(xmm0, 6);
446 __ psrlq(xmm0, 6);
447
448 __ pcmpeqd(xmm1, xmm0);
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100449 }
450
451 // cmov.
452 {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000453 __ cmovq(overflow, rax, Operand(rax, 0));
454 __ cmovq(no_overflow, rax, Operand(rax, 1));
455 __ cmovq(below, rax, Operand(rax, 2));
456 __ cmovq(above_equal, rax, Operand(rax, 3));
457 __ cmovq(equal, rax, Operand(rbx, 0));
458 __ cmovq(not_equal, rax, Operand(rbx, 1));
459 __ cmovq(below_equal, rax, Operand(rbx, 2));
460 __ cmovq(above, rax, Operand(rbx, 3));
461 __ cmovq(sign, rax, Operand(rcx, 0));
462 __ cmovq(not_sign, rax, Operand(rcx, 1));
463 __ cmovq(parity_even, rax, Operand(rcx, 2));
464 __ cmovq(parity_odd, rax, Operand(rcx, 3));
465 __ cmovq(less, rax, Operand(rdx, 0));
466 __ cmovq(greater_equal, rax, Operand(rdx, 1));
467 __ cmovq(less_equal, rax, Operand(rdx, 2));
468 __ cmovq(greater, rax, Operand(rdx, 3));
469 }
470
471 {
472 if (CpuFeatures::IsSupported(SSE4_1)) {
473 CpuFeatureScope scope(&assm, SSE4_1);
474 __ extractps(rax, xmm1, 0);
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100475 }
476 }
477
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400478 // AVX instruction
479 {
480 if (CpuFeatures::IsSupported(AVX)) {
481 CpuFeatureScope scope(&assm, AVX);
482 __ vaddsd(xmm0, xmm1, xmm2);
483 __ vaddsd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
484 __ vmulsd(xmm0, xmm1, xmm2);
485 __ vmulsd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
486 __ vsubsd(xmm0, xmm1, xmm2);
487 __ vsubsd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
488 __ vdivsd(xmm0, xmm1, xmm2);
489 __ vdivsd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
490 }
491 }
492
493 // FMA3 instruction
494 {
495 if (CpuFeatures::IsSupported(FMA3)) {
496 CpuFeatureScope scope(&assm, FMA3);
497 __ vfmadd132sd(xmm0, xmm1, xmm2);
498 __ vfmadd132sd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
499 __ vfmadd213sd(xmm0, xmm1, xmm2);
500 __ vfmadd213sd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
501 __ vfmadd231sd(xmm0, xmm1, xmm2);
502 __ vfmadd231sd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
503
504 __ vfmadd132sd(xmm9, xmm10, xmm11);
505 __ vfmadd132sd(xmm9, xmm10, Operand(r9, r11, times_4, 10000));
506 __ vfmadd213sd(xmm9, xmm10, xmm11);
507 __ vfmadd213sd(xmm9, xmm10, Operand(r9, r11, times_4, 10000));
508 __ vfmadd231sd(xmm9, xmm10, xmm11);
509 __ vfmadd231sd(xmm9, xmm10, Operand(r9, r11, times_4, 10000));
510
511 __ vfmsub132sd(xmm0, xmm1, xmm2);
512 __ vfmsub132sd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
513 __ vfmsub213sd(xmm0, xmm1, xmm2);
514 __ vfmsub213sd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
515 __ vfmsub231sd(xmm0, xmm1, xmm2);
516 __ vfmsub231sd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
517
518 __ vfnmadd132sd(xmm0, xmm1, xmm2);
519 __ vfnmadd132sd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
520 __ vfnmadd213sd(xmm0, xmm1, xmm2);
521 __ vfnmadd213sd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
522 __ vfnmadd231sd(xmm0, xmm1, xmm2);
523 __ vfnmadd231sd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
524
525 __ vfnmsub132sd(xmm0, xmm1, xmm2);
526 __ vfnmsub132sd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
527 __ vfnmsub213sd(xmm0, xmm1, xmm2);
528 __ vfnmsub213sd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
529 __ vfnmsub231sd(xmm0, xmm1, xmm2);
530 __ vfnmsub231sd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
531
532 __ vfmadd132ss(xmm0, xmm1, xmm2);
533 __ vfmadd132ss(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
534 __ vfmadd213ss(xmm0, xmm1, xmm2);
535 __ vfmadd213ss(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
536 __ vfmadd231ss(xmm0, xmm1, xmm2);
537 __ vfmadd231ss(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
538
539 __ vfmsub132ss(xmm0, xmm1, xmm2);
540 __ vfmsub132ss(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
541 __ vfmsub213ss(xmm0, xmm1, xmm2);
542 __ vfmsub213ss(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
543 __ vfmsub231ss(xmm0, xmm1, xmm2);
544 __ vfmsub231ss(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
545
546 __ vfnmadd132ss(xmm0, xmm1, xmm2);
547 __ vfnmadd132ss(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
548 __ vfnmadd213ss(xmm0, xmm1, xmm2);
549 __ vfnmadd213ss(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
550 __ vfnmadd231ss(xmm0, xmm1, xmm2);
551 __ vfnmadd231ss(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
552
553 __ vfnmsub132ss(xmm0, xmm1, xmm2);
554 __ vfnmsub132ss(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
555 __ vfnmsub213ss(xmm0, xmm1, xmm2);
556 __ vfnmsub213ss(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
557 __ vfnmsub231ss(xmm0, xmm1, xmm2);
558 __ vfnmsub231ss(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
559 }
560 }
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000561 // xchg.
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100562 {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000563 __ xchgq(rax, rax);
564 __ xchgq(rax, rbx);
565 __ xchgq(rbx, rbx);
566 __ xchgq(rbx, Operand(rsp, 12));
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100567 }
568
569 // Nop instructions
570 for (int i = 0; i < 16; i++) {
571 __ Nop(i);
572 }
573
574 __ ret(0);
575
576 CodeDesc desc;
577 assm.GetCode(&desc);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000578 Handle<Code> code = isolate->factory()->NewCode(
579 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
580 USE(code);
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100581#ifdef OBJECT_PRINT
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000582 OFStream os(stdout);
583 code->Print(os);
584 byte* begin = code->instruction_start();
585 byte* end = begin + code->instruction_size();
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100586 disasm::Disassembler::Disassemble(stdout, begin, end);
587#endif
588}
589
590#undef __