OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 x >>= 8; | 98 x >>= 8; |
99 } | 99 } |
100 if (x & 0xf0) { | 100 if (x & 0xf0) { |
101 nibble += 4; | 101 nibble += 4; |
102 x >>= 4; | 102 x >>= 4; |
103 } | 103 } |
104 return nibble + msb4[x]; | 104 return nibble + msb4[x]; |
105 } | 105 } |
106 | 106 |
107 | 107 |
108 // Magic numbers for integer division. | |
109 // These are kind of 2's complement reciprocal of the divisors. | |
110 // Details and proofs can be found in: | |
111 // - Hacker's Delight, Henry S. Warren, Jr. | |
112 // - The PowerPC Compiler Writer’s Guide | |
113 // and probably many others. | |
114 // See details in the implementation of the algorithm in | |
115 // lithium-codegen-arm.cc : LCodeGen::TryEmitSignedIntegerDivisionByConstant(). | |
116 struct DivMagicNumbers { | |
117 unsigned M; | |
118 unsigned s; | |
119 }; | |
120 | |
121 const DivMagicNumbers InvalidDivMagicNumber= {0, 0}; | |
122 const DivMagicNumbers DivMagicNumberFor3 = {0x55555556, 0}; | |
123 const DivMagicNumbers DivMagicNumberFor5 = {0x66666667, 1}; | |
124 const DivMagicNumbers DivMagicNumberFor7 = {0x92492493, 2}; | |
125 const DivMagicNumbers DivMagicNumberFor9 = {0x38e38e39, 1}; | |
126 const DivMagicNumbers DivMagicNumberFor11 = {0x2e8ba2e9, 1}; | |
127 const DivMagicNumbers DivMagicNumberFor25 = {0x51eb851f, 3}; | |
128 const DivMagicNumbers DivMagicNumberFor125 = {0x10624dd3, 3}; | |
129 const DivMagicNumbers DivMagicNumberFor625 = {0x68db8bad, 8}; | |
130 | |
131 const DivMagicNumbers DivMagicNumberFor(int32_t divisor); | |
132 | |
133 | |
134 // The C++ standard leaves the semantics of '>>' undefined for | 108 // The C++ standard leaves the semantics of '>>' undefined for |
135 // negative signed operands. Most implementations do the right thing, | 109 // negative signed operands. Most implementations do the right thing, |
136 // though. | 110 // though. |
137 inline int ArithmeticShiftRight(int x, int s) { | 111 inline int ArithmeticShiftRight(int x, int s) { |
138 return x >> s; | 112 return x >> s; |
139 } | 113 } |
140 | 114 |
141 | 115 |
142 // Compute the 0-relative offset of some absolute value x of type T. | 116 // Compute the 0-relative offset of some absolute value x of type T. |
143 // This allows conversion of Addresses and integral types into | 117 // This allows conversion of Addresses and integral types into |
(...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1228 iterator end() { return container_->end(); } | 1202 iterator end() { return container_->end(); } |
1229 reverse_iterator rbegin() { return container_->rbegin(); } | 1203 reverse_iterator rbegin() { return container_->rbegin(); } |
1230 reverse_iterator rend() { return container_->rend(); } | 1204 reverse_iterator rend() { return container_->rend(); } |
1231 private: | 1205 private: |
1232 C* container_; | 1206 C* container_; |
1233 }; | 1207 }; |
1234 | 1208 |
1235 } } // namespace v8::internal | 1209 } } // namespace v8::internal |
1236 | 1210 |
1237 #endif // V8_UTILS_H_ | 1211 #endif // V8_UTILS_H_ |
OLD | NEW |