blob: 8240a9546d22b2eff4ddd392004bbb541d81034b [file] [log] [blame]
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +00001// Copyright 2011 the V8 project authors. All rights reserved.
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +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
30#include "v8.h"
31
32#include "debug.h"
33#include "disasm.h"
34#include "disassembler.h"
35#include "macro-assembler.h"
36#include "serialize.h"
37#include "cctest.h"
38
39using namespace v8::internal;
40
41static v8::Persistent<v8::Context> env;
42
43static void InitializeVM() {
44 if (env.IsEmpty()) {
45 env = v8::Context::New();
46 }
47}
48
49
50#define __ assm.
51
52
53static void DummyStaticFunction(Object* result) {
54}
55
56
57TEST(DisasmIa320) {
58 InitializeVM();
svenpanne@chromium.org2bda5432013-03-15 12:39:50 +000059 Isolate* isolate = reinterpret_cast<Isolate*>(env->GetIsolate());
60 HandleScope scope(isolate);
fschneider@chromium.org0c20e672010-01-14 15:28:53 +000061 v8::internal::byte buffer[2048];
svenpanne@chromium.org2bda5432013-03-15 12:39:50 +000062 Assembler assm(isolate, buffer, sizeof buffer);
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +000063 DummyStaticFunction(NULL); // just bloody use it (DELETE; debugging)
64
65 // Short immediate instructions
66 __ adc(eax, 12345678);
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +000067 __ add(eax, Immediate(12345678));
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +000068 __ or_(eax, 12345678);
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +000069 __ sub(eax, Immediate(12345678));
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +000070 __ xor_(eax, 12345678);
71 __ and_(eax, 12345678);
sgjesse@chromium.orgea88ce92011-03-23 11:19:56 +000072 Handle<FixedArray> foo = FACTORY->NewFixedArray(10, TENURED);
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +000073 __ cmp(eax, foo);
74
75 // ---- This one caused crash
76 __ mov(ebx, Operand(esp, ecx, times_2, 0)); // [esp+ecx*4]
77
78 // ---- All instructions that I can think of
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +000079 __ add(edx, ebx);
jkummerow@chromium.org59297c72013-01-09 16:32:23 +000080 __ add(edx, Operand(12, RelocInfo::NONE32));
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +000081 __ add(edx, Operand(ebx, 0));
82 __ add(edx, Operand(ebx, 16));
83 __ add(edx, Operand(ebx, 1999));
84 __ add(edx, Operand(esp, 0));
85 __ add(edx, Operand(esp, 16));
86 __ add(edx, Operand(esp, 1999));
87 __ nop();
88 __ add(edi, Operand(ebp, ecx, times_4, 0));
89 __ add(edi, Operand(ebp, ecx, times_4, 12));
90 __ add(Operand(ebp, ecx, times_4, 12), Immediate(12));
91
92 __ nop();
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +000093 __ add(ebx, Immediate(12));
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +000094 __ nop();
95 __ adc(ecx, 12);
96 __ adc(ecx, 1000);
97 __ nop();
98 __ and_(edx, 3);
99 __ and_(edx, Operand(esp, 4));
100 __ cmp(edx, 3);
101 __ cmp(edx, Operand(esp, 4));
102 __ cmp(Operand(ebp, ecx, times_4, 0), Immediate(1000));
sgjesse@chromium.orgea88ce92011-03-23 11:19:56 +0000103 Handle<FixedArray> foo2 = FACTORY->NewFixedArray(10, TENURED);
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000104 __ cmp(ebx, foo2);
sgjesse@chromium.orgb302e562010-02-03 11:26:59 +0000105 __ cmpb(ebx, Operand(ebp, ecx, times_2, 0));
106 __ cmpb(Operand(ebp, ecx, times_2, 0), ebx);
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000107 __ or_(edx, 3);
108 __ xor_(edx, 3);
109 __ nop();
110 {
kmillikin@chromium.orgc36ce6e2011-04-04 08:25:31 +0000111 CHECK(CpuFeatures::IsSupported(CPUID));
ulan@chromium.org750145a2013-03-07 15:14:13 +0000112 CpuFeatureScope fscope(&assm, CPUID);
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000113 __ cpuid();
114 }
115 {
kmillikin@chromium.orgc36ce6e2011-04-04 08:25:31 +0000116 CHECK(CpuFeatures::IsSupported(RDTSC));
ulan@chromium.org750145a2013-03-07 15:14:13 +0000117 CpuFeatureScope fscope(&assm, RDTSC);
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000118 __ rdtsc();
119 }
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000120 __ movsx_b(edx, ecx);
121 __ movsx_w(edx, ecx);
122 __ movzx_b(edx, ecx);
123 __ movzx_w(edx, ecx);
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000124
125 __ nop();
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000126 __ imul(edx, ecx);
127 __ shld(edx, ecx);
128 __ shrd(edx, ecx);
129 __ bts(edx, ecx);
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000130 __ bts(Operand(ebx, ecx, times_4, 0), ecx);
131 __ nop();
132 __ pushad();
133 __ popad();
134 __ pushfd();
135 __ popfd();
136 __ push(Immediate(12));
137 __ push(Immediate(23456));
138 __ push(ecx);
139 __ push(esi);
140 __ push(Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
141 __ push(Operand(ebx, ecx, times_4, 0));
142 __ push(Operand(ebx, ecx, times_4, 0));
143 __ push(Operand(ebx, ecx, times_4, 10000));
144 __ pop(edx);
145 __ pop(eax);
146 __ pop(Operand(ebx, ecx, times_4, 0));
147 __ nop();
148
149 __ add(edx, Operand(esp, 16));
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000150 __ add(edx, ecx);
151 __ mov_b(edx, ecx);
152 __ mov_b(ecx, 6);
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000153 __ mov_b(Operand(ebx, ecx, times_4, 10000), 6);
154 __ mov_b(Operand(esp, 16), edx);
155 __ mov_w(edx, Operand(esp, 16));
156 __ mov_w(Operand(esp, 16), edx);
157 __ nop();
158 __ movsx_w(edx, Operand(esp, 12));
159 __ movsx_b(edx, Operand(esp, 12));
160 __ movzx_w(edx, Operand(esp, 12));
161 __ movzx_b(edx, Operand(esp, 12));
162 __ nop();
163 __ mov(edx, 1234567);
164 __ mov(edx, Operand(esp, 12));
165 __ mov(Operand(ebx, ecx, times_4, 10000), Immediate(12345));
166 __ mov(Operand(ebx, ecx, times_4, 10000), edx);
167 __ nop();
168 __ dec_b(edx);
whesse@chromium.org4a1fe7d2010-09-27 12:32:04 +0000169 __ dec_b(Operand(eax, 10));
170 __ dec_b(Operand(ebx, ecx, times_4, 10000));
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000171 __ dec(edx);
172 __ cdq();
173
174 __ nop();
175 __ idiv(edx);
176 __ 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);
183 __ imul(edx, ecx, 1000);
184
185 __ inc(edx);
186 __ inc(Operand(ebx, ecx, times_4, 10000));
187 __ push(Operand(ebx, ecx, times_4, 10000));
188 __ pop(Operand(ebx, ecx, times_4, 10000));
189 __ call(Operand(ebx, ecx, times_4, 10000));
190 __ jmp(Operand(ebx, ecx, times_4, 10000));
191
192 __ lea(edx, Operand(ebx, ecx, times_4, 10000));
193 __ or_(edx, 12345);
194 __ or_(edx, Operand(ebx, ecx, times_4, 10000));
195
196 __ nop();
197
198 __ rcl(edx, 1);
199 __ rcl(edx, 7);
ager@chromium.orgea4f62e2010-08-16 16:28:43 +0000200 __ rcr(edx, 1);
201 __ rcr(edx, 7);
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000202 __ sar(edx, 1);
203 __ sar(edx, 6);
ager@chromium.orgc4c92722009-11-18 14:12:51 +0000204 __ sar_cl(edx);
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000205 __ sbb(edx, Operand(ebx, ecx, times_4, 10000));
206 __ shld(edx, Operand(ebx, ecx, times_4, 10000));
207 __ shl(edx, 1);
208 __ shl(edx, 6);
ager@chromium.orgc4c92722009-11-18 14:12:51 +0000209 __ shl_cl(edx);
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000210 __ shrd(edx, Operand(ebx, ecx, times_4, 10000));
ager@chromium.orgc4c92722009-11-18 14:12:51 +0000211 __ shr(edx, 1);
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000212 __ shr(edx, 7);
ager@chromium.orgc4c92722009-11-18 14:12:51 +0000213 __ shr_cl(edx);
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000214
215
216 // Immediates
217
218 __ adc(edx, 12345);
219
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000220 __ add(ebx, Immediate(12));
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000221 __ add(Operand(edx, ecx, times_4, 10000), Immediate(12));
222
223 __ and_(ebx, 12345);
224
225 __ cmp(ebx, 12345);
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000226 __ cmp(ebx, Immediate(12));
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000227 __ cmp(Operand(edx, ecx, times_4, 10000), Immediate(12));
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000228 __ cmpb(eax, 100);
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000229
230 __ or_(ebx, 12345);
231
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000232 __ sub(ebx, Immediate(12));
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000233 __ sub(Operand(edx, ecx, times_4, 10000), Immediate(12));
234
235 __ xor_(ebx, 12345);
236
237 __ imul(edx, ecx, 12);
238 __ imul(edx, ecx, 1000);
239
ager@chromium.orgce5e87b2010-03-10 10:24:18 +0000240 __ cld();
fschneider@chromium.org0c20e672010-01-14 15:28:53 +0000241 __ rep_movs();
ager@chromium.orgce5e87b2010-03-10 10:24:18 +0000242 __ rep_stos();
erik.corry@gmail.com9dfbea42010-05-21 12:58:28 +0000243 __ stos();
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000244
245 __ sub(edx, Operand(ebx, ecx, times_4, 10000));
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000246 __ sub(edx, ebx);
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000247
248 __ test(edx, Immediate(12345));
249 __ test(edx, Operand(ebx, ecx, times_8, 10000));
vegorov@chromium.org2356e6f2010-06-09 09:38:56 +0000250 __ test(Operand(esi, edi, times_1, -20000000), Immediate(300000000));
251 __ test_b(edx, Operand(ecx, ebx, times_2, 1000));
252 __ test_b(Operand(eax, -20), 0x9A);
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000253 __ nop();
254
255 __ xor_(edx, 12345);
256 __ xor_(edx, Operand(ebx, ecx, times_8, 10000));
257 __ bts(Operand(ebx, ecx, times_8, 10000), edx);
258 __ hlt();
259 __ int3();
260 __ ret(0);
261 __ ret(8);
262
263 // Calls
264
265 Label L1, L2;
266 __ bind(&L1);
267 __ nop();
268 __ call(&L1);
269 __ call(&L2);
270 __ nop();
271 __ bind(&L2);
272 __ call(Operand(ebx, ecx, times_4, 10000));
273 __ nop();
svenpanne@chromium.org2bda5432013-03-15 12:39:50 +0000274 Handle<Code> ic(isolate->builtins()->builtin(Builtins::kLoadIC_Initialize));
ager@chromium.org236ad962008-09-25 09:45:57 +0000275 __ call(ic, RelocInfo::CODE_TARGET);
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000276 __ nop();
ager@chromium.org236ad962008-09-25 09:45:57 +0000277 __ call(FUNCTION_ADDR(DummyStaticFunction), RelocInfo::RUNTIME_ENTRY);
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000278 __ nop();
279
280 __ jmp(&L1);
281 __ jmp(Operand(ebx, ecx, times_4, 10000));
ricow@chromium.org5ad5ace2010-06-23 09:06:43 +0000282#ifdef ENABLE_DEBUGGER_SUPPORT
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000283 ExternalReference after_break_target =
svenpanne@chromium.org2bda5432013-03-15 12:39:50 +0000284 ExternalReference(Debug_Address::AfterBreakTarget(), isolate);
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000285 __ jmp(Operand::StaticVariable(after_break_target));
ricow@chromium.org5ad5ace2010-06-23 09:06:43 +0000286#endif // ENABLE_DEBUGGER_SUPPORT
ager@chromium.org236ad962008-09-25 09:45:57 +0000287 __ jmp(ic, RelocInfo::CODE_TARGET);
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000288 __ nop();
289
290
291 Label Ljcc;
292 __ nop();
293 // long jumps
294 __ j(overflow, &Ljcc);
295 __ j(no_overflow, &Ljcc);
296 __ j(below, &Ljcc);
297 __ j(above_equal, &Ljcc);
298 __ j(equal, &Ljcc);
299 __ j(not_equal, &Ljcc);
300 __ j(below_equal, &Ljcc);
301 __ j(above, &Ljcc);
302 __ j(sign, &Ljcc);
303 __ j(not_sign, &Ljcc);
304 __ j(parity_even, &Ljcc);
305 __ j(parity_odd, &Ljcc);
306 __ j(less, &Ljcc);
307 __ j(greater_equal, &Ljcc);
308 __ j(less_equal, &Ljcc);
309 __ j(greater, &Ljcc);
310 __ nop();
311 __ bind(&Ljcc);
312 // short jumps
313 __ j(overflow, &Ljcc);
314 __ j(no_overflow, &Ljcc);
315 __ j(below, &Ljcc);
316 __ j(above_equal, &Ljcc);
317 __ j(equal, &Ljcc);
318 __ j(not_equal, &Ljcc);
319 __ j(below_equal, &Ljcc);
320 __ j(above, &Ljcc);
321 __ j(sign, &Ljcc);
322 __ j(not_sign, &Ljcc);
323 __ j(parity_even, &Ljcc);
324 __ j(parity_odd, &Ljcc);
325 __ j(less, &Ljcc);
326 __ j(greater_equal, &Ljcc);
327 __ j(less_equal, &Ljcc);
328 __ j(greater, &Ljcc);
329
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000330 // 0xD9 instructions
331 __ nop();
332
whesse@chromium.org4a1fe7d2010-09-27 12:32:04 +0000333 __ fld(1);
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000334 __ fld1();
335 __ fldz();
whesse@chromium.org4a1fe7d2010-09-27 12:32:04 +0000336 __ fldpi();
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000337 __ fabs();
338 __ fchs();
339 __ fprem();
340 __ fprem1();
341 __ fincstp();
342 __ ftst();
343 __ fxch(3);
344 __ fld_s(Operand(ebx, ecx, times_4, 10000));
345 __ fstp_s(Operand(ebx, ecx, times_4, 10000));
346 __ ffree(3);
347 __ fld_d(Operand(ebx, ecx, times_4, 10000));
348 __ fstp_d(Operand(ebx, ecx, times_4, 10000));
349 __ nop();
350
351 __ fild_s(Operand(ebx, ecx, times_4, 10000));
352 __ fistp_s(Operand(ebx, ecx, times_4, 10000));
353 __ fild_d(Operand(ebx, ecx, times_4, 10000));
354 __ fistp_d(Operand(ebx, ecx, times_4, 10000));
355 __ fnstsw_ax();
356 __ nop();
357 __ fadd(3);
358 __ fsub(3);
359 __ fmul(3);
360 __ fdiv(3);
361
362 __ faddp(3);
363 __ fsubp(3);
364 __ fmulp(3);
365 __ fdivp(3);
366 __ fcompp();
367 __ fwait();
368 __ nop();
369 {
kmillikin@chromium.orgc36ce6e2011-04-04 08:25:31 +0000370 if (CpuFeatures::IsSupported(SSE2)) {
ulan@chromium.org750145a2013-03-07 15:14:13 +0000371 CpuFeatureScope fscope(&assm, SSE2);
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000372 __ cvttss2si(edx, Operand(ebx, ecx, times_4, 10000));
373 __ cvtsi2sd(xmm1, Operand(ebx, ecx, times_4, 10000));
374 __ addsd(xmm1, xmm0);
375 __ mulsd(xmm1, xmm0);
376 __ subsd(xmm1, xmm0);
377 __ divsd(xmm1, xmm0);
378 __ movdbl(xmm1, Operand(ebx, ecx, times_4, 10000));
379 __ movdbl(Operand(ebx, ecx, times_4, 10000), xmm1);
ricow@chromium.org5ad5ace2010-06-23 09:06:43 +0000380 __ ucomisd(xmm0, xmm1);
fschneider@chromium.org0c20e672010-01-14 15:28:53 +0000381
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000382 // 128 bit move instructions.
383 __ movdqa(xmm0, Operand(ebx, ecx, times_4, 10000));
384 __ movdqa(Operand(ebx, ecx, times_4, 10000), xmm0);
385 __ movdqu(xmm0, Operand(ebx, ecx, times_4, 10000));
386 __ movdqu(Operand(ebx, ecx, times_4, 10000), xmm0);
387 }
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000388 }
christian.plesner.hansen@gmail.com9d58c2b2009-10-16 11:48:38 +0000389
390 // cmov.
391 {
kmillikin@chromium.orgc36ce6e2011-04-04 08:25:31 +0000392 if (CpuFeatures::IsSupported(CMOV)) {
ulan@chromium.org750145a2013-03-07 15:14:13 +0000393 CpuFeatureScope use_cmov(&assm, CMOV);
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000394 __ cmov(overflow, eax, Operand(eax, 0));
395 __ cmov(no_overflow, eax, Operand(eax, 1));
396 __ cmov(below, eax, Operand(eax, 2));
397 __ cmov(above_equal, eax, Operand(eax, 3));
398 __ cmov(equal, eax, Operand(ebx, 0));
399 __ cmov(not_equal, eax, Operand(ebx, 1));
400 __ cmov(below_equal, eax, Operand(ebx, 2));
401 __ cmov(above, eax, Operand(ebx, 3));
402 __ cmov(sign, eax, Operand(ecx, 0));
403 __ cmov(not_sign, eax, Operand(ecx, 1));
404 __ cmov(parity_even, eax, Operand(ecx, 2));
405 __ cmov(parity_odd, eax, Operand(ecx, 3));
406 __ cmov(less, eax, Operand(edx, 0));
407 __ cmov(greater_equal, eax, Operand(edx, 1));
408 __ cmov(less_equal, eax, Operand(edx, 2));
409 __ cmov(greater, eax, Operand(edx, 3));
410 }
christian.plesner.hansen@gmail.com9d58c2b2009-10-16 11:48:38 +0000411 }
412
sgjesse@chromium.orgc6c57182011-01-17 12:24:25 +0000413 // andpd, cmpltsd, movaps, psllq, psrlq, por.
fschneider@chromium.orgc20610a2010-09-22 09:44:58 +0000414 {
kmillikin@chromium.orgc36ce6e2011-04-04 08:25:31 +0000415 if (CpuFeatures::IsSupported(SSE2)) {
ulan@chromium.org750145a2013-03-07 15:14:13 +0000416 CpuFeatureScope fscope(&assm, SSE2);
fschneider@chromium.orgc20610a2010-09-22 09:44:58 +0000417 __ andpd(xmm0, xmm1);
418 __ andpd(xmm1, xmm2);
419
420 __ cmpltsd(xmm0, xmm1);
421 __ cmpltsd(xmm1, xmm2);
422
423 __ movaps(xmm0, xmm1);
424 __ movaps(xmm1, xmm2);
425
426 __ psllq(xmm0, 17);
427 __ psllq(xmm1, 42);
sgjesse@chromium.orgc6c57182011-01-17 12:24:25 +0000428
429 __ psllq(xmm0, xmm1);
430 __ psllq(xmm1, xmm2);
431
432 __ psrlq(xmm0, 17);
433 __ psrlq(xmm1, 42);
434
435 __ psrlq(xmm0, xmm1);
436 __ psrlq(xmm1, xmm2);
437
438 __ por(xmm0, xmm1);
439 __ por(xmm1, xmm2);
fschneider@chromium.orgc20610a2010-09-22 09:44:58 +0000440 }
441 }
442
erik.corry@gmail.comd91075f2011-02-10 07:45:38 +0000443 {
yangguo@chromium.orga6bbcc82012-12-21 12:35:02 +0000444 if (CpuFeatures::IsSupported(SSE2) &&
445 CpuFeatures::IsSupported(SSE4_1)) {
ulan@chromium.org750145a2013-03-07 15:14:13 +0000446 CpuFeatureScope scope(&assm, SSE4_1);
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000447 __ pextrd(eax, xmm0, 1);
448 __ pinsrd(xmm1, eax, 0);
erik.corry@gmail.comd91075f2011-02-10 07:45:38 +0000449 }
450 }
451
ricow@chromium.org64e3a4b2011-12-13 08:07:27 +0000452 // Nop instructions
453 for (int i = 0; i < 16; i++) {
454 __ Nop(i);
455 }
456
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000457 __ ret(0);
458
459 CodeDesc desc;
460 assm.GetCode(&desc);
ulan@chromium.org09d7ab52013-02-25 15:50:35 +0000461 Object* code = isolate->heap()->CreateCode(
lrn@chromium.org303ada72010-10-27 09:33:13 +0000462 desc,
463 Code::ComputeFlags(Code::STUB),
ulan@chromium.org09d7ab52013-02-25 15:50:35 +0000464 Handle<Code>())->ToObjectChecked();
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000465 CHECK(code->IsCode());
fschneider@chromium.org9e3e0b62011-01-03 10:16:46 +0000466#ifdef OBJECT_PRINT
mads.s.ager@gmail.com9a4089a2008-09-01 08:55:01 +0000467 Code::cast(code)->Print();
468 byte* begin = Code::cast(code)->instruction_start();
469 byte* end = begin + Code::cast(code)->instruction_size();
470 disasm::Disassembler::Disassemble(stdout, begin, end);
471#endif
472}
473
474#undef __