OLD | NEW |
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 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
751 } | 751 } |
752 | 752 |
753 | 753 |
754 | 754 |
755 | 755 |
756 static void SmiAddTest(MacroAssembler* masm, | 756 static void SmiAddTest(MacroAssembler* masm, |
757 Label* exit, | 757 Label* exit, |
758 int id, | 758 int id, |
759 int first, | 759 int first, |
760 int second) { | 760 int second) { |
| 761 MacroAssembler::StrictSmiInstructionWrapper wrapper(masm, exit); |
761 __ movl(rcx, Immediate(first)); | 762 __ movl(rcx, Immediate(first)); |
762 __ Integer32ToSmi(rcx, rcx); | 763 __ Integer32ToSmi(rcx, rcx); |
763 __ movl(rdx, Immediate(second)); | 764 __ movl(rdx, Immediate(second)); |
764 __ Integer32ToSmi(rdx, rdx); | 765 __ Integer32ToSmi(rdx, rdx); |
765 __ movl(r8, Immediate(first + second)); | 766 __ movl(r8, Immediate(first + second)); |
766 __ Integer32ToSmi(r8, r8); | 767 __ Integer32ToSmi(r8, r8); |
767 | 768 |
768 __ movl(rax, Immediate(id)); // Test number. | 769 __ movl(rax, Immediate(id)); // Test number. |
769 __ SmiAdd(r9, rcx, rdx, exit); | 770 __ SmiAdd(r9, rcx, rdx, wrapper); |
770 __ cmpq(r9, r8); | 771 __ cmpq(r9, r8); |
771 __ j(not_equal, exit); | 772 __ j(not_equal, exit); |
772 | 773 |
773 __ incq(rax); | 774 __ incq(rax); |
774 __ SmiAdd(rcx, rcx, rdx, exit); \ | 775 __ SmiAdd(rcx, rcx, rdx, wrapper); |
775 __ cmpq(rcx, r8); | 776 __ cmpq(rcx, r8); |
776 __ j(not_equal, exit); | 777 __ j(not_equal, exit); |
777 | 778 |
778 __ movl(rcx, Immediate(first)); | 779 __ movl(rcx, Immediate(first)); |
779 __ Integer32ToSmi(rcx, rcx); | 780 __ Integer32ToSmi(rcx, rcx); |
780 | 781 |
781 __ incq(rax); | 782 __ incq(rax); |
782 __ SmiAddConstant(r9, rcx, Smi::FromInt(second)); | 783 __ SmiAddConstant(r9, rcx, Smi::FromInt(second)); |
783 __ cmpq(r9, r8); | 784 __ cmpq(r9, r8); |
784 __ j(not_equal, exit); | 785 __ j(not_equal, exit); |
785 | 786 |
786 __ SmiAddConstant(rcx, rcx, Smi::FromInt(second)); | 787 __ SmiAddConstant(rcx, rcx, Smi::FromInt(second)); |
787 __ cmpq(rcx, r8); | 788 __ cmpq(rcx, r8); |
788 __ j(not_equal, exit); | 789 __ j(not_equal, exit); |
789 | 790 |
790 __ movl(rcx, Immediate(first)); | 791 __ movl(rcx, Immediate(first)); |
791 __ Integer32ToSmi(rcx, rcx); | 792 __ Integer32ToSmi(rcx, rcx); |
792 | 793 |
793 __ incq(rax); | 794 __ incq(rax); |
794 __ SmiAddConstant(r9, rcx, Smi::FromInt(second), exit); | 795 __ SmiAddConstant(r9, rcx, Smi::FromInt(second), wrapper); |
795 __ cmpq(r9, r8); | 796 __ cmpq(r9, r8); |
796 __ j(not_equal, exit); | 797 __ j(not_equal, exit); |
797 | 798 |
798 __ incq(rax); | 799 __ incq(rax); |
799 __ SmiAddConstant(rcx, rcx, Smi::FromInt(second), exit); | 800 __ SmiAddConstant(rcx, rcx, Smi::FromInt(second), wrapper); |
800 __ cmpq(rcx, r8); | 801 __ cmpq(rcx, r8); |
801 __ j(not_equal, exit); | 802 __ j(not_equal, exit); |
802 } | 803 } |
803 | 804 |
804 | 805 |
805 TEST(SmiAdd) { | 806 TEST(SmiAdd) { |
806 v8::internal::V8::Initialize(NULL); | 807 v8::internal::V8::Initialize(NULL); |
807 // Allocate an executable page of memory. | 808 // Allocate an executable page of memory. |
808 size_t actual_size; | 809 size_t actual_size; |
809 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 810 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
(...skipping 30 matching lines...) Expand all Loading... |
840 int result = FUNCTION_CAST<F0>(buffer)(); | 841 int result = FUNCTION_CAST<F0>(buffer)(); |
841 CHECK_EQ(0, result); | 842 CHECK_EQ(0, result); |
842 } | 843 } |
843 | 844 |
844 | 845 |
845 static void SmiSubTest(MacroAssembler* masm, | 846 static void SmiSubTest(MacroAssembler* masm, |
846 Label* exit, | 847 Label* exit, |
847 int id, | 848 int id, |
848 int first, | 849 int first, |
849 int second) { | 850 int second) { |
| 851 MacroAssembler::StrictSmiInstructionWrapper wrapper(masm, exit); |
850 __ Move(rcx, Smi::FromInt(first)); | 852 __ Move(rcx, Smi::FromInt(first)); |
851 __ Move(rdx, Smi::FromInt(second)); | 853 __ Move(rdx, Smi::FromInt(second)); |
852 __ Move(r8, Smi::FromInt(first - second)); | 854 __ Move(r8, Smi::FromInt(first - second)); |
853 | 855 |
854 __ movl(rax, Immediate(id)); // Test 0. | 856 __ movl(rax, Immediate(id)); // Test 0. |
855 __ SmiSub(r9, rcx, rdx, exit); | 857 __ SmiSub(r9, rcx, rdx, wrapper); |
856 __ cmpq(r9, r8); | 858 __ cmpq(r9, r8); |
857 __ j(not_equal, exit); | 859 __ j(not_equal, exit); |
858 | 860 |
859 __ incq(rax); // Test 1. | 861 __ incq(rax); // Test 1. |
860 __ SmiSub(rcx, rcx, rdx, exit); | 862 __ SmiSub(rcx, rcx, rdx, wrapper); |
861 __ cmpq(rcx, r8); | 863 __ cmpq(rcx, r8); |
862 __ j(not_equal, exit); | 864 __ j(not_equal, exit); |
863 | 865 |
864 __ Move(rcx, Smi::FromInt(first)); | 866 __ Move(rcx, Smi::FromInt(first)); |
865 | 867 |
866 __ incq(rax); // Test 2. | 868 __ incq(rax); // Test 2. |
867 __ SmiSubConstant(r9, rcx, Smi::FromInt(second)); | 869 __ SmiSubConstant(r9, rcx, Smi::FromInt(second)); |
868 __ cmpq(r9, r8); | 870 __ cmpq(r9, r8); |
869 __ j(not_equal, exit); | 871 __ j(not_equal, exit); |
870 | 872 |
871 __ incq(rax); // Test 3. | 873 __ incq(rax); // Test 3. |
872 __ SmiSubConstant(rcx, rcx, Smi::FromInt(second)); | 874 __ SmiSubConstant(rcx, rcx, Smi::FromInt(second)); |
873 __ cmpq(rcx, r8); | 875 __ cmpq(rcx, r8); |
874 __ j(not_equal, exit); | 876 __ j(not_equal, exit); |
875 | 877 |
876 __ Move(rcx, Smi::FromInt(first)); | 878 __ Move(rcx, Smi::FromInt(first)); |
877 | 879 |
878 __ incq(rax); // Test 4. | 880 __ incq(rax); // Test 4. |
879 __ SmiSubConstant(r9, rcx, Smi::FromInt(second), exit); | 881 __ SmiSubConstant(r9, rcx, Smi::FromInt(second), wrapper); |
880 __ cmpq(r9, r8); | 882 __ cmpq(r9, r8); |
881 __ j(not_equal, exit); | 883 __ j(not_equal, exit); |
882 | 884 |
883 __ incq(rax); // Test 5. | 885 __ incq(rax); // Test 5. |
884 __ SmiSubConstant(rcx, rcx, Smi::FromInt(second), exit); | 886 __ SmiSubConstant(rcx, rcx, Smi::FromInt(second), wrapper); |
885 __ cmpq(rcx, r8); | 887 __ cmpq(rcx, r8); |
886 __ j(not_equal, exit); | 888 __ j(not_equal, exit); |
887 } | 889 } |
888 | 890 |
| 891 |
889 static void SmiSubOverflowTest(MacroAssembler* masm, | 892 static void SmiSubOverflowTest(MacroAssembler* masm, |
890 Label* exit, | 893 Label* exit, |
891 int id, | 894 int id, |
892 int x) { | 895 int x) { |
893 // Subtracts a Smi from x so that the subtraction overflows. | 896 // Subtracts a Smi from x so that the subtraction overflows. |
894 ASSERT(x != -1); // Can't overflow by subtracting a Smi. | 897 ASSERT(x != -1); // Can't overflow by subtracting a Smi. |
895 int y_max = (x < 0) ? (Smi::kMaxValue + 0) : (Smi::kMinValue + 0); | 898 int y_max = (x < 0) ? (Smi::kMaxValue + 0) : (Smi::kMinValue + 0); |
896 int y_min = (x < 0) ? (Smi::kMaxValue + x + 2) : (Smi::kMinValue + x); | 899 int y_min = (x < 0) ? (Smi::kMaxValue + x + 2) : (Smi::kMinValue + x); |
897 | 900 |
898 __ movl(rax, Immediate(id)); | 901 __ movl(rax, Immediate(id)); |
899 __ Move(rcx, Smi::FromInt(x)); | 902 __ Move(rcx, Smi::FromInt(x)); |
900 __ movq(r11, rcx); // Store original Smi value of x in r11. | 903 __ movq(r11, rcx); // Store original Smi value of x in r11. |
901 __ Move(rdx, Smi::FromInt(y_min)); | 904 __ Move(rdx, Smi::FromInt(y_min)); |
902 { | 905 { |
903 Label overflow_ok; | 906 Label overflow_ok; |
904 __ SmiSub(r9, rcx, rdx, &overflow_ok); | 907 MacroAssembler::StrictSmiInstructionWrapper wrapper(masm, &overflow_ok); |
| 908 __ SmiSub(r9, rcx, rdx, wrapper); |
905 __ jmp(exit); | 909 __ jmp(exit); |
906 __ bind(&overflow_ok); | 910 __ bind(&overflow_ok); |
907 __ incq(rax); | 911 __ incq(rax); |
908 __ cmpq(rcx, r11); | 912 __ cmpq(rcx, r11); |
909 __ j(not_equal, exit); | 913 __ j(not_equal, exit); |
910 } | 914 } |
911 | 915 |
912 { | 916 { |
913 Label overflow_ok; | 917 Label overflow_ok; |
| 918 MacroAssembler::StrictSmiInstructionWrapper wrapper(masm, &overflow_ok); |
914 __ incq(rax); | 919 __ incq(rax); |
915 __ SmiSub(rcx, rcx, rdx, &overflow_ok); | 920 __ SmiSub(rcx, rcx, rdx, wrapper); |
916 __ jmp(exit); | 921 __ jmp(exit); |
917 __ bind(&overflow_ok); | 922 __ bind(&overflow_ok); |
918 __ incq(rax); | 923 __ incq(rax); |
919 __ cmpq(rcx, r11); | 924 __ cmpq(rcx, r11); |
920 __ j(not_equal, exit); | 925 __ j(not_equal, exit); |
921 } | 926 } |
922 | 927 |
923 __ movq(rcx, r11); | 928 __ movq(rcx, r11); |
924 { | 929 { |
925 Label overflow_ok; | 930 Label overflow_ok; |
| 931 MacroAssembler::StrictSmiInstructionWrapper wrapper(masm, &overflow_ok); |
926 __ incq(rax); | 932 __ incq(rax); |
927 __ SmiSubConstant(r9, rcx, Smi::FromInt(y_min), &overflow_ok); | 933 __ SmiSubConstant(r9, rcx, Smi::FromInt(y_min), wrapper); |
928 __ jmp(exit); | 934 __ jmp(exit); |
929 __ bind(&overflow_ok); | 935 __ bind(&overflow_ok); |
930 __ incq(rax); | 936 __ incq(rax); |
931 __ cmpq(rcx, r11); | 937 __ cmpq(rcx, r11); |
932 __ j(not_equal, exit); | 938 __ j(not_equal, exit); |
933 } | 939 } |
934 | 940 |
935 { | 941 { |
936 Label overflow_ok; | 942 Label overflow_ok; |
| 943 MacroAssembler::StrictSmiInstructionWrapper wrapper(masm, &overflow_ok); |
937 __ incq(rax); | 944 __ incq(rax); |
938 __ SmiSubConstant(rcx, rcx, Smi::FromInt(y_min), &overflow_ok); | 945 __ SmiSubConstant(rcx, rcx, Smi::FromInt(y_min), wrapper); |
939 __ jmp(exit); | 946 __ jmp(exit); |
940 __ bind(&overflow_ok); | 947 __ bind(&overflow_ok); |
941 __ incq(rax); | 948 __ incq(rax); |
942 __ cmpq(rcx, r11); | 949 __ cmpq(rcx, r11); |
943 __ j(not_equal, exit); | 950 __ j(not_equal, exit); |
944 } | 951 } |
945 | 952 |
946 __ Move(rdx, Smi::FromInt(y_max)); | 953 __ Move(rdx, Smi::FromInt(y_max)); |
947 | 954 |
948 { | 955 { |
949 Label overflow_ok; | 956 Label overflow_ok; |
| 957 MacroAssembler::StrictSmiInstructionWrapper wrapper(masm, &overflow_ok); |
950 __ incq(rax); | 958 __ incq(rax); |
951 __ SmiSub(r9, rcx, rdx, &overflow_ok); | 959 __ SmiSub(r9, rcx, rdx, wrapper); |
952 __ jmp(exit); | 960 __ jmp(exit); |
953 __ bind(&overflow_ok); | 961 __ bind(&overflow_ok); |
954 __ incq(rax); | 962 __ incq(rax); |
955 __ cmpq(rcx, r11); | 963 __ cmpq(rcx, r11); |
956 __ j(not_equal, exit); | 964 __ j(not_equal, exit); |
957 } | 965 } |
958 | 966 |
959 { | 967 { |
960 Label overflow_ok; | 968 Label overflow_ok; |
| 969 MacroAssembler::StrictSmiInstructionWrapper wrapper(masm, &overflow_ok); |
961 __ incq(rax); | 970 __ incq(rax); |
962 __ SmiSub(rcx, rcx, rdx, &overflow_ok); | 971 __ SmiSub(rcx, rcx, rdx, wrapper); |
963 __ jmp(exit); | 972 __ jmp(exit); |
964 __ bind(&overflow_ok); | 973 __ bind(&overflow_ok); |
965 __ incq(rax); | 974 __ incq(rax); |
966 __ cmpq(rcx, r11); | 975 __ cmpq(rcx, r11); |
967 __ j(not_equal, exit); | 976 __ j(not_equal, exit); |
968 } | 977 } |
969 | 978 |
970 __ movq(rcx, r11); | 979 __ movq(rcx, r11); |
971 { | 980 { |
972 Label overflow_ok; | 981 Label overflow_ok; |
| 982 MacroAssembler::StrictSmiInstructionWrapper wrapper(masm, &overflow_ok); |
973 __ incq(rax); | 983 __ incq(rax); |
974 __ SmiSubConstant(r9, rcx, Smi::FromInt(y_max), &overflow_ok); | 984 __ SmiSubConstant(r9, rcx, Smi::FromInt(y_max), wrapper); |
975 __ jmp(exit); | 985 __ jmp(exit); |
976 __ bind(&overflow_ok); | 986 __ bind(&overflow_ok); |
977 __ incq(rax); | 987 __ incq(rax); |
978 __ cmpq(rcx, r11); | 988 __ cmpq(rcx, r11); |
979 __ j(not_equal, exit); | 989 __ j(not_equal, exit); |
980 } | 990 } |
981 | 991 |
982 { | 992 { |
983 Label overflow_ok; | 993 Label overflow_ok; |
| 994 MacroAssembler::StrictSmiInstructionWrapper wrapper(masm, &overflow_ok); |
984 __ incq(rax); | 995 __ incq(rax); |
985 __ SmiSubConstant(rcx, rcx, Smi::FromInt(y_max), &overflow_ok); | 996 __ SmiSubConstant(rcx, rcx, Smi::FromInt(y_max), wrapper); |
986 __ jmp(exit); | 997 __ jmp(exit); |
987 __ bind(&overflow_ok); | 998 __ bind(&overflow_ok); |
988 __ incq(rax); | 999 __ incq(rax); |
989 __ cmpq(rcx, r11); | 1000 __ cmpq(rcx, r11); |
990 __ j(not_equal, exit); | 1001 __ j(not_equal, exit); |
991 } | 1002 } |
992 } | 1003 } |
993 | 1004 |
994 | 1005 |
995 TEST(SmiSub) { | 1006 TEST(SmiSub) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1034 __ ret(0); | 1045 __ ret(0); |
1035 | 1046 |
1036 CodeDesc desc; | 1047 CodeDesc desc; |
1037 masm->GetCode(&desc); | 1048 masm->GetCode(&desc); |
1038 // Call the function from C++. | 1049 // Call the function from C++. |
1039 int result = FUNCTION_CAST<F0>(buffer)(); | 1050 int result = FUNCTION_CAST<F0>(buffer)(); |
1040 CHECK_EQ(0, result); | 1051 CHECK_EQ(0, result); |
1041 } | 1052 } |
1042 | 1053 |
1043 | 1054 |
1044 | |
1045 void TestSmiMul(MacroAssembler* masm, Label* exit, int id, int x, int y) { | 1055 void TestSmiMul(MacroAssembler* masm, Label* exit, int id, int x, int y) { |
1046 int64_t result = static_cast<int64_t>(x) * static_cast<int64_t>(y); | 1056 int64_t result = static_cast<int64_t>(x) * static_cast<int64_t>(y); |
1047 bool negative_zero = (result == 0) && (x < 0 || y < 0); | 1057 bool negative_zero = (result == 0) && (x < 0 || y < 0); |
1048 __ Move(rcx, Smi::FromInt(x)); | 1058 __ Move(rcx, Smi::FromInt(x)); |
1049 __ movq(r11, rcx); | 1059 __ movq(r11, rcx); |
1050 __ Move(rdx, Smi::FromInt(y)); | 1060 __ Move(rdx, Smi::FromInt(y)); |
1051 if (Smi::IsValid(result) && !negative_zero) { | 1061 if (Smi::IsValid(result) && !negative_zero) { |
1052 __ movl(rax, Immediate(id)); | 1062 __ movl(rax, Immediate(id)); |
1053 __ Move(r8, Smi::FromIntptr(result)); | 1063 __ Move(r8, Smi::FromIntptr(result)); |
1054 __ SmiMul(r9, rcx, rdx, exit); | 1064 __ SmiMul(r9, rcx, rdx, exit); |
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1820 // Call the function from C++. | 1830 // Call the function from C++. |
1821 int result = FUNCTION_CAST<F0>(buffer)(); | 1831 int result = FUNCTION_CAST<F0>(buffer)(); |
1822 CHECK_EQ(0, result); | 1832 CHECK_EQ(0, result); |
1823 } | 1833 } |
1824 | 1834 |
1825 | 1835 |
1826 void TestSmiShiftLeft(MacroAssembler* masm, Label* exit, int id, int x) { | 1836 void TestSmiShiftLeft(MacroAssembler* masm, Label* exit, int id, int x) { |
1827 const int shifts[] = { 0, 1, 7, 24, kSmiValueSize - 1}; | 1837 const int shifts[] = { 0, 1, 7, 24, kSmiValueSize - 1}; |
1828 const int kNumShifts = 5; | 1838 const int kNumShifts = 5; |
1829 __ movl(rax, Immediate(id)); | 1839 __ movl(rax, Immediate(id)); |
| 1840 MacroAssembler::StrictSmiInstructionWrapper wrapper(masm, exit); |
1830 for (int i = 0; i < kNumShifts; i++) { | 1841 for (int i = 0; i < kNumShifts; i++) { |
1831 // rax == id + i * 10. | 1842 // rax == id + i * 10. |
1832 int shift = shifts[i]; | 1843 int shift = shifts[i]; |
1833 int result = x << shift; | 1844 int result = x << shift; |
1834 CHECK(Smi::IsValid(result)); | 1845 if (Smi::IsValid(result)) { |
1835 __ Move(r8, Smi::FromInt(result)); | 1846 __ Move(r8, Smi::FromInt(result)); |
1836 __ Move(rcx, Smi::FromInt(x)); | 1847 __ Move(rcx, Smi::FromInt(x)); |
1837 __ SmiShiftLeftConstant(r9, rcx, shift); | 1848 __ SmiShiftLeftConstant(r9, rcx, shift, wrapper); |
1838 | 1849 |
1839 __ incq(rax); | 1850 __ incq(rax); |
1840 __ cmpq(r9, r8); | 1851 __ cmpq(r9, r8); |
1841 __ j(not_equal, exit); | 1852 __ j(not_equal, exit); |
1842 | 1853 |
1843 __ incq(rax); | 1854 __ incq(rax); |
1844 __ Move(rcx, Smi::FromInt(x)); | 1855 __ Move(rcx, Smi::FromInt(x)); |
1845 __ SmiShiftLeftConstant(rcx, rcx, shift); | 1856 if (kSmiValueSize == 32) { |
| 1857 __ SmiShiftLeftConstant(rcx, rcx, shift, wrapper); |
| 1858 } else { |
| 1859 ASSERT(kSmiValueSize == 31); |
| 1860 __ SmiShiftLeftConstant(r9, rcx, shift, wrapper); |
| 1861 __ movq(rcx, r9); |
| 1862 } |
1846 | 1863 |
1847 __ incq(rax); | 1864 __ incq(rax); |
1848 __ cmpq(rcx, r8); | 1865 __ cmpq(rcx, r8); |
1849 __ j(not_equal, exit); | 1866 __ j(not_equal, exit); |
1850 | 1867 |
1851 __ incq(rax); | 1868 __ incq(rax); |
1852 __ Move(rdx, Smi::FromInt(x)); | 1869 __ Move(rdx, Smi::FromInt(x)); |
1853 __ Move(rcx, Smi::FromInt(shift)); | 1870 __ Move(rcx, Smi::FromInt(shift)); |
1854 __ SmiShiftLeft(r9, rdx, rcx); | 1871 __ SmiShiftLeft(r9, rdx, rcx, exit); |
1855 | 1872 |
1856 __ incq(rax); | 1873 __ incq(rax); |
1857 __ cmpq(r9, r8); | 1874 __ cmpq(r9, r8); |
1858 __ j(not_equal, exit); | 1875 __ j(not_equal, exit); |
1859 | 1876 |
1860 __ incq(rax); | 1877 __ incq(rax); |
1861 __ Move(rdx, Smi::FromInt(x)); | 1878 __ Move(rdx, Smi::FromInt(x)); |
1862 __ Move(r11, Smi::FromInt(shift)); | 1879 __ Move(r11, Smi::FromInt(shift)); |
1863 __ SmiShiftLeft(r9, rdx, r11); | 1880 __ SmiShiftLeft(r9, rdx, r11, exit); |
1864 | 1881 |
1865 __ incq(rax); | 1882 __ incq(rax); |
1866 __ cmpq(r9, r8); | 1883 __ cmpq(r9, r8); |
1867 __ j(not_equal, exit); | 1884 __ j(not_equal, exit); |
1868 | 1885 |
1869 __ incq(rax); | 1886 __ incq(rax); |
1870 __ Move(rdx, Smi::FromInt(x)); | 1887 __ Move(rdx, Smi::FromInt(x)); |
1871 __ Move(r11, Smi::FromInt(shift)); | 1888 __ Move(r11, Smi::FromInt(shift)); |
1872 __ SmiShiftLeft(rdx, rdx, r11); | 1889 if (kSmiValueSize == 32) { |
| 1890 __ SmiShiftLeft(rdx, rdx, r11, exit); |
| 1891 } else { |
| 1892 __ SmiShiftLeft(r9, rdx, r11, exit); |
| 1893 __ movq(rdx, r9); |
| 1894 } |
| 1895 __ incq(rax); |
| 1896 __ cmpq(rdx, r8); |
| 1897 __ j(not_equal, exit); |
1873 | 1898 |
1874 __ incq(rax); | 1899 __ incq(rax); |
1875 __ cmpq(rdx, r8); | 1900 } else { |
1876 __ j(not_equal, exit); | 1901 __ Move(rdx, Smi::FromInt(x)); |
| 1902 __ Move(rcx, Smi::FromInt(shift)); |
| 1903 __ movq(r11, rcx); |
| 1904 Label fail_ok1; |
| 1905 __ SmiShiftLeft(r9, rdx, rcx, &fail_ok1); |
| 1906 __ jmp(exit); |
| 1907 __ bind(&fail_ok1); |
1877 | 1908 |
1878 __ incq(rax); | 1909 __ incq(rax); |
| 1910 __ cmpq(rcx, r11); |
| 1911 __ j(not_equal, exit); |
| 1912 |
| 1913 __ incq(rax); |
| 1914 __ Move(rcx, Smi::FromInt(x)); |
| 1915 __ Move(rdx, Smi::FromInt(shift)); |
| 1916 __ movq(r11, rcx); |
| 1917 Label fail_ok2; |
| 1918 __ SmiShiftLeft(r9, rcx, rdx, &fail_ok2); |
| 1919 __ jmp(exit); |
| 1920 __ bind(&fail_ok2); |
| 1921 |
| 1922 __ incq(rax); |
| 1923 __ cmpq(rcx, r11); |
| 1924 __ j(not_equal, exit); |
| 1925 |
| 1926 __ addq(rax, Immediate(7)); |
| 1927 } |
1879 } | 1928 } |
1880 } | 1929 } |
1881 | 1930 |
1882 | 1931 |
1883 TEST(SmiShiftLeft) { | 1932 TEST(SmiShiftLeft) { |
1884 v8::internal::V8::Initialize(NULL); | 1933 v8::internal::V8::Initialize(NULL); |
1885 // Allocate an executable page of memory. | 1934 // Allocate an executable page of memory. |
1886 size_t actual_size; | 1935 size_t actual_size; |
1887 byte* buffer = | 1936 byte* buffer = |
1888 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 4, | 1937 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 4, |
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2515 CodeDesc desc; | 2564 CodeDesc desc; |
2516 masm->GetCode(&desc); | 2565 masm->GetCode(&desc); |
2517 // Call the function from C++. | 2566 // Call the function from C++. |
2518 int result = FUNCTION_CAST<F0>(buffer)(); | 2567 int result = FUNCTION_CAST<F0>(buffer)(); |
2519 CHECK_EQ(0, result); | 2568 CHECK_EQ(0, result); |
2520 } | 2569 } |
2521 | 2570 |
2522 | 2571 |
2523 | 2572 |
2524 #undef __ | 2573 #undef __ |
OLD | NEW |