blob: 669e37ac69bff2b8a3a2b5347b5ccbacd4602474 [file] [log] [blame]
Ben Murdoch3ef787d2012-04-12 10:51:47 +01001// Copyright 2011 the V8 project authors. All rights reserved.
Steve Blocka7e24c12009-10-30 11:49:00 +00002// 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"
Steve Blocka7e24c12009-10-30 11:49:00 +000031
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000032#include "src/debug/debug.h"
Ben Murdochb8a8cc12014-11-26 15:28:44 +000033#include "src/disasm.h"
34#include "src/disassembler.h"
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000035#include "src/ia32/frames-ia32.h"
Ben Murdochb8a8cc12014-11-26 15:28:44 +000036#include "src/ic/ic.h"
37#include "src/macro-assembler.h"
Ben Murdochb8a8cc12014-11-26 15:28:44 +000038#include "test/cctest/cctest.h"
Steve Blocka7e24c12009-10-30 11:49:00 +000039
40using namespace v8::internal;
41
Steve Blocka7e24c12009-10-30 11:49:00 +000042
43#define __ assm.
44
45
46static void DummyStaticFunction(Object* result) {
47}
48
49
50TEST(DisasmIa320) {
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);
Steve Blocka7e24c12009-10-30 11:49:00 +000056 DummyStaticFunction(NULL); // just bloody use it (DELETE; debugging)
57
58 // Short immediate instructions
59 __ adc(eax, 12345678);
Ben Murdoch3ef787d2012-04-12 10:51:47 +010060 __ add(eax, Immediate(12345678));
Steve Blocka7e24c12009-10-30 11:49:00 +000061 __ or_(eax, 12345678);
Ben Murdoch3ef787d2012-04-12 10:51:47 +010062 __ sub(eax, Immediate(12345678));
Steve Blocka7e24c12009-10-30 11:49:00 +000063 __ xor_(eax, 12345678);
64 __ and_(eax, 12345678);
Ben Murdochb8a8cc12014-11-26 15:28:44 +000065 Handle<FixedArray> foo = isolate->factory()->NewFixedArray(10, TENURED);
Steve Blocka7e24c12009-10-30 11:49:00 +000066 __ cmp(eax, foo);
67
68 // ---- This one caused crash
69 __ mov(ebx, Operand(esp, ecx, times_2, 0)); // [esp+ecx*4]
70
71 // ---- All instructions that I can think of
Ben Murdoch3ef787d2012-04-12 10:51:47 +010072 __ add(edx, ebx);
Ben Murdochb8a8cc12014-11-26 15:28:44 +000073 __ add(edx, Operand(12, RelocInfo::NONE32));
Steve Blocka7e24c12009-10-30 11:49:00 +000074 __ add(edx, Operand(ebx, 0));
75 __ add(edx, Operand(ebx, 16));
76 __ add(edx, Operand(ebx, 1999));
Ben Murdochb8a8cc12014-11-26 15:28:44 +000077 __ add(edx, Operand(ebx, -4));
78 __ add(edx, Operand(ebx, -1999));
Steve Blocka7e24c12009-10-30 11:49:00 +000079 __ add(edx, Operand(esp, 0));
80 __ add(edx, Operand(esp, 16));
81 __ add(edx, Operand(esp, 1999));
Ben Murdochb8a8cc12014-11-26 15:28:44 +000082 __ add(edx, Operand(esp, -4));
83 __ add(edx, Operand(esp, -1999));
84 __ nop();
85 __ add(esi, Operand(ecx, times_4, 0));
86 __ add(esi, Operand(ecx, times_4, 24));
87 __ add(esi, Operand(ecx, times_4, -4));
88 __ add(esi, Operand(ecx, times_4, -1999));
Steve Blocka7e24c12009-10-30 11:49:00 +000089 __ nop();
90 __ add(edi, Operand(ebp, ecx, times_4, 0));
91 __ add(edi, Operand(ebp, ecx, times_4, 12));
Ben Murdochb8a8cc12014-11-26 15:28:44 +000092 __ add(edi, Operand(ebp, ecx, times_4, -8));
93 __ add(edi, Operand(ebp, ecx, times_4, -3999));
Steve Blocka7e24c12009-10-30 11:49:00 +000094 __ add(Operand(ebp, ecx, times_4, 12), Immediate(12));
95
96 __ nop();
Ben Murdoch3ef787d2012-04-12 10:51:47 +010097 __ add(ebx, Immediate(12));
Steve Blocka7e24c12009-10-30 11:49:00 +000098 __ nop();
99 __ adc(ecx, 12);
100 __ adc(ecx, 1000);
101 __ nop();
102 __ and_(edx, 3);
103 __ and_(edx, Operand(esp, 4));
104 __ cmp(edx, 3);
105 __ cmp(edx, Operand(esp, 4));
106 __ cmp(Operand(ebp, ecx, times_4, 0), Immediate(1000));
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000107 Handle<FixedArray> foo2 = isolate->factory()->NewFixedArray(10, TENURED);
Steve Blocka7e24c12009-10-30 11:49:00 +0000108 __ cmp(ebx, foo2);
Leon Clarked91b9f72010-01-27 17:25:45 +0000109 __ cmpb(ebx, Operand(ebp, ecx, times_2, 0));
110 __ cmpb(Operand(ebp, ecx, times_2, 0), ebx);
Steve Blocka7e24c12009-10-30 11:49:00 +0000111 __ or_(edx, 3);
112 __ xor_(edx, 3);
113 __ nop();
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000114 __ cpuid();
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100115 __ movsx_b(edx, ecx);
116 __ movsx_w(edx, ecx);
117 __ movzx_b(edx, ecx);
118 __ movzx_w(edx, ecx);
Steve Blocka7e24c12009-10-30 11:49:00 +0000119
120 __ nop();
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100121 __ imul(edx, ecx);
122 __ shld(edx, ecx);
123 __ shrd(edx, ecx);
124 __ bts(edx, ecx);
Steve Blocka7e24c12009-10-30 11:49:00 +0000125 __ bts(Operand(ebx, ecx, times_4, 0), ecx);
126 __ nop();
127 __ pushad();
128 __ popad();
129 __ pushfd();
130 __ popfd();
131 __ push(Immediate(12));
132 __ push(Immediate(23456));
133 __ push(ecx);
134 __ push(esi);
135 __ push(Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
136 __ push(Operand(ebx, ecx, times_4, 0));
137 __ push(Operand(ebx, ecx, times_4, 0));
138 __ push(Operand(ebx, ecx, times_4, 10000));
139 __ pop(edx);
140 __ pop(eax);
141 __ pop(Operand(ebx, ecx, times_4, 0));
142 __ nop();
143
144 __ add(edx, Operand(esp, 16));
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100145 __ add(edx, ecx);
146 __ mov_b(edx, ecx);
147 __ mov_b(ecx, 6);
Steve Blocka7e24c12009-10-30 11:49:00 +0000148 __ mov_b(Operand(ebx, ecx, times_4, 10000), 6);
149 __ mov_b(Operand(esp, 16), edx);
150 __ mov_w(edx, Operand(esp, 16));
151 __ mov_w(Operand(esp, 16), edx);
152 __ nop();
153 __ movsx_w(edx, Operand(esp, 12));
154 __ movsx_b(edx, Operand(esp, 12));
155 __ movzx_w(edx, Operand(esp, 12));
156 __ movzx_b(edx, Operand(esp, 12));
157 __ nop();
158 __ mov(edx, 1234567);
159 __ mov(edx, Operand(esp, 12));
160 __ mov(Operand(ebx, ecx, times_4, 10000), Immediate(12345));
161 __ mov(Operand(ebx, ecx, times_4, 10000), edx);
162 __ nop();
163 __ dec_b(edx);
Kristian Monsen0d5e1162010-09-30 15:31:59 +0100164 __ dec_b(Operand(eax, 10));
165 __ dec_b(Operand(ebx, ecx, times_4, 10000));
Steve Blocka7e24c12009-10-30 11:49:00 +0000166 __ dec(edx);
167 __ cdq();
168
169 __ nop();
170 __ idiv(edx);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000171 __ idiv(Operand(edx, ecx, times_1, 1));
172 __ idiv(Operand(esp, 12));
173 __ div(edx);
174 __ div(Operand(edx, ecx, times_1, 1));
175 __ div(Operand(esp, 12));
Steve Blocka7e24c12009-10-30 11:49:00 +0000176 __ mul(edx);
177 __ neg(edx);
178 __ not_(edx);
179 __ test(Operand(ebx, ecx, times_4, 10000), Immediate(123456));
180
181 __ imul(edx, Operand(ebx, ecx, times_4, 10000));
182 __ imul(edx, ecx, 12);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000183 __ imul(edx, Operand(edx, eax, times_2, 42), 8);
Steve Blocka7e24c12009-10-30 11:49:00 +0000184 __ imul(edx, ecx, 1000);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000185 __ imul(edx, Operand(ebx, ecx, times_4, 1), 9000);
Steve Blocka7e24c12009-10-30 11:49:00 +0000186
187 __ inc(edx);
188 __ inc(Operand(ebx, ecx, times_4, 10000));
189 __ push(Operand(ebx, ecx, times_4, 10000));
190 __ pop(Operand(ebx, ecx, times_4, 10000));
191 __ call(Operand(ebx, ecx, times_4, 10000));
192 __ jmp(Operand(ebx, ecx, times_4, 10000));
193
194 __ lea(edx, Operand(ebx, ecx, times_4, 10000));
195 __ or_(edx, 12345);
196 __ or_(edx, Operand(ebx, ecx, times_4, 10000));
197
198 __ nop();
199
200 __ rcl(edx, 1);
201 __ rcl(edx, 7);
Iain Merrick75681382010-08-19 15:07:18 +0100202 __ rcr(edx, 1);
203 __ rcr(edx, 7);
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400204 __ ror(edx, 1);
205 __ ror(edx, 6);
206 __ ror_cl(edx);
207 __ ror(Operand(ebx, ecx, times_4, 10000), 1);
208 __ ror(Operand(ebx, ecx, times_4, 10000), 6);
209 __ ror_cl(Operand(ebx, ecx, times_4, 10000));
Steve Blocka7e24c12009-10-30 11:49:00 +0000210 __ sar(edx, 1);
211 __ sar(edx, 6);
Steve Blockd0582a62009-12-15 09:54:21 +0000212 __ sar_cl(edx);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000213 __ sar(Operand(ebx, ecx, times_4, 10000), 1);
214 __ sar(Operand(ebx, ecx, times_4, 10000), 6);
215 __ sar_cl(Operand(ebx, ecx, times_4, 10000));
Steve Blocka7e24c12009-10-30 11:49:00 +0000216 __ sbb(edx, Operand(ebx, ecx, times_4, 10000));
217 __ shld(edx, Operand(ebx, ecx, times_4, 10000));
218 __ shl(edx, 1);
219 __ shl(edx, 6);
Steve Blockd0582a62009-12-15 09:54:21 +0000220 __ shl_cl(edx);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000221 __ shl(Operand(ebx, ecx, times_4, 10000), 1);
222 __ shl(Operand(ebx, ecx, times_4, 10000), 6);
223 __ shl_cl(Operand(ebx, ecx, times_4, 10000));
Steve Blocka7e24c12009-10-30 11:49:00 +0000224 __ shrd(edx, Operand(ebx, ecx, times_4, 10000));
Steve Blockd0582a62009-12-15 09:54:21 +0000225 __ shr(edx, 1);
Steve Blocka7e24c12009-10-30 11:49:00 +0000226 __ shr(edx, 7);
Steve Blockd0582a62009-12-15 09:54:21 +0000227 __ shr_cl(edx);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000228 __ shr(Operand(ebx, ecx, times_4, 10000), 1);
229 __ shr(Operand(ebx, ecx, times_4, 10000), 6);
230 __ shr_cl(Operand(ebx, ecx, times_4, 10000));
Steve Blocka7e24c12009-10-30 11:49:00 +0000231
232
233 // Immediates
234
235 __ adc(edx, 12345);
236
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100237 __ add(ebx, Immediate(12));
Steve Blocka7e24c12009-10-30 11:49:00 +0000238 __ add(Operand(edx, ecx, times_4, 10000), Immediate(12));
239
240 __ and_(ebx, 12345);
241
242 __ cmp(ebx, 12345);
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100243 __ cmp(ebx, Immediate(12));
Steve Blocka7e24c12009-10-30 11:49:00 +0000244 __ cmp(Operand(edx, ecx, times_4, 10000), Immediate(12));
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100245 __ cmpb(eax, 100);
Steve Blocka7e24c12009-10-30 11:49:00 +0000246
247 __ or_(ebx, 12345);
248
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100249 __ sub(ebx, Immediate(12));
Steve Blocka7e24c12009-10-30 11:49:00 +0000250 __ sub(Operand(edx, ecx, times_4, 10000), Immediate(12));
251
252 __ xor_(ebx, 12345);
253
254 __ imul(edx, ecx, 12);
255 __ imul(edx, ecx, 1000);
256
Steve Block6ded16b2010-05-10 14:33:55 +0100257 __ cld();
Leon Clarkee46be812010-01-19 14:06:41 +0000258 __ rep_movs();
Steve Block6ded16b2010-05-10 14:33:55 +0100259 __ rep_stos();
Leon Clarkef7060e22010-06-03 12:02:55 +0100260 __ stos();
Steve Blocka7e24c12009-10-30 11:49:00 +0000261
262 __ sub(edx, Operand(ebx, ecx, times_4, 10000));
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100263 __ sub(edx, ebx);
Steve Blocka7e24c12009-10-30 11:49:00 +0000264
265 __ test(edx, Immediate(12345));
266 __ test(edx, Operand(ebx, ecx, times_8, 10000));
Ben Murdoch7f4d5bd2010-06-15 11:15:29 +0100267 __ test(Operand(esi, edi, times_1, -20000000), Immediate(300000000));
268 __ test_b(edx, Operand(ecx, ebx, times_2, 1000));
269 __ test_b(Operand(eax, -20), 0x9A);
Steve Blocka7e24c12009-10-30 11:49:00 +0000270 __ nop();
271
272 __ xor_(edx, 12345);
273 __ xor_(edx, Operand(ebx, ecx, times_8, 10000));
274 __ bts(Operand(ebx, ecx, times_8, 10000), edx);
275 __ hlt();
276 __ int3();
277 __ ret(0);
278 __ ret(8);
279
280 // Calls
281
282 Label L1, L2;
283 __ bind(&L1);
284 __ nop();
285 __ call(&L1);
286 __ call(&L2);
287 __ nop();
288 __ bind(&L2);
289 __ call(Operand(ebx, ecx, times_4, 10000));
290 __ nop();
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000291 Handle<Code> ic(LoadIC::initialize_stub(isolate, NOT_INSIDE_TYPEOF));
Steve Blocka7e24c12009-10-30 11:49:00 +0000292 __ call(ic, RelocInfo::CODE_TARGET);
293 __ nop();
294 __ call(FUNCTION_ADDR(DummyStaticFunction), RelocInfo::RUNTIME_ENTRY);
295 __ nop();
296
297 __ jmp(&L1);
298 __ jmp(Operand(ebx, ecx, times_4, 10000));
299 ExternalReference after_break_target =
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000300 ExternalReference::debug_after_break_target_address(isolate);
Steve Blocka7e24c12009-10-30 11:49:00 +0000301 __ jmp(Operand::StaticVariable(after_break_target));
302 __ jmp(ic, RelocInfo::CODE_TARGET);
303 __ nop();
304
305
306 Label Ljcc;
307 __ nop();
308 // long jumps
309 __ j(overflow, &Ljcc);
310 __ j(no_overflow, &Ljcc);
311 __ j(below, &Ljcc);
312 __ j(above_equal, &Ljcc);
313 __ j(equal, &Ljcc);
314 __ j(not_equal, &Ljcc);
315 __ j(below_equal, &Ljcc);
316 __ j(above, &Ljcc);
317 __ j(sign, &Ljcc);
318 __ j(not_sign, &Ljcc);
319 __ j(parity_even, &Ljcc);
320 __ j(parity_odd, &Ljcc);
321 __ j(less, &Ljcc);
322 __ j(greater_equal, &Ljcc);
323 __ j(less_equal, &Ljcc);
324 __ j(greater, &Ljcc);
325 __ nop();
326 __ bind(&Ljcc);
327 // short jumps
328 __ j(overflow, &Ljcc);
329 __ j(no_overflow, &Ljcc);
330 __ j(below, &Ljcc);
331 __ j(above_equal, &Ljcc);
332 __ j(equal, &Ljcc);
333 __ j(not_equal, &Ljcc);
334 __ j(below_equal, &Ljcc);
335 __ j(above, &Ljcc);
336 __ j(sign, &Ljcc);
337 __ j(not_sign, &Ljcc);
338 __ j(parity_even, &Ljcc);
339 __ j(parity_odd, &Ljcc);
340 __ j(less, &Ljcc);
341 __ j(greater_equal, &Ljcc);
342 __ j(less_equal, &Ljcc);
343 __ j(greater, &Ljcc);
344
Steve Blocka7e24c12009-10-30 11:49:00 +0000345 // 0xD9 instructions
346 __ nop();
347
Kristian Monsen0d5e1162010-09-30 15:31:59 +0100348 __ fld(1);
Steve Blocka7e24c12009-10-30 11:49:00 +0000349 __ fld1();
350 __ fldz();
Kristian Monsen0d5e1162010-09-30 15:31:59 +0100351 __ fldpi();
Steve Blocka7e24c12009-10-30 11:49:00 +0000352 __ fabs();
353 __ fchs();
354 __ fprem();
355 __ fprem1();
356 __ fincstp();
357 __ ftst();
358 __ fxch(3);
359 __ fld_s(Operand(ebx, ecx, times_4, 10000));
360 __ fstp_s(Operand(ebx, ecx, times_4, 10000));
361 __ ffree(3);
362 __ fld_d(Operand(ebx, ecx, times_4, 10000));
363 __ fstp_d(Operand(ebx, ecx, times_4, 10000));
364 __ nop();
365
366 __ fild_s(Operand(ebx, ecx, times_4, 10000));
367 __ fistp_s(Operand(ebx, ecx, times_4, 10000));
368 __ fild_d(Operand(ebx, ecx, times_4, 10000));
369 __ fistp_d(Operand(ebx, ecx, times_4, 10000));
370 __ fnstsw_ax();
371 __ nop();
372 __ fadd(3);
373 __ fsub(3);
374 __ fmul(3);
375 __ fdiv(3);
376
377 __ faddp(3);
378 __ fsubp(3);
379 __ fmulp(3);
380 __ fdivp(3);
381 __ fcompp();
382 __ fwait();
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000383 __ frndint();
384 __ fninit();
Steve Blocka7e24c12009-10-30 11:49:00 +0000385 __ nop();
Leon Clarkee46be812010-01-19 14:06:41 +0000386
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000387 // SSE instruction
388 {
389 // Move operation
390 __ movaps(xmm0, xmm1);
391 __ shufps(xmm0, xmm0, 0x0);
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400392 __ cvtsd2ss(xmm0, xmm1);
393 __ cvtsd2ss(xmm0, Operand(ebx, ecx, times_4, 10000));
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000394
395 // logic operation
396 __ andps(xmm0, xmm1);
397 __ andps(xmm0, Operand(ebx, ecx, times_4, 10000));
398 __ orps(xmm0, xmm1);
399 __ orps(xmm0, Operand(ebx, ecx, times_4, 10000));
400 __ xorps(xmm0, xmm1);
401 __ xorps(xmm0, Operand(ebx, ecx, times_4, 10000));
402
403 // Arithmetic operation
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400404 __ addss(xmm1, xmm0);
405 __ addss(xmm1, Operand(ebx, ecx, times_4, 10000));
406 __ mulss(xmm1, xmm0);
407 __ mulss(xmm1, Operand(ebx, ecx, times_4, 10000));
408 __ subss(xmm1, xmm0);
409 __ subss(xmm1, Operand(ebx, ecx, times_4, 10000));
410 __ divss(xmm1, xmm0);
411 __ divss(xmm1, Operand(ebx, ecx, times_4, 10000));
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000412 __ maxss(xmm1, xmm0);
413 __ maxss(xmm1, Operand(ebx, ecx, times_4, 10000));
414 __ minss(xmm1, xmm0);
415 __ minss(xmm1, Operand(ebx, ecx, times_4, 10000));
416 __ sqrtss(xmm1, xmm0);
417 __ sqrtss(xmm1, Operand(ebx, ecx, times_4, 10000));
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000418 __ addps(xmm1, xmm0);
419 __ addps(xmm1, Operand(ebx, ecx, times_4, 10000));
420 __ subps(xmm1, xmm0);
421 __ subps(xmm1, Operand(ebx, ecx, times_4, 10000));
422 __ mulps(xmm1, xmm0);
423 __ mulps(xmm1, Operand(ebx, ecx, times_4, 10000));
424 __ divps(xmm1, xmm0);
425 __ divps(xmm1, Operand(ebx, ecx, times_4, 10000));
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400426
427 __ ucomiss(xmm0, xmm1);
428 __ ucomiss(xmm0, Operand(ebx, ecx, times_4, 10000));
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000429 }
430 {
431 __ cvttss2si(edx, Operand(ebx, ecx, times_4, 10000));
432 __ cvtsi2sd(xmm1, Operand(ebx, ecx, times_4, 10000));
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400433 __ cvtss2sd(xmm1, Operand(ebx, ecx, times_4, 10000));
434 __ cvtss2sd(xmm1, xmm0);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000435 __ movsd(xmm1, Operand(ebx, ecx, times_4, 10000));
436 __ movsd(Operand(ebx, ecx, times_4, 10000), xmm1);
437 // 128 bit move instructions.
438 __ movdqa(xmm0, Operand(ebx, ecx, times_4, 10000));
439 __ movdqa(Operand(ebx, ecx, times_4, 10000), xmm0);
440 __ movdqu(xmm0, Operand(ebx, ecx, times_4, 10000));
441 __ movdqu(Operand(ebx, ecx, times_4, 10000), xmm0);
442
443 __ addsd(xmm1, xmm0);
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400444 __ addsd(xmm1, Operand(ebx, ecx, times_4, 10000));
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000445 __ mulsd(xmm1, xmm0);
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400446 __ mulsd(xmm1, Operand(ebx, ecx, times_4, 10000));
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000447 __ subsd(xmm1, xmm0);
448 __ subsd(xmm1, Operand(ebx, ecx, times_4, 10000));
449 __ divsd(xmm1, xmm0);
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400450 __ divsd(xmm1, Operand(ebx, ecx, times_4, 10000));
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000451 __ minsd(xmm1, xmm0);
452 __ minsd(xmm1, Operand(ebx, ecx, times_4, 10000));
453 __ maxsd(xmm1, xmm0);
454 __ maxsd(xmm1, Operand(ebx, ecx, times_4, 10000));
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000455 __ ucomisd(xmm0, xmm1);
456 __ cmpltsd(xmm0, xmm1);
457
458 __ andpd(xmm0, xmm1);
459 __ psllq(xmm0, 17);
460 __ psllq(xmm0, xmm1);
461 __ psrlq(xmm0, 17);
462 __ psrlq(xmm0, xmm1);
463 __ por(xmm0, xmm1);
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000464
465 __ pcmpeqd(xmm1, xmm0);
466
467 __ punpckldq(xmm1, xmm6);
468 __ punpckhdq(xmm7, xmm5);
Steve Blocka7e24c12009-10-30 11:49:00 +0000469 }
Steve Block3ce2e202009-11-05 08:53:23 +0000470
471 // cmov.
472 {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000473 __ cmov(overflow, eax, Operand(eax, 0));
474 __ cmov(no_overflow, eax, Operand(eax, 1));
475 __ cmov(below, eax, Operand(eax, 2));
476 __ cmov(above_equal, eax, Operand(eax, 3));
477 __ cmov(equal, eax, Operand(ebx, 0));
478 __ cmov(not_equal, eax, Operand(ebx, 1));
479 __ cmov(below_equal, eax, Operand(ebx, 2));
480 __ cmov(above, eax, Operand(ebx, 3));
481 __ cmov(sign, eax, Operand(ecx, 0));
482 __ cmov(not_sign, eax, Operand(ecx, 1));
483 __ cmov(parity_even, eax, Operand(ecx, 2));
484 __ cmov(parity_odd, eax, Operand(ecx, 3));
485 __ cmov(less, eax, Operand(edx, 0));
486 __ cmov(greater_equal, eax, Operand(edx, 1));
487 __ cmov(less_equal, eax, Operand(edx, 2));
488 __ cmov(greater, eax, Operand(edx, 3));
Kristian Monsen0d5e1162010-09-30 15:31:59 +0100489 }
490
Steve Block1e0659c2011-05-24 12:43:12 +0100491 {
Ben Murdoch8b112d22011-06-08 16:22:53 +0100492 if (CpuFeatures::IsSupported(SSE4_1)) {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000493 CpuFeatureScope scope(&assm, SSE4_1);
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100494 __ pextrd(eax, xmm0, 1);
495 __ pinsrd(xmm1, eax, 0);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000496 __ extractps(eax, xmm1, 0);
Steve Block1e0659c2011-05-24 12:43:12 +0100497 }
498 }
499
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400500 // AVX instruction
501 {
502 if (CpuFeatures::IsSupported(AVX)) {
503 CpuFeatureScope scope(&assm, AVX);
504 __ vaddsd(xmm0, xmm1, xmm2);
505 __ vaddsd(xmm0, xmm1, Operand(ebx, ecx, times_4, 10000));
506 __ vmulsd(xmm0, xmm1, xmm2);
507 __ vmulsd(xmm0, xmm1, Operand(ebx, ecx, times_4, 10000));
508 __ vsubsd(xmm0, xmm1, xmm2);
509 __ vsubsd(xmm0, xmm1, Operand(ebx, ecx, times_4, 10000));
510 __ vdivsd(xmm0, xmm1, xmm2);
511 __ vdivsd(xmm0, xmm1, Operand(ebx, ecx, times_4, 10000));
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000512 __ vminsd(xmm0, xmm1, xmm2);
513 __ vminsd(xmm0, xmm1, Operand(ebx, ecx, times_4, 10000));
514 __ vmaxsd(xmm0, xmm1, xmm2);
515 __ vmaxsd(xmm0, xmm1, Operand(ebx, ecx, times_4, 10000));
516
517 __ vaddss(xmm0, xmm1, xmm2);
518 __ vaddss(xmm0, xmm1, Operand(ebx, ecx, times_4, 10000));
519 __ vmulss(xmm0, xmm1, xmm2);
520 __ vmulss(xmm0, xmm1, Operand(ebx, ecx, times_4, 10000));
521 __ vsubss(xmm0, xmm1, xmm2);
522 __ vsubss(xmm0, xmm1, Operand(ebx, ecx, times_4, 10000));
523 __ vdivss(xmm0, xmm1, xmm2);
524 __ vdivss(xmm0, xmm1, Operand(ebx, ecx, times_4, 10000));
525 __ vminss(xmm0, xmm1, xmm2);
526 __ vminss(xmm0, xmm1, Operand(ebx, ecx, times_4, 10000));
527 __ vmaxss(xmm0, xmm1, xmm2);
528 __ vmaxss(xmm0, xmm1, Operand(ebx, ecx, times_4, 10000));
529
530 __ vandps(xmm0, xmm1, xmm2);
531 __ vandps(xmm0, xmm1, Operand(ebx, ecx, times_4, 10000));
532 __ vxorps(xmm0, xmm1, xmm2);
533 __ vxorps(xmm0, xmm1, Operand(ebx, ecx, times_4, 10000));
534
535 __ vandpd(xmm0, xmm1, xmm2);
536 __ vandpd(xmm0, xmm1, Operand(ebx, ecx, times_4, 10000));
537 __ vxorpd(xmm0, xmm1, xmm2);
538 __ vxorpd(xmm0, xmm1, Operand(ebx, ecx, times_4, 10000));
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400539 }
540 }
541
542 // FMA3 instruction
543 {
544 if (CpuFeatures::IsSupported(FMA3)) {
545 CpuFeatureScope scope(&assm, FMA3);
546 __ vfmadd132sd(xmm0, xmm1, xmm2);
547 __ vfmadd132sd(xmm0, xmm1, Operand(ebx, ecx, times_4, 10000));
548 __ vfmadd213sd(xmm0, xmm1, xmm2);
549 __ vfmadd213sd(xmm0, xmm1, Operand(ebx, ecx, times_4, 10000));
550 __ vfmadd231sd(xmm0, xmm1, xmm2);
551 __ vfmadd231sd(xmm0, xmm1, Operand(ebx, ecx, times_4, 10000));
552
553 __ vfmsub132sd(xmm0, xmm1, xmm2);
554 __ vfmsub132sd(xmm0, xmm1, Operand(ebx, ecx, times_4, 10000));
555 __ vfmsub213sd(xmm0, xmm1, xmm2);
556 __ vfmsub213sd(xmm0, xmm1, Operand(ebx, ecx, times_4, 10000));
557 __ vfmsub231sd(xmm0, xmm1, xmm2);
558 __ vfmsub231sd(xmm0, xmm1, Operand(ebx, ecx, times_4, 10000));
559
560 __ vfnmadd132sd(xmm0, xmm1, xmm2);
561 __ vfnmadd132sd(xmm0, xmm1, Operand(ebx, ecx, times_4, 10000));
562 __ vfnmadd213sd(xmm0, xmm1, xmm2);
563 __ vfnmadd213sd(xmm0, xmm1, Operand(ebx, ecx, times_4, 10000));
564 __ vfnmadd231sd(xmm0, xmm1, xmm2);
565 __ vfnmadd231sd(xmm0, xmm1, Operand(ebx, ecx, times_4, 10000));
566
567 __ vfnmsub132sd(xmm0, xmm1, xmm2);
568 __ vfnmsub132sd(xmm0, xmm1, Operand(ebx, ecx, times_4, 10000));
569 __ vfnmsub213sd(xmm0, xmm1, xmm2);
570 __ vfnmsub213sd(xmm0, xmm1, Operand(ebx, ecx, times_4, 10000));
571 __ vfnmsub231sd(xmm0, xmm1, xmm2);
572 __ vfnmsub231sd(xmm0, xmm1, Operand(ebx, ecx, times_4, 10000));
573
574 __ vfmadd132ss(xmm0, xmm1, xmm2);
575 __ vfmadd132ss(xmm0, xmm1, Operand(ebx, ecx, times_4, 10000));
576 __ vfmadd213ss(xmm0, xmm1, xmm2);
577 __ vfmadd213ss(xmm0, xmm1, Operand(ebx, ecx, times_4, 10000));
578 __ vfmadd231ss(xmm0, xmm1, xmm2);
579 __ vfmadd231ss(xmm0, xmm1, Operand(ebx, ecx, times_4, 10000));
580
581 __ vfmsub132ss(xmm0, xmm1, xmm2);
582 __ vfmsub132ss(xmm0, xmm1, Operand(ebx, ecx, times_4, 10000));
583 __ vfmsub213ss(xmm0, xmm1, xmm2);
584 __ vfmsub213ss(xmm0, xmm1, Operand(ebx, ecx, times_4, 10000));
585 __ vfmsub231ss(xmm0, xmm1, xmm2);
586 __ vfmsub231ss(xmm0, xmm1, Operand(ebx, ecx, times_4, 10000));
587
588 __ vfnmadd132ss(xmm0, xmm1, xmm2);
589 __ vfnmadd132ss(xmm0, xmm1, Operand(ebx, ecx, times_4, 10000));
590 __ vfnmadd213ss(xmm0, xmm1, xmm2);
591 __ vfnmadd213ss(xmm0, xmm1, Operand(ebx, ecx, times_4, 10000));
592 __ vfnmadd231ss(xmm0, xmm1, xmm2);
593 __ vfnmadd231ss(xmm0, xmm1, Operand(ebx, ecx, times_4, 10000));
594
595 __ vfnmsub132ss(xmm0, xmm1, xmm2);
596 __ vfnmsub132ss(xmm0, xmm1, Operand(ebx, ecx, times_4, 10000));
597 __ vfnmsub213ss(xmm0, xmm1, xmm2);
598 __ vfnmsub213ss(xmm0, xmm1, Operand(ebx, ecx, times_4, 10000));
599 __ vfnmsub231ss(xmm0, xmm1, xmm2);
600 __ vfnmsub231ss(xmm0, xmm1, Operand(ebx, ecx, times_4, 10000));
601 }
602 }
603
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000604 // BMI1 instructions
605 {
606 if (CpuFeatures::IsSupported(BMI1)) {
607 CpuFeatureScope scope(&assm, BMI1);
608 __ andn(eax, ebx, ecx);
609 __ andn(eax, ebx, Operand(ebx, ecx, times_4, 10000));
610 __ bextr(eax, ebx, ecx);
611 __ bextr(eax, Operand(ebx, ecx, times_4, 10000), ebx);
612 __ blsi(eax, ebx);
613 __ blsi(eax, Operand(ebx, ecx, times_4, 10000));
614 __ blsmsk(eax, ebx);
615 __ blsmsk(eax, Operand(ebx, ecx, times_4, 10000));
616 __ blsr(eax, ebx);
617 __ blsr(eax, Operand(ebx, ecx, times_4, 10000));
618 __ tzcnt(eax, ebx);
619 __ tzcnt(eax, Operand(ebx, ecx, times_4, 10000));
620 }
621 }
622
623 // LZCNT instructions
624 {
625 if (CpuFeatures::IsSupported(LZCNT)) {
626 CpuFeatureScope scope(&assm, LZCNT);
627 __ lzcnt(eax, ebx);
628 __ lzcnt(eax, Operand(ebx, ecx, times_4, 10000));
629 }
630 }
631
632 // POPCNT instructions
633 {
634 if (CpuFeatures::IsSupported(POPCNT)) {
635 CpuFeatureScope scope(&assm, POPCNT);
636 __ popcnt(eax, ebx);
637 __ popcnt(eax, Operand(ebx, ecx, times_4, 10000));
638 }
639 }
640
641 // BMI2 instructions
642 {
643 if (CpuFeatures::IsSupported(BMI2)) {
644 CpuFeatureScope scope(&assm, BMI2);
645 __ bzhi(eax, ebx, ecx);
646 __ bzhi(eax, Operand(ebx, ecx, times_4, 10000), ebx);
647 __ mulx(eax, ebx, ecx);
648 __ mulx(eax, ebx, Operand(ebx, ecx, times_4, 10000));
649 __ pdep(eax, ebx, ecx);
650 __ pdep(eax, ebx, Operand(ebx, ecx, times_4, 10000));
651 __ pext(eax, ebx, ecx);
652 __ pext(eax, ebx, Operand(ebx, ecx, times_4, 10000));
653 __ sarx(eax, ebx, ecx);
654 __ sarx(eax, Operand(ebx, ecx, times_4, 10000), ebx);
655 __ shlx(eax, ebx, ecx);
656 __ shlx(eax, Operand(ebx, ecx, times_4, 10000), ebx);
657 __ shrx(eax, ebx, ecx);
658 __ shrx(eax, Operand(ebx, ecx, times_4, 10000), ebx);
659 __ rorx(eax, ebx, 31);
660 __ rorx(eax, Operand(ebx, ecx, times_4, 10000), 31);
661 }
662 }
663
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000664 // xchg.
665 {
666 __ xchg(eax, eax);
667 __ xchg(eax, ebx);
668 __ xchg(ebx, ebx);
669 __ xchg(ebx, Operand(esp, 12));
670 }
671
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100672 // Nop instructions
673 for (int i = 0; i < 16; i++) {
674 __ Nop(i);
675 }
676
Steve Blocka7e24c12009-10-30 11:49:00 +0000677 __ ret(0);
678
679 CodeDesc desc;
680 assm.GetCode(&desc);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000681 Handle<Code> code = isolate->factory()->NewCode(
682 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
683 USE(code);
Steve Block9fac8402011-05-12 15:51:54 +0100684#ifdef OBJECT_PRINT
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000685 OFStream os(stdout);
686 code->Print(os);
687 byte* begin = code->instruction_start();
688 byte* end = begin + code->instruction_size();
Steve Blocka7e24c12009-10-30 11:49:00 +0000689 disasm::Disassembler::Disassemble(stdout, begin, end);
690#endif
691}
692
693#undef __