Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(882)

Side by Side Diff: test/cctest/test-macro-assembler-x64.cc

Issue 6682026: Fix SmiCompare on 64 bit to distinguish between comparisons where... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 int result = FUNCTION_CAST<F0>(buffer)(); 183 int result = FUNCTION_CAST<F0>(buffer)();
184 CHECK_EQ(0, result); 184 CHECK_EQ(0, result);
185 } 185 }
186 186
187 187
188 void TestSmiCompare(MacroAssembler* masm, Label* exit, int id, int x, int y) { 188 void TestSmiCompare(MacroAssembler* masm, Label* exit, int id, int x, int y) {
189 __ Move(rcx, Smi::FromInt(x)); 189 __ Move(rcx, Smi::FromInt(x));
190 __ movq(r8, rcx); 190 __ movq(r8, rcx);
191 __ Move(rdx, Smi::FromInt(y)); 191 __ Move(rdx, Smi::FromInt(y));
192 __ movq(r9, rdx); 192 __ movq(r9, rdx);
193 __ SmiCompare(rcx, rdx); 193 __ cmpq(rcx, rdx);
194 if (x < y) { 194 if (x < y) {
195 __ movl(rax, Immediate(id + 1)); 195 __ movl(rax, Immediate(id + 1));
196 __ j(greater_equal, exit); 196 __ j(greater_equal, exit);
197 } else if (x > y) { 197 } else if (x > y) {
198 __ movl(rax, Immediate(id + 2)); 198 __ movl(rax, Immediate(id + 2));
199 __ j(less_equal, exit); 199 __ j(less_equal, exit);
200 } else { 200 } else {
201 ASSERT_EQ(x, y); 201 ASSERT_EQ(x, y);
202 __ movl(rax, Immediate(id + 3)); 202 __ movl(rax, Immediate(id + 3));
203 __ j(not_equal, exit); 203 __ j(not_equal, exit);
204 } 204 }
205 __ movl(rax, Immediate(id + 4)); 205 __ movl(rax, Immediate(id + 4));
206 __ cmpq(rcx, r8); 206 __ cmpq(rcx, r8);
207 __ j(not_equal, exit); 207 __ j(not_equal, exit);
208 __ incq(rax); 208 __ incq(rax);
209 __ cmpq(rdx, r9); 209 __ cmpq(rdx, r9);
210 __ j(not_equal, exit); 210 __ j(not_equal, exit);
211 211
212 if (x != y) { 212 if (x != y) {
213 __ SmiCompare(rdx, rcx); 213 __ cmpq(rdx, rcx);
214 if (y < x) { 214 if (y < x) {
215 __ movl(rax, Immediate(id + 9)); 215 __ movl(rax, Immediate(id + 9));
216 __ j(greater_equal, exit); 216 __ j(greater_equal, exit);
217 } else { 217 } else {
218 ASSERT(y > x); 218 ASSERT(y > x);
219 __ movl(rax, Immediate(id + 10)); 219 __ movl(rax, Immediate(id + 10));
220 __ j(less_equal, exit); 220 __ j(less_equal, exit);
221 } 221 }
222 } else { 222 } else {
223 __ SmiCompare(rcx, rcx); 223 __ cmpq(rcx, rcx);
224 __ movl(rax, Immediate(id + 11)); 224 __ movl(rax, Immediate(id + 11));
225 __ j(not_equal, exit); 225 __ j(not_equal, exit);
226 __ incq(rax); 226 __ incq(rax);
227 __ cmpq(rcx, r8); 227 __ cmpq(rcx, r8);
228 __ j(not_equal, exit); 228 __ j(not_equal, exit);
229 } 229 }
230 } 230 }
231 231
232 232
233 // Test that we can compare smis for equality (and more). 233 // Test that we can compare smis for equality (and more).
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 293
294 MacroAssembler* masm = &assembler; 294 MacroAssembler* masm = &assembler;
295 masm->set_allow_stub_calls(false); 295 masm->set_allow_stub_calls(false);
296 EntryCode(masm); 296 EntryCode(masm);
297 Label exit; 297 Label exit;
298 298
299 __ movq(rax, Immediate(1)); // Test number. 299 __ movq(rax, Immediate(1)); // Test number.
300 __ movl(rcx, Immediate(0)); 300 __ movl(rcx, Immediate(0));
301 __ Integer32ToSmi(rcx, rcx); 301 __ Integer32ToSmi(rcx, rcx);
302 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(0))); 302 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(0)));
303 __ SmiCompare(rcx, rdx); 303 __ cmpq(rcx, rdx);
304 __ j(not_equal, &exit); 304 __ j(not_equal, &exit);
305 305
306 __ movq(rax, Immediate(2)); // Test number. 306 __ movq(rax, Immediate(2)); // Test number.
307 __ movl(rcx, Immediate(1024)); 307 __ movl(rcx, Immediate(1024));
308 __ Integer32ToSmi(rcx, rcx); 308 __ Integer32ToSmi(rcx, rcx);
309 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(1024))); 309 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(1024)));
310 __ SmiCompare(rcx, rdx); 310 __ cmpq(rcx, rdx);
311 __ j(not_equal, &exit); 311 __ j(not_equal, &exit);
312 312
313 __ movq(rax, Immediate(3)); // Test number. 313 __ movq(rax, Immediate(3)); // Test number.
314 __ movl(rcx, Immediate(-1)); 314 __ movl(rcx, Immediate(-1));
315 __ Integer32ToSmi(rcx, rcx); 315 __ Integer32ToSmi(rcx, rcx);
316 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(-1))); 316 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(-1)));
317 __ SmiCompare(rcx, rdx); 317 __ cmpq(rcx, rdx);
318 __ j(not_equal, &exit); 318 __ j(not_equal, &exit);
319 319
320 __ movq(rax, Immediate(4)); // Test number. 320 __ movq(rax, Immediate(4)); // Test number.
321 __ movl(rcx, Immediate(Smi::kMaxValue)); 321 __ movl(rcx, Immediate(Smi::kMaxValue));
322 __ Integer32ToSmi(rcx, rcx); 322 __ Integer32ToSmi(rcx, rcx);
323 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(Smi::kMaxValue))); 323 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(Smi::kMaxValue)));
324 __ SmiCompare(rcx, rdx); 324 __ cmpq(rcx, rdx);
325 __ j(not_equal, &exit); 325 __ j(not_equal, &exit);
326 326
327 __ movq(rax, Immediate(5)); // Test number. 327 __ movq(rax, Immediate(5)); // Test number.
328 __ movl(rcx, Immediate(Smi::kMinValue)); 328 __ movl(rcx, Immediate(Smi::kMinValue));
329 __ Integer32ToSmi(rcx, rcx); 329 __ Integer32ToSmi(rcx, rcx);
330 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(Smi::kMinValue))); 330 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(Smi::kMinValue)));
331 __ SmiCompare(rcx, rdx); 331 __ cmpq(rcx, rdx);
332 __ j(not_equal, &exit); 332 __ j(not_equal, &exit);
333 333
334 // Different target register. 334 // Different target register.
335 335
336 __ movq(rax, Immediate(6)); // Test number. 336 __ movq(rax, Immediate(6)); // Test number.
337 __ movl(rcx, Immediate(0)); 337 __ movl(rcx, Immediate(0));
338 __ Integer32ToSmi(r8, rcx); 338 __ Integer32ToSmi(r8, rcx);
339 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(0))); 339 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(0)));
340 __ SmiCompare(r8, rdx); 340 __ cmpq(r8, rdx);
341 __ j(not_equal, &exit); 341 __ j(not_equal, &exit);
342 342
343 __ movq(rax, Immediate(7)); // Test number. 343 __ movq(rax, Immediate(7)); // Test number.
344 __ movl(rcx, Immediate(1024)); 344 __ movl(rcx, Immediate(1024));
345 __ Integer32ToSmi(r8, rcx); 345 __ Integer32ToSmi(r8, rcx);
346 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(1024))); 346 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(1024)));
347 __ SmiCompare(r8, rdx); 347 __ cmpq(r8, rdx);
348 __ j(not_equal, &exit); 348 __ j(not_equal, &exit);
349 349
350 __ movq(rax, Immediate(8)); // Test number. 350 __ movq(rax, Immediate(8)); // Test number.
351 __ movl(rcx, Immediate(-1)); 351 __ movl(rcx, Immediate(-1));
352 __ Integer32ToSmi(r8, rcx); 352 __ Integer32ToSmi(r8, rcx);
353 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(-1))); 353 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(-1)));
354 __ SmiCompare(r8, rdx); 354 __ cmpq(r8, rdx);
355 __ j(not_equal, &exit); 355 __ j(not_equal, &exit);
356 356
357 __ movq(rax, Immediate(9)); // Test number. 357 __ movq(rax, Immediate(9)); // Test number.
358 __ movl(rcx, Immediate(Smi::kMaxValue)); 358 __ movl(rcx, Immediate(Smi::kMaxValue));
359 __ Integer32ToSmi(r8, rcx); 359 __ Integer32ToSmi(r8, rcx);
360 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(Smi::kMaxValue))); 360 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(Smi::kMaxValue)));
361 __ SmiCompare(r8, rdx); 361 __ cmpq(r8, rdx);
362 __ j(not_equal, &exit); 362 __ j(not_equal, &exit);
363 363
364 __ movq(rax, Immediate(10)); // Test number. 364 __ movq(rax, Immediate(10)); // Test number.
365 __ movl(rcx, Immediate(Smi::kMinValue)); 365 __ movl(rcx, Immediate(Smi::kMinValue));
366 __ Integer32ToSmi(r8, rcx); 366 __ Integer32ToSmi(r8, rcx);
367 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(Smi::kMinValue))); 367 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(Smi::kMinValue)));
368 __ SmiCompare(r8, rdx); 368 __ cmpq(r8, rdx);
369 __ j(not_equal, &exit); 369 __ j(not_equal, &exit);
370 370
371 371
372 __ xor_(rax, rax); // Success. 372 __ xor_(rax, rax); // Success.
373 __ bind(&exit); 373 __ bind(&exit);
374 ExitCode(masm); 374 ExitCode(masm);
375 __ ret(0); 375 __ ret(0);
376 376
377 CodeDesc desc; 377 CodeDesc desc;
378 masm->GetCode(&desc); 378 masm->GetCode(&desc);
379 // Call the function from C++. 379 // Call the function from C++.
380 int result = FUNCTION_CAST<F0>(buffer)(); 380 int result = FUNCTION_CAST<F0>(buffer)();
381 CHECK_EQ(0, result); 381 CHECK_EQ(0, result);
382 } 382 }
383 383
384 384
385 void TestI64PlusConstantToSmi(MacroAssembler* masm, 385 void TestI64PlusConstantToSmi(MacroAssembler* masm,
386 Label* exit, 386 Label* exit,
387 int id, 387 int id,
388 int64_t x, 388 int64_t x,
389 int y) { 389 int y) {
390 int64_t result = x + y; 390 int64_t result = x + y;
391 ASSERT(Smi::IsValid(result)); 391 ASSERT(Smi::IsValid(result));
392 __ movl(rax, Immediate(id)); 392 __ movl(rax, Immediate(id));
393 __ Move(r8, Smi::FromInt(static_cast<int>(result))); 393 __ Move(r8, Smi::FromInt(static_cast<int>(result)));
394 __ movq(rcx, x, RelocInfo::NONE); 394 __ movq(rcx, x, RelocInfo::NONE);
395 __ movq(r11, rcx); 395 __ movq(r11, rcx);
396 __ Integer64PlusConstantToSmi(rdx, rcx, y); 396 __ Integer64PlusConstantToSmi(rdx, rcx, y);
397 __ SmiCompare(rdx, r8); 397 __ cmpq(rdx, r8);
398 __ j(not_equal, exit); 398 __ j(not_equal, exit);
399 399
400 __ incq(rax); 400 __ incq(rax);
401 __ SmiCompare(r11, rcx); 401 __ cmpq(r11, rcx);
402 __ j(not_equal, exit); 402 __ j(not_equal, exit);
403 403
404 __ incq(rax); 404 __ incq(rax);
405 __ Integer64PlusConstantToSmi(rcx, rcx, y); 405 __ Integer64PlusConstantToSmi(rcx, rcx, y);
406 __ SmiCompare(rcx, r8); 406 __ cmpq(rcx, r8);
407 __ j(not_equal, exit); 407 __ j(not_equal, exit);
408 } 408 }
409 409
410 410
411 TEST(Integer64PlusConstantToSmi) { 411 TEST(Integer64PlusConstantToSmi) {
412 // Allocate an executable page of memory. 412 // Allocate an executable page of memory.
413 size_t actual_size; 413 size_t actual_size;
414 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, 414 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize,
415 &actual_size, 415 &actual_size,
416 true)); 416 true));
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 653
654 void TestSmiNeg(MacroAssembler* masm, Label* exit, int id, int x) { 654 void TestSmiNeg(MacroAssembler* masm, Label* exit, int id, int x) {
655 __ Move(rcx, Smi::FromInt(x)); 655 __ Move(rcx, Smi::FromInt(x));
656 __ movq(r11, rcx); 656 __ movq(r11, rcx);
657 if (x == Smi::kMinValue || x == 0) { 657 if (x == Smi::kMinValue || x == 0) {
658 // Negation fails. 658 // Negation fails.
659 __ movl(rax, Immediate(id + 8)); 659 __ movl(rax, Immediate(id + 8));
660 __ SmiNeg(r9, rcx, exit); 660 __ SmiNeg(r9, rcx, exit);
661 661
662 __ incq(rax); 662 __ incq(rax);
663 __ SmiCompare(r11, rcx); 663 __ cmpq(r11, rcx);
664 __ j(not_equal, exit); 664 __ j(not_equal, exit);
665 665
666 __ incq(rax); 666 __ incq(rax);
667 __ SmiNeg(rcx, rcx, exit); 667 __ SmiNeg(rcx, rcx, exit);
668 668
669 __ incq(rax); 669 __ incq(rax);
670 __ SmiCompare(r11, rcx); 670 __ cmpq(r11, rcx);
671 __ j(not_equal, exit); 671 __ j(not_equal, exit);
672 } else { 672 } else {
673 Label smi_ok, smi_ok2; 673 Label smi_ok, smi_ok2;
674 int result = -x; 674 int result = -x;
675 __ movl(rax, Immediate(id)); 675 __ movl(rax, Immediate(id));
676 __ Move(r8, Smi::FromInt(result)); 676 __ Move(r8, Smi::FromInt(result));
677 677
678 __ SmiNeg(r9, rcx, &smi_ok); 678 __ SmiNeg(r9, rcx, &smi_ok);
679 __ jmp(exit); 679 __ jmp(exit);
680 __ bind(&smi_ok); 680 __ bind(&smi_ok);
681 __ incq(rax); 681 __ incq(rax);
682 __ SmiCompare(r9, r8); 682 __ cmpq(r9, r8);
683 __ j(not_equal, exit); 683 __ j(not_equal, exit);
684 684
685 __ incq(rax); 685 __ incq(rax);
686 __ SmiCompare(r11, rcx); 686 __ cmpq(r11, rcx);
687 __ j(not_equal, exit); 687 __ j(not_equal, exit);
688 688
689 __ incq(rax); 689 __ incq(rax);
690 __ SmiNeg(rcx, rcx, &smi_ok2); 690 __ SmiNeg(rcx, rcx, &smi_ok2);
691 __ jmp(exit); 691 __ jmp(exit);
692 __ bind(&smi_ok2); 692 __ bind(&smi_ok2);
693 __ incq(rax); 693 __ incq(rax);
694 __ SmiCompare(rcx, r8); 694 __ cmpq(rcx, r8);
695 __ j(not_equal, exit); 695 __ j(not_equal, exit);
696 } 696 }
697 } 697 }
698 698
699 699
700 TEST(SmiNeg) { 700 TEST(SmiNeg) {
701 // Allocate an executable page of memory. 701 // Allocate an executable page of memory.
702 size_t actual_size; 702 size_t actual_size;
703 byte* buffer = 703 byte* buffer =
704 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, 704 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 int second) { 744 int second) {
745 __ movl(rcx, Immediate(first)); 745 __ movl(rcx, Immediate(first));
746 __ Integer32ToSmi(rcx, rcx); 746 __ Integer32ToSmi(rcx, rcx);
747 __ movl(rdx, Immediate(second)); 747 __ movl(rdx, Immediate(second));
748 __ Integer32ToSmi(rdx, rdx); 748 __ Integer32ToSmi(rdx, rdx);
749 __ movl(r8, Immediate(first + second)); 749 __ movl(r8, Immediate(first + second));
750 __ Integer32ToSmi(r8, r8); 750 __ Integer32ToSmi(r8, r8);
751 751
752 __ movl(rax, Immediate(id)); // Test number. 752 __ movl(rax, Immediate(id)); // Test number.
753 __ SmiAdd(r9, rcx, rdx, exit); 753 __ SmiAdd(r9, rcx, rdx, exit);
754 __ SmiCompare(r9, r8); 754 __ cmpq(r9, r8);
755 __ j(not_equal, exit); 755 __ j(not_equal, exit);
756 756
757 __ incq(rax); 757 __ incq(rax);
758 __ SmiAdd(rcx, rcx, rdx, exit); \ 758 __ SmiAdd(rcx, rcx, rdx, exit); \
759 __ SmiCompare(rcx, r8); 759 __ cmpq(rcx, r8);
760 __ j(not_equal, exit); 760 __ j(not_equal, exit);
761 761
762 __ movl(rcx, Immediate(first)); 762 __ movl(rcx, Immediate(first));
763 __ Integer32ToSmi(rcx, rcx); 763 __ Integer32ToSmi(rcx, rcx);
764 764
765 __ incq(rax); 765 __ incq(rax);
766 __ SmiAddConstant(r9, rcx, Smi::FromInt(second)); 766 __ SmiAddConstant(r9, rcx, Smi::FromInt(second));
767 __ SmiCompare(r9, r8); 767 __ cmpq(r9, r8);
768 __ j(not_equal, exit); 768 __ j(not_equal, exit);
769 769
770 __ SmiAddConstant(rcx, rcx, Smi::FromInt(second)); 770 __ SmiAddConstant(rcx, rcx, Smi::FromInt(second));
771 __ SmiCompare(rcx, r8); 771 __ cmpq(rcx, r8);
772 __ j(not_equal, exit); 772 __ j(not_equal, exit);
773 773
774 __ movl(rcx, Immediate(first)); 774 __ movl(rcx, Immediate(first));
775 __ Integer32ToSmi(rcx, rcx); 775 __ Integer32ToSmi(rcx, rcx);
776 776
777 __ incq(rax); 777 __ incq(rax);
778 __ SmiAddConstant(r9, rcx, Smi::FromInt(second), exit); 778 __ SmiAddConstant(r9, rcx, Smi::FromInt(second), exit);
779 __ SmiCompare(r9, r8); 779 __ cmpq(r9, r8);
780 __ j(not_equal, exit); 780 __ j(not_equal, exit);
781 781
782 __ incq(rax); 782 __ incq(rax);
783 __ SmiAddConstant(rcx, rcx, Smi::FromInt(second), exit); 783 __ SmiAddConstant(rcx, rcx, Smi::FromInt(second), exit);
784 __ SmiCompare(rcx, r8); 784 __ cmpq(rcx, r8);
785 __ j(not_equal, exit); 785 __ j(not_equal, exit);
786 } 786 }
787 787
788 TEST(SmiAdd) { 788 TEST(SmiAdd) {
789 // Allocate an executable page of memory. 789 // Allocate an executable page of memory.
790 size_t actual_size; 790 size_t actual_size;
791 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, 791 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize,
792 &actual_size, 792 &actual_size,
793 true)); 793 true));
794 CHECK(buffer); 794 CHECK(buffer);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 Label* exit, 827 Label* exit,
828 int id, 828 int id,
829 int first, 829 int first,
830 int second) { 830 int second) {
831 __ Move(rcx, Smi::FromInt(first)); 831 __ Move(rcx, Smi::FromInt(first));
832 __ Move(rdx, Smi::FromInt(second)); 832 __ Move(rdx, Smi::FromInt(second));
833 __ Move(r8, Smi::FromInt(first - second)); 833 __ Move(r8, Smi::FromInt(first - second));
834 834
835 __ movl(rax, Immediate(id)); // Test 0. 835 __ movl(rax, Immediate(id)); // Test 0.
836 __ SmiSub(r9, rcx, rdx, exit); 836 __ SmiSub(r9, rcx, rdx, exit);
837 __ SmiCompare(r9, r8); 837 __ cmpq(r9, r8);
838 __ j(not_equal, exit); 838 __ j(not_equal, exit);
839 839
840 __ incq(rax); // Test 1. 840 __ incq(rax); // Test 1.
841 __ SmiSub(rcx, rcx, rdx, exit); 841 __ SmiSub(rcx, rcx, rdx, exit);
842 __ SmiCompare(rcx, r8); 842 __ cmpq(rcx, r8);
843 __ j(not_equal, exit); 843 __ j(not_equal, exit);
844 844
845 __ Move(rcx, Smi::FromInt(first)); 845 __ Move(rcx, Smi::FromInt(first));
846 846
847 __ incq(rax); // Test 2. 847 __ incq(rax); // Test 2.
848 __ SmiSubConstant(r9, rcx, Smi::FromInt(second)); 848 __ SmiSubConstant(r9, rcx, Smi::FromInt(second));
849 __ SmiCompare(r9, r8); 849 __ cmpq(r9, r8);
850 __ j(not_equal, exit); 850 __ j(not_equal, exit);
851 851
852 __ incq(rax); // Test 3. 852 __ incq(rax); // Test 3.
853 __ SmiSubConstant(rcx, rcx, Smi::FromInt(second)); 853 __ SmiSubConstant(rcx, rcx, Smi::FromInt(second));
854 __ SmiCompare(rcx, r8); 854 __ cmpq(rcx, r8);
855 __ j(not_equal, exit); 855 __ j(not_equal, exit);
856 856
857 __ Move(rcx, Smi::FromInt(first)); 857 __ Move(rcx, Smi::FromInt(first));
858 858
859 __ incq(rax); // Test 4. 859 __ incq(rax); // Test 4.
860 __ SmiSubConstant(r9, rcx, Smi::FromInt(second), exit); 860 __ SmiSubConstant(r9, rcx, Smi::FromInt(second), exit);
861 __ SmiCompare(r9, r8); 861 __ cmpq(r9, r8);
862 __ j(not_equal, exit); 862 __ j(not_equal, exit);
863 863
864 __ incq(rax); // Test 5. 864 __ incq(rax); // Test 5.
865 __ SmiSubConstant(rcx, rcx, Smi::FromInt(second), exit); 865 __ SmiSubConstant(rcx, rcx, Smi::FromInt(second), exit);
866 __ SmiCompare(rcx, r8); 866 __ cmpq(rcx, r8);
867 __ j(not_equal, exit); 867 __ j(not_equal, exit);
868 } 868 }
869 869
870 static void SmiSubOverflowTest(MacroAssembler* masm, 870 static void SmiSubOverflowTest(MacroAssembler* masm,
871 Label* exit, 871 Label* exit,
872 int id, 872 int id,
873 int x) { 873 int x) {
874 // Subtracts a Smi from x so that the subtraction overflows. 874 // Subtracts a Smi from x so that the subtraction overflows.
875 ASSERT(x != -1); // Can't overflow by subtracting a Smi. 875 ASSERT(x != -1); // Can't overflow by subtracting a Smi.
876 int y_max = (x < 0) ? (Smi::kMaxValue + 0) : (Smi::kMinValue + 0); 876 int y_max = (x < 0) ? (Smi::kMaxValue + 0) : (Smi::kMinValue + 0);
877 int y_min = (x < 0) ? (Smi::kMaxValue + x + 2) : (Smi::kMinValue + x); 877 int y_min = (x < 0) ? (Smi::kMaxValue + x + 2) : (Smi::kMinValue + x);
878 878
879 __ movl(rax, Immediate(id)); 879 __ movl(rax, Immediate(id));
880 __ Move(rcx, Smi::FromInt(x)); 880 __ Move(rcx, Smi::FromInt(x));
881 __ movq(r11, rcx); // Store original Smi value of x in r11. 881 __ movq(r11, rcx); // Store original Smi value of x in r11.
882 __ Move(rdx, Smi::FromInt(y_min)); 882 __ Move(rdx, Smi::FromInt(y_min));
883 { 883 {
884 Label overflow_ok; 884 Label overflow_ok;
885 __ SmiSub(r9, rcx, rdx, &overflow_ok); 885 __ SmiSub(r9, rcx, rdx, &overflow_ok);
886 __ jmp(exit); 886 __ jmp(exit);
887 __ bind(&overflow_ok); 887 __ bind(&overflow_ok);
888 __ incq(rax); 888 __ incq(rax);
889 __ SmiCompare(rcx, r11); 889 __ cmpq(rcx, r11);
890 __ j(not_equal, exit); 890 __ j(not_equal, exit);
891 } 891 }
892 892
893 { 893 {
894 Label overflow_ok; 894 Label overflow_ok;
895 __ incq(rax); 895 __ incq(rax);
896 __ SmiSub(rcx, rcx, rdx, &overflow_ok); 896 __ SmiSub(rcx, rcx, rdx, &overflow_ok);
897 __ jmp(exit); 897 __ jmp(exit);
898 __ bind(&overflow_ok); 898 __ bind(&overflow_ok);
899 __ incq(rax); 899 __ incq(rax);
900 __ SmiCompare(rcx, r11); 900 __ cmpq(rcx, r11);
901 __ j(not_equal, exit); 901 __ j(not_equal, exit);
902 } 902 }
903 903
904 __ movq(rcx, r11); 904 __ movq(rcx, r11);
905 { 905 {
906 Label overflow_ok; 906 Label overflow_ok;
907 __ incq(rax); 907 __ incq(rax);
908 __ SmiSubConstant(r9, rcx, Smi::FromInt(y_min), &overflow_ok); 908 __ SmiSubConstant(r9, rcx, Smi::FromInt(y_min), &overflow_ok);
909 __ jmp(exit); 909 __ jmp(exit);
910 __ bind(&overflow_ok); 910 __ bind(&overflow_ok);
911 __ incq(rax); 911 __ incq(rax);
912 __ SmiCompare(rcx, r11); 912 __ cmpq(rcx, r11);
913 __ j(not_equal, exit); 913 __ j(not_equal, exit);
914 } 914 }
915 915
916 { 916 {
917 Label overflow_ok; 917 Label overflow_ok;
918 __ incq(rax); 918 __ incq(rax);
919 __ SmiSubConstant(rcx, rcx, Smi::FromInt(y_min), &overflow_ok); 919 __ SmiSubConstant(rcx, rcx, Smi::FromInt(y_min), &overflow_ok);
920 __ jmp(exit); 920 __ jmp(exit);
921 __ bind(&overflow_ok); 921 __ bind(&overflow_ok);
922 __ incq(rax); 922 __ incq(rax);
923 __ SmiCompare(rcx, r11); 923 __ cmpq(rcx, r11);
924 __ j(not_equal, exit); 924 __ j(not_equal, exit);
925 } 925 }
926 926
927 __ Move(rdx, Smi::FromInt(y_max)); 927 __ Move(rdx, Smi::FromInt(y_max));
928 928
929 { 929 {
930 Label overflow_ok; 930 Label overflow_ok;
931 __ incq(rax); 931 __ incq(rax);
932 __ SmiSub(r9, rcx, rdx, &overflow_ok); 932 __ SmiSub(r9, rcx, rdx, &overflow_ok);
933 __ jmp(exit); 933 __ jmp(exit);
934 __ bind(&overflow_ok); 934 __ bind(&overflow_ok);
935 __ incq(rax); 935 __ incq(rax);
936 __ SmiCompare(rcx, r11); 936 __ cmpq(rcx, r11);
937 __ j(not_equal, exit); 937 __ j(not_equal, exit);
938 } 938 }
939 939
940 { 940 {
941 Label overflow_ok; 941 Label overflow_ok;
942 __ incq(rax); 942 __ incq(rax);
943 __ SmiSub(rcx, rcx, rdx, &overflow_ok); 943 __ SmiSub(rcx, rcx, rdx, &overflow_ok);
944 __ jmp(exit); 944 __ jmp(exit);
945 __ bind(&overflow_ok); 945 __ bind(&overflow_ok);
946 __ incq(rax); 946 __ incq(rax);
947 __ SmiCompare(rcx, r11); 947 __ cmpq(rcx, r11);
948 __ j(not_equal, exit); 948 __ j(not_equal, exit);
949 } 949 }
950 950
951 __ movq(rcx, r11); 951 __ movq(rcx, r11);
952 { 952 {
953 Label overflow_ok; 953 Label overflow_ok;
954 __ incq(rax); 954 __ incq(rax);
955 __ SmiSubConstant(r9, rcx, Smi::FromInt(y_max), &overflow_ok); 955 __ SmiSubConstant(r9, rcx, Smi::FromInt(y_max), &overflow_ok);
956 __ jmp(exit); 956 __ jmp(exit);
957 __ bind(&overflow_ok); 957 __ bind(&overflow_ok);
958 __ incq(rax); 958 __ incq(rax);
959 __ SmiCompare(rcx, r11); 959 __ cmpq(rcx, r11);
960 __ j(not_equal, exit); 960 __ j(not_equal, exit);
961 } 961 }
962 962
963 { 963 {
964 Label overflow_ok; 964 Label overflow_ok;
965 __ incq(rax); 965 __ incq(rax);
966 __ SmiSubConstant(rcx, rcx, Smi::FromInt(y_max), &overflow_ok); 966 __ SmiSubConstant(rcx, rcx, Smi::FromInt(y_max), &overflow_ok);
967 __ jmp(exit); 967 __ jmp(exit);
968 __ bind(&overflow_ok); 968 __ bind(&overflow_ok);
969 __ incq(rax); 969 __ incq(rax);
970 __ SmiCompare(rcx, r11); 970 __ cmpq(rcx, r11);
971 __ j(not_equal, exit); 971 __ j(not_equal, exit);
972 } 972 }
973 } 973 }
974 974
975 975
976 TEST(SmiSub) { 976 TEST(SmiSub) {
977 // Allocate an executable page of memory. 977 // Allocate an executable page of memory.
978 size_t actual_size; 978 size_t actual_size;
979 byte* buffer = 979 byte* buffer =
980 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, 980 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 int64_t result = static_cast<int64_t>(x) * static_cast<int64_t>(y); 1025 int64_t result = static_cast<int64_t>(x) * static_cast<int64_t>(y);
1026 bool negative_zero = (result == 0) && (x < 0 || y < 0); 1026 bool negative_zero = (result == 0) && (x < 0 || y < 0);
1027 __ Move(rcx, Smi::FromInt(x)); 1027 __ Move(rcx, Smi::FromInt(x));
1028 __ movq(r11, rcx); 1028 __ movq(r11, rcx);
1029 __ Move(rdx, Smi::FromInt(y)); 1029 __ Move(rdx, Smi::FromInt(y));
1030 if (Smi::IsValid(result) && !negative_zero) { 1030 if (Smi::IsValid(result) && !negative_zero) {
1031 __ movl(rax, Immediate(id)); 1031 __ movl(rax, Immediate(id));
1032 __ Move(r8, Smi::FromIntptr(result)); 1032 __ Move(r8, Smi::FromIntptr(result));
1033 __ SmiMul(r9, rcx, rdx, exit); 1033 __ SmiMul(r9, rcx, rdx, exit);
1034 __ incq(rax); 1034 __ incq(rax);
1035 __ SmiCompare(r11, rcx); 1035 __ cmpq(r11, rcx);
1036 __ j(not_equal, exit); 1036 __ j(not_equal, exit);
1037 __ incq(rax); 1037 __ incq(rax);
1038 __ SmiCompare(r9, r8); 1038 __ cmpq(r9, r8);
1039 __ j(not_equal, exit); 1039 __ j(not_equal, exit);
1040 1040
1041 __ incq(rax); 1041 __ incq(rax);
1042 __ SmiMul(rcx, rcx, rdx, exit); 1042 __ SmiMul(rcx, rcx, rdx, exit);
1043 __ SmiCompare(rcx, r8); 1043 __ cmpq(rcx, r8);
1044 __ j(not_equal, exit); 1044 __ j(not_equal, exit);
1045 } else { 1045 } else {
1046 __ movl(rax, Immediate(id + 8)); 1046 __ movl(rax, Immediate(id + 8));
1047 Label overflow_ok, overflow_ok2; 1047 Label overflow_ok, overflow_ok2;
1048 __ SmiMul(r9, rcx, rdx, &overflow_ok); 1048 __ SmiMul(r9, rcx, rdx, &overflow_ok);
1049 __ jmp(exit); 1049 __ jmp(exit);
1050 __ bind(&overflow_ok); 1050 __ bind(&overflow_ok);
1051 __ incq(rax); 1051 __ incq(rax);
1052 __ SmiCompare(r11, rcx); 1052 __ cmpq(r11, rcx);
1053 __ j(not_equal, exit); 1053 __ j(not_equal, exit);
1054 __ incq(rax); 1054 __ incq(rax);
1055 __ SmiMul(rcx, rcx, rdx, &overflow_ok2); 1055 __ SmiMul(rcx, rcx, rdx, &overflow_ok2);
1056 __ jmp(exit); 1056 __ jmp(exit);
1057 __ bind(&overflow_ok2); 1057 __ bind(&overflow_ok2);
1058 // 31-bit version doesn't preserve rcx on failure. 1058 // 31-bit version doesn't preserve rcx on failure.
1059 // __ incq(rax); 1059 // __ incq(rax);
1060 // __ SmiCompare(r11, rcx); 1060 // __ cmpq(r11, rcx);
1061 // __ j(not_equal, exit); 1061 // __ j(not_equal, exit);
1062 } 1062 }
1063 } 1063 }
1064 1064
1065 1065
1066 TEST(SmiMul) { 1066 TEST(SmiMul) {
1067 // Allocate an executable page of memory. 1067 // Allocate an executable page of memory.
1068 size_t actual_size; 1068 size_t actual_size;
1069 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, 1069 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize,
1070 &actual_size, 1070 &actual_size,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1119 __ Move(r14, Smi::FromInt(y)); 1119 __ Move(r14, Smi::FromInt(y));
1120 if (!fraction && !overflow && !negative_zero && !division_by_zero) { 1120 if (!fraction && !overflow && !negative_zero && !division_by_zero) {
1121 // Division succeeds 1121 // Division succeeds
1122 __ movq(rcx, r11); 1122 __ movq(rcx, r11);
1123 __ movq(r15, Immediate(id)); 1123 __ movq(r15, Immediate(id));
1124 int result = x / y; 1124 int result = x / y;
1125 __ Move(r8, Smi::FromInt(result)); 1125 __ Move(r8, Smi::FromInt(result));
1126 __ SmiDiv(r9, rcx, r14, exit); 1126 __ SmiDiv(r9, rcx, r14, exit);
1127 // Might have destroyed rcx and r14. 1127 // Might have destroyed rcx and r14.
1128 __ incq(r15); 1128 __ incq(r15);
1129 __ SmiCompare(r9, r8); 1129 __ cmpq(r9, r8);
1130 __ j(not_equal, exit); 1130 __ j(not_equal, exit);
1131 1131
1132 __ incq(r15); 1132 __ incq(r15);
1133 __ movq(rcx, r11); 1133 __ movq(rcx, r11);
1134 __ Move(r14, Smi::FromInt(y)); 1134 __ Move(r14, Smi::FromInt(y));
1135 __ SmiCompare(rcx, r11); 1135 __ cmpq(rcx, r11);
1136 __ j(not_equal, exit); 1136 __ j(not_equal, exit);
1137 1137
1138 __ incq(r15); 1138 __ incq(r15);
1139 __ SmiDiv(rcx, rcx, r14, exit); 1139 __ SmiDiv(rcx, rcx, r14, exit);
1140 1140
1141 __ incq(r15); 1141 __ incq(r15);
1142 __ SmiCompare(rcx, r8); 1142 __ cmpq(rcx, r8);
1143 __ j(not_equal, exit); 1143 __ j(not_equal, exit);
1144 } else { 1144 } else {
1145 // Division fails. 1145 // Division fails.
1146 __ movq(r15, Immediate(id + 8)); 1146 __ movq(r15, Immediate(id + 8));
1147 1147
1148 Label fail_ok, fail_ok2; 1148 Label fail_ok, fail_ok2;
1149 __ movq(rcx, r11); 1149 __ movq(rcx, r11);
1150 __ SmiDiv(r9, rcx, r14, &fail_ok); 1150 __ SmiDiv(r9, rcx, r14, &fail_ok);
1151 __ jmp(exit); 1151 __ jmp(exit);
1152 __ bind(&fail_ok); 1152 __ bind(&fail_ok);
1153 1153
1154 __ incq(r15); 1154 __ incq(r15);
1155 __ SmiCompare(rcx, r11); 1155 __ cmpq(rcx, r11);
1156 __ j(not_equal, exit); 1156 __ j(not_equal, exit);
1157 1157
1158 __ incq(r15); 1158 __ incq(r15);
1159 __ SmiDiv(rcx, rcx, r14, &fail_ok2); 1159 __ SmiDiv(rcx, rcx, r14, &fail_ok2);
1160 __ jmp(exit); 1160 __ jmp(exit);
1161 __ bind(&fail_ok2); 1161 __ bind(&fail_ok2);
1162 1162
1163 __ incq(r15); 1163 __ incq(r15);
1164 __ SmiCompare(rcx, r11); 1164 __ cmpq(rcx, r11);
1165 __ j(not_equal, exit); 1165 __ j(not_equal, exit);
1166 } 1166 }
1167 } 1167 }
1168 1168
1169 1169
1170 TEST(SmiDiv) { 1170 TEST(SmiDiv) {
1171 // Allocate an executable page of memory. 1171 // Allocate an executable page of memory.
1172 size_t actual_size; 1172 size_t actual_size;
1173 byte* buffer = 1173 byte* buffer =
1174 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, 1174 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1231 __ movq(r11, rcx); 1231 __ movq(r11, rcx);
1232 __ Move(r14, Smi::FromInt(y)); 1232 __ Move(r14, Smi::FromInt(y));
1233 if (!division_overflow && !negative_zero && !division_by_zero) { 1233 if (!division_overflow && !negative_zero && !division_by_zero) {
1234 // Modulo succeeds 1234 // Modulo succeeds
1235 __ movq(r15, Immediate(id)); 1235 __ movq(r15, Immediate(id));
1236 int result = x % y; 1236 int result = x % y;
1237 __ Move(r8, Smi::FromInt(result)); 1237 __ Move(r8, Smi::FromInt(result));
1238 __ SmiMod(r9, rcx, r14, exit); 1238 __ SmiMod(r9, rcx, r14, exit);
1239 1239
1240 __ incq(r15); 1240 __ incq(r15);
1241 __ SmiCompare(r9, r8); 1241 __ cmpq(r9, r8);
1242 __ j(not_equal, exit); 1242 __ j(not_equal, exit);
1243 1243
1244 __ incq(r15); 1244 __ incq(r15);
1245 __ SmiCompare(rcx, r11); 1245 __ cmpq(rcx, r11);
1246 __ j(not_equal, exit); 1246 __ j(not_equal, exit);
1247 1247
1248 __ incq(r15); 1248 __ incq(r15);
1249 __ SmiMod(rcx, rcx, r14, exit); 1249 __ SmiMod(rcx, rcx, r14, exit);
1250 1250
1251 __ incq(r15); 1251 __ incq(r15);
1252 __ SmiCompare(rcx, r8); 1252 __ cmpq(rcx, r8);
1253 __ j(not_equal, exit); 1253 __ j(not_equal, exit);
1254 } else { 1254 } else {
1255 // Modulo fails. 1255 // Modulo fails.
1256 __ movq(r15, Immediate(id + 8)); 1256 __ movq(r15, Immediate(id + 8));
1257 1257
1258 Label fail_ok, fail_ok2; 1258 Label fail_ok, fail_ok2;
1259 __ SmiMod(r9, rcx, r14, &fail_ok); 1259 __ SmiMod(r9, rcx, r14, &fail_ok);
1260 __ jmp(exit); 1260 __ jmp(exit);
1261 __ bind(&fail_ok); 1261 __ bind(&fail_ok);
1262 1262
1263 __ incq(r15); 1263 __ incq(r15);
1264 __ SmiCompare(rcx, r11); 1264 __ cmpq(rcx, r11);
1265 __ j(not_equal, exit); 1265 __ j(not_equal, exit);
1266 1266
1267 __ incq(r15); 1267 __ incq(r15);
1268 __ SmiMod(rcx, rcx, r14, &fail_ok2); 1268 __ SmiMod(rcx, rcx, r14, &fail_ok2);
1269 __ jmp(exit); 1269 __ jmp(exit);
1270 __ bind(&fail_ok2); 1270 __ bind(&fail_ok2);
1271 1271
1272 __ incq(r15); 1272 __ incq(r15);
1273 __ SmiCompare(rcx, r11); 1273 __ cmpq(rcx, r11);
1274 __ j(not_equal, exit); 1274 __ j(not_equal, exit);
1275 } 1275 }
1276 } 1276 }
1277 1277
1278 1278
1279 TEST(SmiMod) { 1279 TEST(SmiMod) {
1280 // Allocate an executable page of memory. 1280 // Allocate an executable page of memory.
1281 size_t actual_size; 1281 size_t actual_size;
1282 byte* buffer = 1282 byte* buffer =
1283 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, 1283 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1333 1333
1334 void TestSmiIndex(MacroAssembler* masm, Label* exit, int id, int x) { 1334 void TestSmiIndex(MacroAssembler* masm, Label* exit, int id, int x) {
1335 __ movl(rax, Immediate(id)); 1335 __ movl(rax, Immediate(id));
1336 1336
1337 for (int i = 0; i < 8; i++) { 1337 for (int i = 0; i < 8; i++) {
1338 __ Move(rcx, Smi::FromInt(x)); 1338 __ Move(rcx, Smi::FromInt(x));
1339 SmiIndex index = masm->SmiToIndex(rdx, rcx, i); 1339 SmiIndex index = masm->SmiToIndex(rdx, rcx, i);
1340 ASSERT(index.reg.is(rcx) || index.reg.is(rdx)); 1340 ASSERT(index.reg.is(rcx) || index.reg.is(rdx));
1341 __ shl(index.reg, Immediate(index.scale)); 1341 __ shl(index.reg, Immediate(index.scale));
1342 __ Set(r8, static_cast<intptr_t>(x) << i); 1342 __ Set(r8, static_cast<intptr_t>(x) << i);
1343 __ SmiCompare(index.reg, r8); 1343 __ cmpq(index.reg, r8);
1344 __ j(not_equal, exit); 1344 __ j(not_equal, exit);
1345 __ incq(rax); 1345 __ incq(rax);
1346 __ Move(rcx, Smi::FromInt(x)); 1346 __ Move(rcx, Smi::FromInt(x));
1347 index = masm->SmiToIndex(rcx, rcx, i); 1347 index = masm->SmiToIndex(rcx, rcx, i);
1348 ASSERT(index.reg.is(rcx)); 1348 ASSERT(index.reg.is(rcx));
1349 __ shl(rcx, Immediate(index.scale)); 1349 __ shl(rcx, Immediate(index.scale));
1350 __ Set(r8, static_cast<intptr_t>(x) << i); 1350 __ Set(r8, static_cast<intptr_t>(x) << i);
1351 __ SmiCompare(rcx, r8); 1351 __ cmpq(rcx, r8);
1352 __ j(not_equal, exit); 1352 __ j(not_equal, exit);
1353 __ incq(rax); 1353 __ incq(rax);
1354 1354
1355 __ Move(rcx, Smi::FromInt(x)); 1355 __ Move(rcx, Smi::FromInt(x));
1356 index = masm->SmiToNegativeIndex(rdx, rcx, i); 1356 index = masm->SmiToNegativeIndex(rdx, rcx, i);
1357 ASSERT(index.reg.is(rcx) || index.reg.is(rdx)); 1357 ASSERT(index.reg.is(rcx) || index.reg.is(rdx));
1358 __ shl(index.reg, Immediate(index.scale)); 1358 __ shl(index.reg, Immediate(index.scale));
1359 __ Set(r8, static_cast<intptr_t>(-x) << i); 1359 __ Set(r8, static_cast<intptr_t>(-x) << i);
1360 __ SmiCompare(index.reg, r8); 1360 __ cmpq(index.reg, r8);
1361 __ j(not_equal, exit); 1361 __ j(not_equal, exit);
1362 __ incq(rax); 1362 __ incq(rax);
1363 __ Move(rcx, Smi::FromInt(x)); 1363 __ Move(rcx, Smi::FromInt(x));
1364 index = masm->SmiToNegativeIndex(rcx, rcx, i); 1364 index = masm->SmiToNegativeIndex(rcx, rcx, i);
1365 ASSERT(index.reg.is(rcx)); 1365 ASSERT(index.reg.is(rcx));
1366 __ shl(rcx, Immediate(index.scale)); 1366 __ shl(rcx, Immediate(index.scale));
1367 __ Set(r8, static_cast<intptr_t>(-x) << i); 1367 __ Set(r8, static_cast<intptr_t>(-x) << i);
1368 __ SmiCompare(rcx, r8); 1368 __ cmpq(rcx, r8);
1369 __ j(not_equal, exit); 1369 __ j(not_equal, exit);
1370 __ incq(rax); 1370 __ incq(rax);
1371 } 1371 }
1372 } 1372 }
1373 1373
1374 TEST(SmiIndex) { 1374 TEST(SmiIndex) {
1375 // Allocate an executable page of memory. 1375 // Allocate an executable page of memory.
1376 size_t actual_size; 1376 size_t actual_size;
1377 byte* buffer = 1377 byte* buffer =
1378 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 3, 1378 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 3,
(...skipping 28 matching lines...) Expand all
1407 1407
1408 1408
1409 void TestSelectNonSmi(MacroAssembler* masm, Label* exit, int id, int x, int y) { 1409 void TestSelectNonSmi(MacroAssembler* masm, Label* exit, int id, int x, int y) {
1410 __ movl(rax, Immediate(id)); 1410 __ movl(rax, Immediate(id));
1411 __ Move(rcx, Smi::FromInt(x)); 1411 __ Move(rcx, Smi::FromInt(x));
1412 __ Move(rdx, Smi::FromInt(y)); 1412 __ Move(rdx, Smi::FromInt(y));
1413 __ xor_(rdx, Immediate(kSmiTagMask)); 1413 __ xor_(rdx, Immediate(kSmiTagMask));
1414 __ SelectNonSmi(r9, rcx, rdx, exit); 1414 __ SelectNonSmi(r9, rcx, rdx, exit);
1415 1415
1416 __ incq(rax); 1416 __ incq(rax);
1417 __ SmiCompare(r9, rdx); 1417 __ cmpq(r9, rdx);
1418 __ j(not_equal, exit); 1418 __ j(not_equal, exit);
1419 1419
1420 __ incq(rax); 1420 __ incq(rax);
1421 __ Move(rcx, Smi::FromInt(x)); 1421 __ Move(rcx, Smi::FromInt(x));
1422 __ Move(rdx, Smi::FromInt(y)); 1422 __ Move(rdx, Smi::FromInt(y));
1423 __ xor_(rcx, Immediate(kSmiTagMask)); 1423 __ xor_(rcx, Immediate(kSmiTagMask));
1424 __ SelectNonSmi(r9, rcx, rdx, exit); 1424 __ SelectNonSmi(r9, rcx, rdx, exit);
1425 1425
1426 __ incq(rax); 1426 __ incq(rax);
1427 __ SmiCompare(r9, rcx); 1427 __ cmpq(r9, rcx);
1428 __ j(not_equal, exit); 1428 __ j(not_equal, exit);
1429 1429
1430 __ incq(rax); 1430 __ incq(rax);
1431 Label fail_ok; 1431 Label fail_ok;
1432 __ Move(rcx, Smi::FromInt(x)); 1432 __ Move(rcx, Smi::FromInt(x));
1433 __ Move(rdx, Smi::FromInt(y)); 1433 __ Move(rdx, Smi::FromInt(y));
1434 __ xor_(rcx, Immediate(kSmiTagMask)); 1434 __ xor_(rcx, Immediate(kSmiTagMask));
1435 __ xor_(rdx, Immediate(kSmiTagMask)); 1435 __ xor_(rdx, Immediate(kSmiTagMask));
1436 __ SelectNonSmi(r9, rcx, rdx, &fail_ok); 1436 __ SelectNonSmi(r9, rcx, rdx, &fail_ok);
1437 __ jmp(exit); 1437 __ jmp(exit);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1481 void TestSmiAnd(MacroAssembler* masm, Label* exit, int id, int x, int y) { 1481 void TestSmiAnd(MacroAssembler* masm, Label* exit, int id, int x, int y) {
1482 int result = x & y; 1482 int result = x & y;
1483 1483
1484 __ movl(rax, Immediate(id)); 1484 __ movl(rax, Immediate(id));
1485 1485
1486 __ Move(rcx, Smi::FromInt(x)); 1486 __ Move(rcx, Smi::FromInt(x));
1487 __ movq(r11, rcx); 1487 __ movq(r11, rcx);
1488 __ Move(rdx, Smi::FromInt(y)); 1488 __ Move(rdx, Smi::FromInt(y));
1489 __ Move(r8, Smi::FromInt(result)); 1489 __ Move(r8, Smi::FromInt(result));
1490 __ SmiAnd(r9, rcx, rdx); 1490 __ SmiAnd(r9, rcx, rdx);
1491 __ SmiCompare(r8, r9); 1491 __ cmpq(r8, r9);
1492 __ j(not_equal, exit); 1492 __ j(not_equal, exit);
1493 1493
1494 __ incq(rax); 1494 __ incq(rax);
1495 __ SmiCompare(r11, rcx); 1495 __ cmpq(r11, rcx);
1496 __ j(not_equal, exit); 1496 __ j(not_equal, exit);
1497 1497
1498 __ incq(rax); 1498 __ incq(rax);
1499 __ SmiAnd(rcx, rcx, rdx); 1499 __ SmiAnd(rcx, rcx, rdx);
1500 __ SmiCompare(r8, rcx); 1500 __ cmpq(r8, rcx);
1501 __ j(not_equal, exit); 1501 __ j(not_equal, exit);
1502 1502
1503 __ movq(rcx, r11); 1503 __ movq(rcx, r11);
1504 __ incq(rax); 1504 __ incq(rax);
1505 __ SmiAndConstant(r9, rcx, Smi::FromInt(y)); 1505 __ SmiAndConstant(r9, rcx, Smi::FromInt(y));
1506 __ SmiCompare(r8, r9); 1506 __ cmpq(r8, r9);
1507 __ j(not_equal, exit); 1507 __ j(not_equal, exit);
1508 1508
1509 __ incq(rax); 1509 __ incq(rax);
1510 __ SmiCompare(r11, rcx); 1510 __ cmpq(r11, rcx);
1511 __ j(not_equal, exit); 1511 __ j(not_equal, exit);
1512 1512
1513 __ incq(rax); 1513 __ incq(rax);
1514 __ SmiAndConstant(rcx, rcx, Smi::FromInt(y)); 1514 __ SmiAndConstant(rcx, rcx, Smi::FromInt(y));
1515 __ SmiCompare(r8, rcx); 1515 __ cmpq(r8, rcx);
1516 __ j(not_equal, exit); 1516 __ j(not_equal, exit);
1517 } 1517 }
1518 1518
1519 1519
1520 TEST(SmiAnd) { 1520 TEST(SmiAnd) {
1521 // Allocate an executable page of memory. 1521 // Allocate an executable page of memory.
1522 size_t actual_size; 1522 size_t actual_size;
1523 byte* buffer = 1523 byte* buffer =
1524 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, 1524 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize,
1525 &actual_size, 1525 &actual_size,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1561 void TestSmiOr(MacroAssembler* masm, Label* exit, int id, int x, int y) { 1561 void TestSmiOr(MacroAssembler* masm, Label* exit, int id, int x, int y) {
1562 int result = x | y; 1562 int result = x | y;
1563 1563
1564 __ movl(rax, Immediate(id)); 1564 __ movl(rax, Immediate(id));
1565 1565
1566 __ Move(rcx, Smi::FromInt(x)); 1566 __ Move(rcx, Smi::FromInt(x));
1567 __ movq(r11, rcx); 1567 __ movq(r11, rcx);
1568 __ Move(rdx, Smi::FromInt(y)); 1568 __ Move(rdx, Smi::FromInt(y));
1569 __ Move(r8, Smi::FromInt(result)); 1569 __ Move(r8, Smi::FromInt(result));
1570 __ SmiOr(r9, rcx, rdx); 1570 __ SmiOr(r9, rcx, rdx);
1571 __ SmiCompare(r8, r9); 1571 __ cmpq(r8, r9);
1572 __ j(not_equal, exit); 1572 __ j(not_equal, exit);
1573 1573
1574 __ incq(rax); 1574 __ incq(rax);
1575 __ SmiCompare(r11, rcx); 1575 __ cmpq(r11, rcx);
1576 __ j(not_equal, exit); 1576 __ j(not_equal, exit);
1577 1577
1578 __ incq(rax); 1578 __ incq(rax);
1579 __ SmiOr(rcx, rcx, rdx); 1579 __ SmiOr(rcx, rcx, rdx);
1580 __ SmiCompare(r8, rcx); 1580 __ cmpq(r8, rcx);
1581 __ j(not_equal, exit); 1581 __ j(not_equal, exit);
1582 1582
1583 __ movq(rcx, r11); 1583 __ movq(rcx, r11);
1584 __ incq(rax); 1584 __ incq(rax);
1585 __ SmiOrConstant(r9, rcx, Smi::FromInt(y)); 1585 __ SmiOrConstant(r9, rcx, Smi::FromInt(y));
1586 __ SmiCompare(r8, r9); 1586 __ cmpq(r8, r9);
1587 __ j(not_equal, exit); 1587 __ j(not_equal, exit);
1588 1588
1589 __ incq(rax); 1589 __ incq(rax);
1590 __ SmiCompare(r11, rcx); 1590 __ cmpq(r11, rcx);
1591 __ j(not_equal, exit); 1591 __ j(not_equal, exit);
1592 1592
1593 __ incq(rax); 1593 __ incq(rax);
1594 __ SmiOrConstant(rcx, rcx, Smi::FromInt(y)); 1594 __ SmiOrConstant(rcx, rcx, Smi::FromInt(y));
1595 __ SmiCompare(r8, rcx); 1595 __ cmpq(r8, rcx);
1596 __ j(not_equal, exit); 1596 __ j(not_equal, exit);
1597 } 1597 }
1598 1598
1599 1599
1600 TEST(SmiOr) { 1600 TEST(SmiOr) {
1601 // Allocate an executable page of memory. 1601 // Allocate an executable page of memory.
1602 size_t actual_size; 1602 size_t actual_size;
1603 byte* buffer = 1603 byte* buffer =
1604 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, 1604 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize,
1605 &actual_size, 1605 &actual_size,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1643 void TestSmiXor(MacroAssembler* masm, Label* exit, int id, int x, int y) { 1643 void TestSmiXor(MacroAssembler* masm, Label* exit, int id, int x, int y) {
1644 int result = x ^ y; 1644 int result = x ^ y;
1645 1645
1646 __ movl(rax, Immediate(id)); 1646 __ movl(rax, Immediate(id));
1647 1647
1648 __ Move(rcx, Smi::FromInt(x)); 1648 __ Move(rcx, Smi::FromInt(x));
1649 __ movq(r11, rcx); 1649 __ movq(r11, rcx);
1650 __ Move(rdx, Smi::FromInt(y)); 1650 __ Move(rdx, Smi::FromInt(y));
1651 __ Move(r8, Smi::FromInt(result)); 1651 __ Move(r8, Smi::FromInt(result));
1652 __ SmiXor(r9, rcx, rdx); 1652 __ SmiXor(r9, rcx, rdx);
1653 __ SmiCompare(r8, r9); 1653 __ cmpq(r8, r9);
1654 __ j(not_equal, exit); 1654 __ j(not_equal, exit);
1655 1655
1656 __ incq(rax); 1656 __ incq(rax);
1657 __ SmiCompare(r11, rcx); 1657 __ cmpq(r11, rcx);
1658 __ j(not_equal, exit); 1658 __ j(not_equal, exit);
1659 1659
1660 __ incq(rax); 1660 __ incq(rax);
1661 __ SmiXor(rcx, rcx, rdx); 1661 __ SmiXor(rcx, rcx, rdx);
1662 __ SmiCompare(r8, rcx); 1662 __ cmpq(r8, rcx);
1663 __ j(not_equal, exit); 1663 __ j(not_equal, exit);
1664 1664
1665 __ movq(rcx, r11); 1665 __ movq(rcx, r11);
1666 __ incq(rax); 1666 __ incq(rax);
1667 __ SmiXorConstant(r9, rcx, Smi::FromInt(y)); 1667 __ SmiXorConstant(r9, rcx, Smi::FromInt(y));
1668 __ SmiCompare(r8, r9); 1668 __ cmpq(r8, r9);
1669 __ j(not_equal, exit); 1669 __ j(not_equal, exit);
1670 1670
1671 __ incq(rax); 1671 __ incq(rax);
1672 __ SmiCompare(r11, rcx); 1672 __ cmpq(r11, rcx);
1673 __ j(not_equal, exit); 1673 __ j(not_equal, exit);
1674 1674
1675 __ incq(rax); 1675 __ incq(rax);
1676 __ SmiXorConstant(rcx, rcx, Smi::FromInt(y)); 1676 __ SmiXorConstant(rcx, rcx, Smi::FromInt(y));
1677 __ SmiCompare(r8, rcx); 1677 __ cmpq(r8, rcx);
1678 __ j(not_equal, exit); 1678 __ j(not_equal, exit);
1679 } 1679 }
1680 1680
1681 1681
1682 TEST(SmiXor) { 1682 TEST(SmiXor) {
1683 // Allocate an executable page of memory. 1683 // Allocate an executable page of memory.
1684 size_t actual_size; 1684 size_t actual_size;
1685 byte* buffer = 1685 byte* buffer =
1686 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, 1686 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize,
1687 &actual_size, 1687 &actual_size,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1724 1724
1725 void TestSmiNot(MacroAssembler* masm, Label* exit, int id, int x) { 1725 void TestSmiNot(MacroAssembler* masm, Label* exit, int id, int x) {
1726 int result = ~x; 1726 int result = ~x;
1727 __ movl(rax, Immediate(id)); 1727 __ movl(rax, Immediate(id));
1728 1728
1729 __ Move(r8, Smi::FromInt(result)); 1729 __ Move(r8, Smi::FromInt(result));
1730 __ Move(rcx, Smi::FromInt(x)); 1730 __ Move(rcx, Smi::FromInt(x));
1731 __ movq(r11, rcx); 1731 __ movq(r11, rcx);
1732 1732
1733 __ SmiNot(r9, rcx); 1733 __ SmiNot(r9, rcx);
1734 __ SmiCompare(r9, r8); 1734 __ cmpq(r9, r8);
1735 __ j(not_equal, exit); 1735 __ j(not_equal, exit);
1736 1736
1737 __ incq(rax); 1737 __ incq(rax);
1738 __ SmiCompare(r11, rcx); 1738 __ cmpq(r11, rcx);
1739 __ j(not_equal, exit); 1739 __ j(not_equal, exit);
1740 1740
1741 __ incq(rax); 1741 __ incq(rax);
1742 __ SmiNot(rcx, rcx); 1742 __ SmiNot(rcx, rcx);
1743 __ SmiCompare(rcx, r8); 1743 __ cmpq(rcx, r8);
1744 __ j(not_equal, exit); 1744 __ j(not_equal, exit);
1745 } 1745 }
1746 1746
1747 1747
1748 TEST(SmiNot) { 1748 TEST(SmiNot) {
1749 // Allocate an executable page of memory. 1749 // Allocate an executable page of memory.
1750 size_t actual_size; 1750 size_t actual_size;
1751 byte* buffer = 1751 byte* buffer =
1752 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, 1752 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize,
1753 &actual_size, 1753 &actual_size,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1790 for (int i = 0; i < kNumShifts; i++) { 1790 for (int i = 0; i < kNumShifts; i++) {
1791 // rax == id + i * 10. 1791 // rax == id + i * 10.
1792 int shift = shifts[i]; 1792 int shift = shifts[i];
1793 int result = x << shift; 1793 int result = x << shift;
1794 CHECK(Smi::IsValid(result)); 1794 CHECK(Smi::IsValid(result));
1795 __ Move(r8, Smi::FromInt(result)); 1795 __ Move(r8, Smi::FromInt(result));
1796 __ Move(rcx, Smi::FromInt(x)); 1796 __ Move(rcx, Smi::FromInt(x));
1797 __ SmiShiftLeftConstant(r9, rcx, shift); 1797 __ SmiShiftLeftConstant(r9, rcx, shift);
1798 1798
1799 __ incq(rax); 1799 __ incq(rax);
1800 __ SmiCompare(r9, r8); 1800 __ cmpq(r9, r8);
1801 __ j(not_equal, exit); 1801 __ j(not_equal, exit);
1802 1802
1803 __ incq(rax); 1803 __ incq(rax);
1804 __ Move(rcx, Smi::FromInt(x)); 1804 __ Move(rcx, Smi::FromInt(x));
1805 __ SmiShiftLeftConstant(rcx, rcx, shift); 1805 __ SmiShiftLeftConstant(rcx, rcx, shift);
1806 1806
1807 __ incq(rax); 1807 __ incq(rax);
1808 __ SmiCompare(rcx, r8); 1808 __ cmpq(rcx, r8);
1809 __ j(not_equal, exit); 1809 __ j(not_equal, exit);
1810 1810
1811 __ incq(rax); 1811 __ incq(rax);
1812 __ Move(rdx, Smi::FromInt(x)); 1812 __ Move(rdx, Smi::FromInt(x));
1813 __ Move(rcx, Smi::FromInt(shift)); 1813 __ Move(rcx, Smi::FromInt(shift));
1814 __ SmiShiftLeft(r9, rdx, rcx); 1814 __ SmiShiftLeft(r9, rdx, rcx);
1815 1815
1816 __ incq(rax); 1816 __ incq(rax);
1817 __ SmiCompare(r9, r8); 1817 __ cmpq(r9, r8);
1818 __ j(not_equal, exit); 1818 __ j(not_equal, exit);
1819 1819
1820 __ incq(rax); 1820 __ incq(rax);
1821 __ Move(rdx, Smi::FromInt(x)); 1821 __ Move(rdx, Smi::FromInt(x));
1822 __ Move(r11, Smi::FromInt(shift)); 1822 __ Move(r11, Smi::FromInt(shift));
1823 __ SmiShiftLeft(r9, rdx, r11); 1823 __ SmiShiftLeft(r9, rdx, r11);
1824 1824
1825 __ incq(rax); 1825 __ incq(rax);
1826 __ SmiCompare(r9, r8); 1826 __ cmpq(r9, r8);
1827 __ j(not_equal, exit); 1827 __ j(not_equal, exit);
1828 1828
1829 __ incq(rax); 1829 __ incq(rax);
1830 __ Move(rdx, Smi::FromInt(x)); 1830 __ Move(rdx, Smi::FromInt(x));
1831 __ Move(r11, Smi::FromInt(shift)); 1831 __ Move(r11, Smi::FromInt(shift));
1832 __ SmiShiftLeft(rdx, rdx, r11); 1832 __ SmiShiftLeft(rdx, rdx, r11);
1833 1833
1834 __ incq(rax); 1834 __ incq(rax);
1835 __ SmiCompare(rdx, r8); 1835 __ cmpq(rdx, r8);
1836 __ j(not_equal, exit); 1836 __ j(not_equal, exit);
1837 1837
1838 __ incq(rax); 1838 __ incq(rax);
1839 } 1839 }
1840 } 1840 }
1841 1841
1842 1842
1843 TEST(SmiShiftLeft) { 1843 TEST(SmiShiftLeft) {
1844 // Allocate an executable page of memory. 1844 // Allocate an executable page of memory.
1845 size_t actual_size; 1845 size_t actual_size;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1886 __ movl(rax, Immediate(id)); 1886 __ movl(rax, Immediate(id));
1887 for (int i = 0; i < kNumShifts; i++) { 1887 for (int i = 0; i < kNumShifts; i++) {
1888 int shift = shifts[i]; 1888 int shift = shifts[i];
1889 intptr_t result = static_cast<unsigned int>(x) >> shift; 1889 intptr_t result = static_cast<unsigned int>(x) >> shift;
1890 if (Smi::IsValid(result)) { 1890 if (Smi::IsValid(result)) {
1891 __ Move(r8, Smi::FromInt(static_cast<int>(result))); 1891 __ Move(r8, Smi::FromInt(static_cast<int>(result)));
1892 __ Move(rcx, Smi::FromInt(x)); 1892 __ Move(rcx, Smi::FromInt(x));
1893 __ SmiShiftLogicalRightConstant(r9, rcx, shift, exit); 1893 __ SmiShiftLogicalRightConstant(r9, rcx, shift, exit);
1894 1894
1895 __ incq(rax); 1895 __ incq(rax);
1896 __ SmiCompare(r9, r8); 1896 __ cmpq(r9, r8);
1897 __ j(not_equal, exit); 1897 __ j(not_equal, exit);
1898 1898
1899 __ incq(rax); 1899 __ incq(rax);
1900 __ Move(rdx, Smi::FromInt(x)); 1900 __ Move(rdx, Smi::FromInt(x));
1901 __ Move(rcx, Smi::FromInt(shift)); 1901 __ Move(rcx, Smi::FromInt(shift));
1902 __ SmiShiftLogicalRight(r9, rdx, rcx, exit); 1902 __ SmiShiftLogicalRight(r9, rdx, rcx, exit);
1903 1903
1904 __ incq(rax); 1904 __ incq(rax);
1905 __ SmiCompare(r9, r8); 1905 __ cmpq(r9, r8);
1906 __ j(not_equal, exit); 1906 __ j(not_equal, exit);
1907 1907
1908 __ incq(rax); 1908 __ incq(rax);
1909 __ Move(rdx, Smi::FromInt(x)); 1909 __ Move(rdx, Smi::FromInt(x));
1910 __ Move(r11, Smi::FromInt(shift)); 1910 __ Move(r11, Smi::FromInt(shift));
1911 __ SmiShiftLogicalRight(r9, rdx, r11, exit); 1911 __ SmiShiftLogicalRight(r9, rdx, r11, exit);
1912 1912
1913 __ incq(rax); 1913 __ incq(rax);
1914 __ SmiCompare(r9, r8); 1914 __ cmpq(r9, r8);
1915 __ j(not_equal, exit); 1915 __ j(not_equal, exit);
1916 1916
1917 __ incq(rax); 1917 __ incq(rax);
1918 } else { 1918 } else {
1919 // Cannot happen with long smis. 1919 // Cannot happen with long smis.
1920 Label fail_ok; 1920 Label fail_ok;
1921 __ Move(rcx, Smi::FromInt(x)); 1921 __ Move(rcx, Smi::FromInt(x));
1922 __ movq(r11, rcx); 1922 __ movq(r11, rcx);
1923 __ SmiShiftLogicalRightConstant(r9, rcx, shift, &fail_ok); 1923 __ SmiShiftLogicalRightConstant(r9, rcx, shift, &fail_ok);
1924 __ jmp(exit); 1924 __ jmp(exit);
1925 __ bind(&fail_ok); 1925 __ bind(&fail_ok);
1926 1926
1927 __ incq(rax); 1927 __ incq(rax);
1928 __ SmiCompare(rcx, r11); 1928 __ cmpq(rcx, r11);
1929 __ j(not_equal, exit); 1929 __ j(not_equal, exit);
1930 1930
1931 __ incq(rax); 1931 __ incq(rax);
1932 __ Move(r8, Smi::FromInt(shift)); 1932 __ Move(r8, Smi::FromInt(shift));
1933 Label fail_ok3; 1933 Label fail_ok3;
1934 __ SmiShiftLogicalRight(r9, rcx, r8, &fail_ok3); 1934 __ SmiShiftLogicalRight(r9, rcx, r8, &fail_ok3);
1935 __ jmp(exit); 1935 __ jmp(exit);
1936 __ bind(&fail_ok3); 1936 __ bind(&fail_ok3);
1937 1937
1938 __ incq(rax); 1938 __ incq(rax);
1939 __ SmiCompare(rcx, r11); 1939 __ cmpq(rcx, r11);
1940 __ j(not_equal, exit); 1940 __ j(not_equal, exit);
1941 1941
1942 __ addq(rax, Immediate(3)); 1942 __ addq(rax, Immediate(3));
1943 } 1943 }
1944 } 1944 }
1945 } 1945 }
1946 1946
1947 1947
1948 TEST(SmiShiftLogicalRight) { 1948 TEST(SmiShiftLogicalRight) {
1949 // Allocate an executable page of memory. 1949 // Allocate an executable page of memory.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1990 const int kNumShifts = 5; 1990 const int kNumShifts = 5;
1991 __ movl(rax, Immediate(id)); 1991 __ movl(rax, Immediate(id));
1992 for (int i = 0; i < kNumShifts; i++) { 1992 for (int i = 0; i < kNumShifts; i++) {
1993 int shift = shifts[i]; 1993 int shift = shifts[i];
1994 // Guaranteed arithmetic shift. 1994 // Guaranteed arithmetic shift.
1995 int result = (x < 0) ? ~((~x) >> shift) : (x >> shift); 1995 int result = (x < 0) ? ~((~x) >> shift) : (x >> shift);
1996 __ Move(r8, Smi::FromInt(result)); 1996 __ Move(r8, Smi::FromInt(result));
1997 __ Move(rcx, Smi::FromInt(x)); 1997 __ Move(rcx, Smi::FromInt(x));
1998 __ SmiShiftArithmeticRightConstant(rcx, rcx, shift); 1998 __ SmiShiftArithmeticRightConstant(rcx, rcx, shift);
1999 1999
2000 __ SmiCompare(rcx, r8); 2000 __ cmpq(rcx, r8);
2001 __ j(not_equal, exit); 2001 __ j(not_equal, exit);
2002 2002
2003 __ incq(rax); 2003 __ incq(rax);
2004 __ Move(rdx, Smi::FromInt(x)); 2004 __ Move(rdx, Smi::FromInt(x));
2005 __ Move(r11, Smi::FromInt(shift)); 2005 __ Move(r11, Smi::FromInt(shift));
2006 __ SmiShiftArithmeticRight(rdx, rdx, r11); 2006 __ SmiShiftArithmeticRight(rdx, rdx, r11);
2007 2007
2008 __ SmiCompare(rdx, r8); 2008 __ cmpq(rdx, r8);
2009 __ j(not_equal, exit); 2009 __ j(not_equal, exit);
2010 2010
2011 __ incq(rax); 2011 __ incq(rax);
2012 } 2012 }
2013 } 2013 }
2014 2014
2015 2015
2016 TEST(SmiShiftArithmeticRight) { 2016 TEST(SmiShiftArithmeticRight) {
2017 // Allocate an executable page of memory. 2017 // Allocate an executable page of memory.
2018 size_t actual_size; 2018 size_t actual_size;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2055 int powers[] = { 0, 1, 2, 3, 8, 16, 24, 31 }; 2055 int powers[] = { 0, 1, 2, 3, 8, 16, 24, 31 };
2056 int power_count = 8; 2056 int power_count = 8;
2057 __ movl(rax, Immediate(id)); 2057 __ movl(rax, Immediate(id));
2058 for (int i = 0; i < power_count; i++) { 2058 for (int i = 0; i < power_count; i++) {
2059 int power = powers[i]; 2059 int power = powers[i];
2060 intptr_t result = static_cast<intptr_t>(x) << power; 2060 intptr_t result = static_cast<intptr_t>(x) << power;
2061 __ Set(r8, result); 2061 __ Set(r8, result);
2062 __ Move(rcx, Smi::FromInt(x)); 2062 __ Move(rcx, Smi::FromInt(x));
2063 __ movq(r11, rcx); 2063 __ movq(r11, rcx);
2064 __ PositiveSmiTimesPowerOfTwoToInteger64(rdx, rcx, power); 2064 __ PositiveSmiTimesPowerOfTwoToInteger64(rdx, rcx, power);
2065 __ SmiCompare(rdx, r8); 2065 __ cmpq(rdx, r8);
2066 __ j(not_equal, exit); 2066 __ j(not_equal, exit);
2067 __ incq(rax); 2067 __ incq(rax);
2068 __ SmiCompare(r11, rcx); // rcx unchanged. 2068 __ cmpq(r11, rcx); // rcx unchanged.
2069 __ j(not_equal, exit); 2069 __ j(not_equal, exit);
2070 __ incq(rax); 2070 __ incq(rax);
2071 __ PositiveSmiTimesPowerOfTwoToInteger64(rcx, rcx, power); 2071 __ PositiveSmiTimesPowerOfTwoToInteger64(rcx, rcx, power);
2072 __ SmiCompare(rdx, r8); 2072 __ cmpq(rdx, r8);
2073 __ j(not_equal, exit); 2073 __ j(not_equal, exit);
2074 __ incq(rax); 2074 __ incq(rax);
2075 } 2075 }
2076 } 2076 }
2077 2077
2078 2078
2079 TEST(PositiveSmiTimesPowerOfTwoToInteger64) { 2079 TEST(PositiveSmiTimesPowerOfTwoToInteger64) {
2080 // Allocate an executable page of memory. 2080 // Allocate an executable page of memory.
2081 size_t actual_size; 2081 size_t actual_size;
2082 byte* buffer = 2082 byte* buffer =
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
2465 CodeDesc desc; 2465 CodeDesc desc;
2466 masm->GetCode(&desc); 2466 masm->GetCode(&desc);
2467 // Call the function from C++. 2467 // Call the function from C++.
2468 int result = FUNCTION_CAST<F0>(buffer)(); 2468 int result = FUNCTION_CAST<F0>(buffer)();
2469 CHECK_EQ(0, result); 2469 CHECK_EQ(0, result);
2470 } 2470 }
2471 2471
2472 2472
2473 2473
2474 #undef __ 2474 #undef __
OLDNEW
« src/x64/macro-assembler-x64.cc ('K') | « src/x64/macro-assembler-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698