OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. |
6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
7 | 7 |
8 #include "vm/intrinsifier.h" | 8 #include "vm/intrinsifier.h" |
9 | 9 |
10 #include "vm/assembler.h" | 10 #include "vm/assembler.h" |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 __ orq(RCX, RAX); | 482 __ orq(RCX, RAX); |
483 __ testq(RCX, Immediate(kSmiTagMask)); | 483 __ testq(RCX, Immediate(kSmiTagMask)); |
484 __ j(NOT_ZERO, not_smi, Assembler::kNearJump); | 484 __ j(NOT_ZERO, not_smi, Assembler::kNearJump); |
485 } | 485 } |
486 | 486 |
487 | 487 |
488 bool Intrinsifier::Integer_addFromInteger(Assembler* assembler) { | 488 bool Intrinsifier::Integer_addFromInteger(Assembler* assembler) { |
489 Label fall_through; | 489 Label fall_through; |
490 TestBothArgumentsSmis(assembler, &fall_through); | 490 TestBothArgumentsSmis(assembler, &fall_through); |
491 // RAX contains right argument. | 491 // RAX contains right argument. |
492 __ movq(RCX, Address(RSP, + 2 * kWordSize)); | 492 __ addq(RAX, Address(RSP, + 2 * kWordSize)); |
493 __ addq(RAX, RCX); | |
494 __ j(OVERFLOW, &fall_through, Assembler::kNearJump); | 493 __ j(OVERFLOW, &fall_through, Assembler::kNearJump); |
495 // Result is in RAX. | 494 // Result is in RAX. |
496 __ ret(); | 495 __ ret(); |
497 __ Bind(&fall_through); | 496 __ Bind(&fall_through); |
498 return false; | 497 return false; |
499 } | 498 } |
500 | 499 |
501 | 500 |
502 bool Intrinsifier::Integer_add(Assembler* assembler) { | 501 bool Intrinsifier::Integer_add(Assembler* assembler) { |
503 return Integer_addFromInteger(assembler); | 502 return Integer_addFromInteger(assembler); |
(...skipping 28 matching lines...) Expand all Loading... |
532 } | 531 } |
533 | 532 |
534 | 533 |
535 | 534 |
536 bool Intrinsifier::Integer_mulFromInteger(Assembler* assembler) { | 535 bool Intrinsifier::Integer_mulFromInteger(Assembler* assembler) { |
537 Label fall_through; | 536 Label fall_through; |
538 TestBothArgumentsSmis(assembler, &fall_through); | 537 TestBothArgumentsSmis(assembler, &fall_through); |
539 // RAX is the right argument. | 538 // RAX is the right argument. |
540 ASSERT(kSmiTag == 0); // Adjust code below if not the case. | 539 ASSERT(kSmiTag == 0); // Adjust code below if not the case. |
541 __ SmiUntag(RAX); | 540 __ SmiUntag(RAX); |
542 __ movq(RCX, Address(RSP, + 2 * kWordSize)); | 541 __ imulq(RAX, Address(RSP, + 2 * kWordSize)); |
543 __ imulq(RAX, RCX); | |
544 __ j(OVERFLOW, &fall_through, Assembler::kNearJump); | 542 __ j(OVERFLOW, &fall_through, Assembler::kNearJump); |
545 // Result is in RAX. | 543 // Result is in RAX. |
546 __ ret(); | 544 __ ret(); |
547 __ Bind(&fall_through); | 545 __ Bind(&fall_through); |
548 return false; | 546 return false; |
549 } | 547 } |
550 | 548 |
551 | 549 |
552 bool Intrinsifier::Integer_mul(Assembler* assembler) { | 550 bool Intrinsifier::Integer_mul(Assembler* assembler) { |
553 return Integer_mulFromInteger(assembler); | 551 return Integer_mulFromInteger(assembler); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 __ ret(); | 622 __ ret(); |
625 __ Bind(&fall_through); | 623 __ Bind(&fall_through); |
626 return false; | 624 return false; |
627 } | 625 } |
628 | 626 |
629 | 627 |
630 bool Intrinsifier::Integer_bitAndFromInteger(Assembler* assembler) { | 628 bool Intrinsifier::Integer_bitAndFromInteger(Assembler* assembler) { |
631 Label fall_through; | 629 Label fall_through; |
632 TestBothArgumentsSmis(assembler, &fall_through); | 630 TestBothArgumentsSmis(assembler, &fall_through); |
633 // RAX is the right argument. | 631 // RAX is the right argument. |
634 __ movq(RCX, Address(RSP, + 2 * kWordSize)); | 632 __ andq(RAX, Address(RSP, + 2 * kWordSize)); |
635 __ andq(RAX, RCX); | |
636 // Result is in RAX. | 633 // Result is in RAX. |
637 __ ret(); | 634 __ ret(); |
638 __ Bind(&fall_through); | 635 __ Bind(&fall_through); |
639 return false; | 636 return false; |
640 } | 637 } |
641 | 638 |
642 | 639 |
643 bool Intrinsifier::Integer_bitAnd(Assembler* assembler) { | 640 bool Intrinsifier::Integer_bitAnd(Assembler* assembler) { |
644 return Integer_bitAndFromInteger(assembler); | 641 return Integer_bitAndFromInteger(assembler); |
645 } | 642 } |
646 | 643 |
647 | 644 |
648 bool Intrinsifier::Integer_bitOrFromInteger(Assembler* assembler) { | 645 bool Intrinsifier::Integer_bitOrFromInteger(Assembler* assembler) { |
649 Label fall_through; | 646 Label fall_through; |
650 TestBothArgumentsSmis(assembler, &fall_through); | 647 TestBothArgumentsSmis(assembler, &fall_through); |
651 // RAX is the right argument. | 648 // RAX is the right argument. |
652 __ movq(RCX, Address(RSP, + 2 * kWordSize)); | 649 __ orq(RAX, Address(RSP, + 2 * kWordSize)); |
653 __ orq(RAX, RCX); | |
654 // Result is in RAX. | 650 // Result is in RAX. |
655 __ ret(); | 651 __ ret(); |
656 __ Bind(&fall_through); | 652 __ Bind(&fall_through); |
657 return false; | 653 return false; |
658 } | 654 } |
659 | 655 |
660 | 656 |
661 bool Intrinsifier::Integer_bitOr(Assembler* assembler) { | 657 bool Intrinsifier::Integer_bitOr(Assembler* assembler) { |
662 return Integer_bitOrFromInteger(assembler); | 658 return Integer_bitOrFromInteger(assembler); |
663 } | 659 } |
664 | 660 |
665 | 661 |
666 bool Intrinsifier::Integer_bitXorFromInteger(Assembler* assembler) { | 662 bool Intrinsifier::Integer_bitXorFromInteger(Assembler* assembler) { |
667 Label fall_through; | 663 Label fall_through; |
668 TestBothArgumentsSmis(assembler, &fall_through); | 664 TestBothArgumentsSmis(assembler, &fall_through); |
669 // RAX is the right argument. | 665 // RAX is the right argument. |
670 __ movq(RCX, Address(RSP, + 2 * kWordSize)); | 666 __ xorq(RAX, Address(RSP, + 2 * kWordSize)); |
671 __ xorq(RAX, RCX); | |
672 // Result is in RAX. | 667 // Result is in RAX. |
673 __ ret(); | 668 __ ret(); |
674 __ Bind(&fall_through); | 669 __ Bind(&fall_through); |
675 return false; | 670 return false; |
676 } | 671 } |
677 | 672 |
678 | 673 |
679 bool Intrinsifier::Integer_bitXor(Assembler* assembler) { | 674 bool Intrinsifier::Integer_bitXor(Assembler* assembler) { |
680 return Integer_bitXorFromInteger(assembler); | 675 return Integer_bitXorFromInteger(assembler); |
681 } | 676 } |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1119 __ LoadObject(RAX, bool_true); | 1114 __ LoadObject(RAX, bool_true); |
1120 __ ret(); | 1115 __ ret(); |
1121 return true; | 1116 return true; |
1122 } | 1117 } |
1123 | 1118 |
1124 #undef __ | 1119 #undef __ |
1125 | 1120 |
1126 } // namespace dart | 1121 } // namespace dart |
1127 | 1122 |
1128 #endif // defined TARGET_ARCH_X64 | 1123 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |