OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_UTILS_H_ | 5 #ifndef V8_UTILS_H_ |
6 #define V8_UTILS_H_ | 6 #define V8_UTILS_H_ |
7 | 7 |
8 #include <limits.h> | 8 #include <limits.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 } | 54 } |
55 switch (x) { | 55 switch (x) { |
56 default: UNREACHABLE(); | 56 default: UNREACHABLE(); |
57 case 8: bits++; // Fall through. | 57 case 8: bits++; // Fall through. |
58 case 4: bits++; // Fall through. | 58 case 4: bits++; // Fall through. |
59 case 2: bits++; // Fall through. | 59 case 2: bits++; // Fall through. |
60 case 1: break; | 60 case 1: break; |
61 } | 61 } |
62 DCHECK_EQ(1 << bits, original_x); | 62 DCHECK_EQ(1 << bits, original_x); |
63 return bits; | 63 return bits; |
64 return 0; | |
65 } | 64 } |
66 | 65 |
67 | 66 |
68 inline int MostSignificantBit(uint32_t x) { | 67 inline int MostSignificantBit(uint32_t x) { |
69 static const int msb4[] = {0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4}; | 68 static const int msb4[] = {0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4}; |
70 int nibble = 0; | 69 int nibble = 0; |
71 if (x & 0xffff0000) { | 70 if (x & 0xffff0000) { |
72 nibble += 16; | 71 nibble += 16; |
73 x >>= 16; | 72 x >>= 16; |
74 } | 73 } |
(...skipping 1386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1461 // Takes the address of the limit variable in order to find out where | 1460 // Takes the address of the limit variable in order to find out where |
1462 // the top of stack is right now. | 1461 // the top of stack is right now. |
1463 uintptr_t limit = reinterpret_cast<uintptr_t>(&limit); | 1462 uintptr_t limit = reinterpret_cast<uintptr_t>(&limit); |
1464 return limit; | 1463 return limit; |
1465 } | 1464 } |
1466 | 1465 |
1467 } // namespace internal | 1466 } // namespace internal |
1468 } // namespace v8 | 1467 } // namespace v8 |
1469 | 1468 |
1470 #endif // V8_UTILS_H_ | 1469 #endif // V8_UTILS_H_ |
OLD | NEW |