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 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 __ cmpq(r9, r8); | 729 __ cmpq(r9, r8); |
730 __ j(not_equal, exit); | 730 __ j(not_equal, exit); |
731 | 731 |
732 __ SmiAddConstant(rcx, rcx, Smi::FromInt(second)); | 732 __ SmiAddConstant(rcx, rcx, Smi::FromInt(second)); |
733 __ cmpq(rcx, r8); | 733 __ cmpq(rcx, r8); |
734 __ j(not_equal, exit); | 734 __ j(not_equal, exit); |
735 | 735 |
736 __ movl(rcx, Immediate(first)); | 736 __ movl(rcx, Immediate(first)); |
737 __ Integer32ToSmi(rcx, rcx); | 737 __ Integer32ToSmi(rcx, rcx); |
738 | 738 |
739 i::SmiOperationExecutionMode mode; | 739 i::SmiOperationConstraints constraints = |
740 mode.Add(i::PRESERVE_SOURCE_REGISTER); | 740 i::SmiOperationConstraint::kPreserveSourceRegister | |
741 mode.Add(i::BAILOUT_ON_OVERFLOW); | 741 i::SmiOperationConstraint::kBailoutOnOverflow; |
742 __ incq(rax); | 742 __ incq(rax); |
743 __ SmiAddConstant(r9, rcx, Smi::FromInt(second), mode, exit); | 743 __ SmiAddConstant(r9, rcx, Smi::FromInt(second), constraints, exit); |
744 __ cmpq(r9, r8); | 744 __ cmpq(r9, r8); |
745 __ j(not_equal, exit); | 745 __ j(not_equal, exit); |
746 | 746 |
747 __ incq(rax); | 747 __ incq(rax); |
748 __ SmiAddConstant(rcx, rcx, Smi::FromInt(second), mode, exit); | 748 __ SmiAddConstant(rcx, rcx, Smi::FromInt(second), constraints, exit); |
749 __ cmpq(rcx, r8); | 749 __ cmpq(rcx, r8); |
750 __ j(not_equal, exit); | 750 __ j(not_equal, exit); |
751 | 751 |
752 __ movl(rcx, Immediate(first)); | 752 __ movl(rcx, Immediate(first)); |
753 __ Integer32ToSmi(rcx, rcx); | 753 __ Integer32ToSmi(rcx, rcx); |
754 | 754 |
755 mode.RemoveAll(); | 755 constraints = i::SmiOperationConstraint::kPreserveSourceRegister | |
756 mode.Add(i::PRESERVE_SOURCE_REGISTER); | 756 i::SmiOperationConstraint::kBailoutOnNoOverflow; |
757 mode.Add(i::BAILOUT_ON_NO_OVERFLOW); | |
758 Label done; | 757 Label done; |
759 __ incq(rax); | 758 __ incq(rax); |
760 __ SmiAddConstant(rcx, rcx, Smi::FromInt(second), mode, &done); | 759 __ SmiAddConstant(rcx, rcx, Smi::FromInt(second), constraints, &done); |
761 __ jmp(exit); | 760 __ jmp(exit); |
762 __ bind(&done); | 761 __ bind(&done); |
763 __ cmpq(rcx, r8); | 762 __ cmpq(rcx, r8); |
764 __ j(not_equal, exit); | 763 __ j(not_equal, exit); |
765 } | 764 } |
766 | 765 |
767 | 766 |
768 static void SmiAddOverflowTest(MacroAssembler* masm, | 767 static void SmiAddOverflowTest(MacroAssembler* masm, |
769 Label* exit, | 768 Label* exit, |
770 int id, | 769 int id, |
(...skipping 21 matching lines...) Expand all Loading... |
792 Label overflow_ok; | 791 Label overflow_ok; |
793 __ incq(rax); | 792 __ incq(rax); |
794 __ SmiAdd(rcx, rcx, rdx, &overflow_ok); | 793 __ SmiAdd(rcx, rcx, rdx, &overflow_ok); |
795 __ jmp(exit); | 794 __ jmp(exit); |
796 __ bind(&overflow_ok); | 795 __ bind(&overflow_ok); |
797 __ incq(rax); | 796 __ incq(rax); |
798 __ cmpq(rcx, r11); | 797 __ cmpq(rcx, r11); |
799 __ j(not_equal, exit); | 798 __ j(not_equal, exit); |
800 } | 799 } |
801 | 800 |
802 i::SmiOperationExecutionMode mode; | 801 i::SmiOperationConstraints constraints = |
803 mode.Add(i::PRESERVE_SOURCE_REGISTER); | 802 i::SmiOperationConstraint::kPreserveSourceRegister | |
804 mode.Add(i::BAILOUT_ON_OVERFLOW); | 803 i::SmiOperationConstraint::kBailoutOnOverflow; |
805 __ movq(rcx, r11); | 804 __ movq(rcx, r11); |
806 { | 805 { |
807 Label overflow_ok; | 806 Label overflow_ok; |
808 __ incq(rax); | 807 __ incq(rax); |
809 __ SmiAddConstant(r9, rcx, Smi::FromInt(y_min), mode, &overflow_ok); | 808 __ SmiAddConstant(r9, rcx, Smi::FromInt(y_min), constraints, &overflow_ok); |
810 __ jmp(exit); | 809 __ jmp(exit); |
811 __ bind(&overflow_ok); | 810 __ bind(&overflow_ok); |
812 __ incq(rax); | 811 __ incq(rax); |
813 __ cmpq(rcx, r11); | 812 __ cmpq(rcx, r11); |
814 __ j(not_equal, exit); | 813 __ j(not_equal, exit); |
815 } | 814 } |
816 | 815 |
817 { | 816 { |
818 Label overflow_ok; | 817 Label overflow_ok; |
819 __ incq(rax); | 818 __ incq(rax); |
820 __ SmiAddConstant(rcx, rcx, Smi::FromInt(y_min), mode, &overflow_ok); | 819 __ SmiAddConstant(rcx, rcx, Smi::FromInt(y_min), constraints, &overflow_ok); |
821 __ jmp(exit); | 820 __ jmp(exit); |
822 __ bind(&overflow_ok); | 821 __ bind(&overflow_ok); |
823 __ incq(rax); | 822 __ incq(rax); |
824 __ cmpq(rcx, r11); | 823 __ cmpq(rcx, r11); |
825 __ j(not_equal, exit); | 824 __ j(not_equal, exit); |
826 } | 825 } |
827 | 826 |
828 __ Move(rdx, Smi::FromInt(y_max)); | 827 __ Move(rdx, Smi::FromInt(y_max)); |
829 | 828 |
830 { | 829 { |
(...skipping 15 matching lines...) Expand all Loading... |
846 __ bind(&overflow_ok); | 845 __ bind(&overflow_ok); |
847 __ incq(rax); | 846 __ incq(rax); |
848 __ cmpq(rcx, r11); | 847 __ cmpq(rcx, r11); |
849 __ j(not_equal, exit); | 848 __ j(not_equal, exit); |
850 } | 849 } |
851 | 850 |
852 __ movq(rcx, r11); | 851 __ movq(rcx, r11); |
853 { | 852 { |
854 Label overflow_ok; | 853 Label overflow_ok; |
855 __ incq(rax); | 854 __ incq(rax); |
856 __ SmiAddConstant(r9, rcx, Smi::FromInt(y_max), mode, &overflow_ok); | 855 __ SmiAddConstant(r9, rcx, Smi::FromInt(y_max), constraints, &overflow_ok); |
857 __ jmp(exit); | 856 __ jmp(exit); |
858 __ bind(&overflow_ok); | 857 __ bind(&overflow_ok); |
859 __ incq(rax); | 858 __ incq(rax); |
860 __ cmpq(rcx, r11); | 859 __ cmpq(rcx, r11); |
861 __ j(not_equal, exit); | 860 __ j(not_equal, exit); |
862 } | 861 } |
863 | 862 |
864 mode.RemoveAll(); | 863 constraints = i::SmiOperationConstraint::kBailoutOnOverflow; |
865 mode.Add(i::BAILOUT_ON_OVERFLOW); | |
866 { | 864 { |
867 Label overflow_ok; | 865 Label overflow_ok; |
868 __ incq(rax); | 866 __ incq(rax); |
869 __ SmiAddConstant(rcx, rcx, Smi::FromInt(y_max), mode, &overflow_ok); | 867 __ SmiAddConstant(rcx, rcx, Smi::FromInt(y_max), constraints, &overflow_ok); |
870 __ jmp(exit); | 868 __ jmp(exit); |
871 __ bind(&overflow_ok); | 869 __ bind(&overflow_ok); |
872 __ incq(rax); | 870 __ incq(rax); |
873 __ cmpq(rcx, r11); | 871 __ cmpq(rcx, r11); |
874 __ j(equal, exit); | 872 __ j(equal, exit); |
875 } | 873 } |
876 } | 874 } |
877 | 875 |
878 | 876 |
879 TEST(SmiAdd) { | 877 TEST(SmiAdd) { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
945 __ incq(rax); // Test 2. | 943 __ incq(rax); // Test 2. |
946 __ SmiSubConstant(r9, rcx, Smi::FromInt(second)); | 944 __ SmiSubConstant(r9, rcx, Smi::FromInt(second)); |
947 __ cmpq(r9, r8); | 945 __ cmpq(r9, r8); |
948 __ j(not_equal, exit); | 946 __ j(not_equal, exit); |
949 | 947 |
950 __ incq(rax); // Test 3. | 948 __ incq(rax); // Test 3. |
951 __ SmiSubConstant(rcx, rcx, Smi::FromInt(second)); | 949 __ SmiSubConstant(rcx, rcx, Smi::FromInt(second)); |
952 __ cmpq(rcx, r8); | 950 __ cmpq(rcx, r8); |
953 __ j(not_equal, exit); | 951 __ j(not_equal, exit); |
954 | 952 |
955 i::SmiOperationExecutionMode mode; | 953 i::SmiOperationConstraints constraints = |
956 mode.Add(i::PRESERVE_SOURCE_REGISTER); | 954 i::SmiOperationConstraint::kPreserveSourceRegister | |
957 mode.Add(i::BAILOUT_ON_OVERFLOW); | 955 i::SmiOperationConstraint::kBailoutOnOverflow; |
958 __ Move(rcx, Smi::FromInt(first)); | 956 __ Move(rcx, Smi::FromInt(first)); |
959 __ incq(rax); // Test 4. | 957 __ incq(rax); // Test 4. |
960 __ SmiSubConstant(rcx, rcx, Smi::FromInt(second), mode, exit); | 958 __ SmiSubConstant(rcx, rcx, Smi::FromInt(second), constraints, exit); |
961 __ cmpq(rcx, r8); | 959 __ cmpq(rcx, r8); |
962 __ j(not_equal, exit); | 960 __ j(not_equal, exit); |
963 | 961 |
964 __ Move(rcx, Smi::FromInt(first)); | 962 __ Move(rcx, Smi::FromInt(first)); |
965 __ incq(rax); // Test 5. | 963 __ incq(rax); // Test 5. |
966 __ SmiSubConstant(r9, rcx, Smi::FromInt(second), mode, exit); | 964 __ SmiSubConstant(r9, rcx, Smi::FromInt(second), constraints, exit); |
967 __ cmpq(r9, r8); | 965 __ cmpq(r9, r8); |
968 __ j(not_equal, exit); | 966 __ j(not_equal, exit); |
969 | 967 |
970 mode.RemoveAll(); | 968 constraints = i::SmiOperationConstraint::kPreserveSourceRegister | |
971 mode.Add(i::PRESERVE_SOURCE_REGISTER); | 969 i::SmiOperationConstraint::kBailoutOnNoOverflow; |
972 mode.Add(i::BAILOUT_ON_NO_OVERFLOW); | |
973 __ Move(rcx, Smi::FromInt(first)); | 970 __ Move(rcx, Smi::FromInt(first)); |
974 Label done; | 971 Label done; |
975 __ incq(rax); // Test 6. | 972 __ incq(rax); // Test 6. |
976 __ SmiSubConstant(rcx, rcx, Smi::FromInt(second), mode, &done); | 973 __ SmiSubConstant(rcx, rcx, Smi::FromInt(second), constraints, &done); |
977 __ jmp(exit); | 974 __ jmp(exit); |
978 __ bind(&done); | 975 __ bind(&done); |
979 __ cmpq(rcx, r8); | 976 __ cmpq(rcx, r8); |
980 __ j(not_equal, exit); | 977 __ j(not_equal, exit); |
981 } | 978 } |
982 | 979 |
983 | 980 |
984 static void SmiSubOverflowTest(MacroAssembler* masm, | 981 static void SmiSubOverflowTest(MacroAssembler* masm, |
985 Label* exit, | 982 Label* exit, |
986 int id, | 983 int id, |
(...skipping 21 matching lines...) Expand all Loading... |
1008 Label overflow_ok; | 1005 Label overflow_ok; |
1009 __ incq(rax); | 1006 __ incq(rax); |
1010 __ SmiSub(rcx, rcx, rdx, &overflow_ok); | 1007 __ SmiSub(rcx, rcx, rdx, &overflow_ok); |
1011 __ jmp(exit); | 1008 __ jmp(exit); |
1012 __ bind(&overflow_ok); | 1009 __ bind(&overflow_ok); |
1013 __ incq(rax); | 1010 __ incq(rax); |
1014 __ cmpq(rcx, r11); | 1011 __ cmpq(rcx, r11); |
1015 __ j(not_equal, exit); | 1012 __ j(not_equal, exit); |
1016 } | 1013 } |
1017 | 1014 |
1018 i::SmiOperationExecutionMode mode; | 1015 i::SmiOperationConstraints constraints = |
1019 mode.Add(i::PRESERVE_SOURCE_REGISTER); | 1016 i::SmiOperationConstraint::kPreserveSourceRegister | |
1020 mode.Add(i::BAILOUT_ON_OVERFLOW); | 1017 i::SmiOperationConstraint::kBailoutOnOverflow; |
1021 | 1018 |
1022 __ movq(rcx, r11); | 1019 __ movq(rcx, r11); |
1023 { | 1020 { |
1024 Label overflow_ok; | 1021 Label overflow_ok; |
1025 __ incq(rax); | 1022 __ incq(rax); |
1026 __ SmiSubConstant(r9, rcx, Smi::FromInt(y_min), mode, &overflow_ok); | 1023 __ SmiSubConstant(r9, rcx, Smi::FromInt(y_min), constraints, &overflow_ok); |
1027 __ jmp(exit); | 1024 __ jmp(exit); |
1028 __ bind(&overflow_ok); | 1025 __ bind(&overflow_ok); |
1029 __ incq(rax); | 1026 __ incq(rax); |
1030 __ cmpq(rcx, r11); | 1027 __ cmpq(rcx, r11); |
1031 __ j(not_equal, exit); | 1028 __ j(not_equal, exit); |
1032 } | 1029 } |
1033 | 1030 |
1034 { | 1031 { |
1035 Label overflow_ok; | 1032 Label overflow_ok; |
1036 __ incq(rax); | 1033 __ incq(rax); |
1037 __ SmiSubConstant(rcx, rcx, Smi::FromInt(y_min), mode, &overflow_ok); | 1034 __ SmiSubConstant(rcx, rcx, Smi::FromInt(y_min), constraints, &overflow_ok); |
1038 __ jmp(exit); | 1035 __ jmp(exit); |
1039 __ bind(&overflow_ok); | 1036 __ bind(&overflow_ok); |
1040 __ incq(rax); | 1037 __ incq(rax); |
1041 __ cmpq(rcx, r11); | 1038 __ cmpq(rcx, r11); |
1042 __ j(not_equal, exit); | 1039 __ j(not_equal, exit); |
1043 } | 1040 } |
1044 | 1041 |
1045 __ Move(rdx, Smi::FromInt(y_max)); | 1042 __ Move(rdx, Smi::FromInt(y_max)); |
1046 | 1043 |
1047 { | 1044 { |
(...skipping 15 matching lines...) Expand all Loading... |
1063 __ bind(&overflow_ok); | 1060 __ bind(&overflow_ok); |
1064 __ incq(rax); | 1061 __ incq(rax); |
1065 __ cmpq(rcx, r11); | 1062 __ cmpq(rcx, r11); |
1066 __ j(not_equal, exit); | 1063 __ j(not_equal, exit); |
1067 } | 1064 } |
1068 | 1065 |
1069 __ movq(rcx, r11); | 1066 __ movq(rcx, r11); |
1070 { | 1067 { |
1071 Label overflow_ok; | 1068 Label overflow_ok; |
1072 __ incq(rax); | 1069 __ incq(rax); |
1073 __ SmiSubConstant(rcx, rcx, Smi::FromInt(y_max), mode, &overflow_ok); | 1070 __ SmiSubConstant(rcx, rcx, Smi::FromInt(y_max), constraints, &overflow_ok); |
1074 __ jmp(exit); | 1071 __ jmp(exit); |
1075 __ bind(&overflow_ok); | 1072 __ bind(&overflow_ok); |
1076 __ incq(rax); | 1073 __ incq(rax); |
1077 __ cmpq(rcx, r11); | 1074 __ cmpq(rcx, r11); |
1078 __ j(not_equal, exit); | 1075 __ j(not_equal, exit); |
1079 } | 1076 } |
1080 | 1077 |
1081 mode.RemoveAll(); | 1078 constraints = i::SmiOperationConstraint::kBailoutOnOverflow; |
1082 mode.Add(i::BAILOUT_ON_OVERFLOW); | |
1083 __ movq(rcx, r11); | 1079 __ movq(rcx, r11); |
1084 { | 1080 { |
1085 Label overflow_ok; | 1081 Label overflow_ok; |
1086 __ incq(rax); | 1082 __ incq(rax); |
1087 __ SmiSubConstant(rcx, rcx, Smi::FromInt(y_max), mode, &overflow_ok); | 1083 __ SmiSubConstant(rcx, rcx, Smi::FromInt(y_max), constraints, &overflow_ok); |
1088 __ jmp(exit); | 1084 __ jmp(exit); |
1089 __ bind(&overflow_ok); | 1085 __ bind(&overflow_ok); |
1090 __ incq(rax); | 1086 __ incq(rax); |
1091 __ cmpq(rcx, r11); | 1087 __ cmpq(rcx, r11); |
1092 __ j(equal, exit); | 1088 __ j(equal, exit); |
1093 } | 1089 } |
1094 } | 1090 } |
1095 | 1091 |
1096 | 1092 |
1097 TEST(SmiSub) { | 1093 TEST(SmiSub) { |
(...skipping 1606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2704 | 2700 |
2705 CodeDesc desc; | 2701 CodeDesc desc; |
2706 masm->GetCode(&desc); | 2702 masm->GetCode(&desc); |
2707 // Call the function from C++. | 2703 // Call the function from C++. |
2708 int result = FUNCTION_CAST<F0>(buffer)(); | 2704 int result = FUNCTION_CAST<F0>(buffer)(); |
2709 CHECK_EQ(0, result); | 2705 CHECK_EQ(0, result); |
2710 } | 2706 } |
2711 | 2707 |
2712 | 2708 |
2713 #undef __ | 2709 #undef __ |
OLD | NEW |