OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
874 Register scratch4); | 874 Register scratch4); |
875 | 875 |
876 private: | 876 private: |
877 Major MajorKey() { return StringCompare; } | 877 Major MajorKey() { return StringCompare; } |
878 int MinorKey() { return 0; } | 878 int MinorKey() { return 0; } |
879 | 879 |
880 void Generate(MacroAssembler* masm); | 880 void Generate(MacroAssembler* masm); |
881 }; | 881 }; |
882 | 882 |
883 | 883 |
| 884 // This stub can do a fast mod operation without using fp. |
| 885 // It is tail called from the GenericBinaryOpStub and it always |
| 886 // returns an answer. It never causes GC so it doesn't need a real frame. |
| 887 // |
| 888 // The inputs are always positive Smis. This is never called |
| 889 // where the denominator is a power of 2. We handle that separately. |
| 890 // |
| 891 // If we consider the denominator as an odd number multiplied by a power of 2, |
| 892 // then: |
| 893 // * The exponent (power of 2) is in the shift_distance register. |
| 894 // * The odd number is in the odd_number register. It is always in the range |
| 895 // of 3 to 25. |
| 896 // * The bits from the numerator that are to be copied to the answer (there are |
| 897 // shift_distance of them) are in the mask_bits register. |
| 898 // * The other bits of the numerator have been shifted down and are in the lhs |
| 899 // register. |
| 900 class IntegerModStub : public CodeStub { |
| 901 public: |
| 902 IntegerModStub(Register result, |
| 903 Register shift_distance, |
| 904 Register odd_number, |
| 905 Register mask_bits, |
| 906 Register lhs, |
| 907 Register scratch) |
| 908 : result_(result), |
| 909 shift_distance_(shift_distance), |
| 910 odd_number_(odd_number), |
| 911 mask_bits_(mask_bits), |
| 912 lhs_(lhs), |
| 913 scratch_(scratch) { |
| 914 // We don't code these in the minor key, so they should always be the same. |
| 915 // We don't really want to fix that since this stub is rather large and we |
| 916 // don't want many copies of it. |
| 917 ASSERT(shift_distance_.is(r9)); |
| 918 ASSERT(odd_number_.is(r4)); |
| 919 ASSERT(mask_bits_.is(r3)); |
| 920 ASSERT(scratch_.is(r5)); |
| 921 } |
| 922 |
| 923 private: |
| 924 Register result_; |
| 925 Register shift_distance_; |
| 926 Register odd_number_; |
| 927 Register mask_bits_; |
| 928 Register lhs_; |
| 929 Register scratch_; |
| 930 |
| 931 // Minor key encoding in 16 bits. |
| 932 class ResultRegisterBits: public BitField<int, 0, 4> {}; |
| 933 class LhsRegisterBits: public BitField<int, 4, 4> {}; |
| 934 |
| 935 Major MajorKey() { return IntegerMod; } |
| 936 int MinorKey() { |
| 937 // Encode the parameters in a unique 16 bit value. |
| 938 return ResultRegisterBits::encode(result_.code()) |
| 939 | LhsRegisterBits::encode(lhs_.code()); |
| 940 } |
| 941 |
| 942 void Generate(MacroAssembler* masm); |
| 943 |
| 944 const char* GetName() { return "IntegerModStub"; } |
| 945 |
| 946 #ifdef DEBUG |
| 947 void Print() { PrintF("IntegerModStub\n"); } |
| 948 #endif |
| 949 }; |
| 950 |
| 951 |
884 // This stub can convert a signed int32 to a heap number (double). It does | 952 // This stub can convert a signed int32 to a heap number (double). It does |
885 // not work for int32s that are in Smi range! No GC occurs during this stub | 953 // not work for int32s that are in Smi range! No GC occurs during this stub |
886 // so you don't have to set up the frame. | 954 // so you don't have to set up the frame. |
887 class WriteInt32ToHeapNumberStub : public CodeStub { | 955 class WriteInt32ToHeapNumberStub : public CodeStub { |
888 public: | 956 public: |
889 WriteInt32ToHeapNumberStub(Register the_int, | 957 WriteInt32ToHeapNumberStub(Register the_int, |
890 Register the_heap_number, | 958 Register the_heap_number, |
891 Register scratch) | 959 Register scratch) |
892 : the_int_(the_int), | 960 : the_int_(the_int), |
893 the_heap_number_(the_heap_number), | 961 the_heap_number_(the_heap_number), |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
988 return ObjectBits::encode(object_.code()) | | 1056 return ObjectBits::encode(object_.code()) | |
989 OffsetBits::encode(offset_.code()) | | 1057 OffsetBits::encode(offset_.code()) | |
990 ScratchBits::encode(scratch_.code()); | 1058 ScratchBits::encode(scratch_.code()); |
991 } | 1059 } |
992 }; | 1060 }; |
993 | 1061 |
994 | 1062 |
995 } } // namespace v8::internal | 1063 } } // namespace v8::internal |
996 | 1064 |
997 #endif // V8_ARM_CODEGEN_ARM_H_ | 1065 #endif // V8_ARM_CODEGEN_ARM_H_ |
OLD | NEW |