| 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> |
| 11 #include <cmath> | 11 #include <cmath> |
| 12 | 12 |
| 13 #include "include/v8.h" | 13 #include "include/v8.h" |
| 14 #include "src/allocation.h" | 14 #include "src/allocation.h" |
| 15 #include "src/base/bits.h" |
| 15 #include "src/base/logging.h" | 16 #include "src/base/logging.h" |
| 16 #include "src/base/macros.h" | 17 #include "src/base/macros.h" |
| 17 #include "src/base/platform/platform.h" | 18 #include "src/base/platform/platform.h" |
| 18 #include "src/globals.h" | 19 #include "src/globals.h" |
| 19 #include "src/list.h" | 20 #include "src/list.h" |
| 20 #include "src/vector.h" | 21 #include "src/vector.h" |
| 21 | 22 |
| 22 namespace v8 { | 23 namespace v8 { |
| 23 namespace internal { | 24 namespace internal { |
| 24 | 25 |
| 25 // ---------------------------------------------------------------------------- | 26 // ---------------------------------------------------------------------------- |
| 26 // General helper functions | 27 // General helper functions |
| 27 | 28 |
| 28 // X must be a power of 2. Returns the number of trailing zeros. | 29 // X must be a power of 2. Returns the number of trailing zeros. |
| 29 inline int WhichPowerOf2(uint32_t x) { | 30 inline int WhichPowerOf2(uint32_t x) { |
| 30 DCHECK(IsPowerOf2(x)); | 31 DCHECK(base::bits::IsPowerOfTwo32(x)); |
| 31 int bits = 0; | 32 int bits = 0; |
| 32 #ifdef DEBUG | 33 #ifdef DEBUG |
| 33 int original_x = x; | 34 int original_x = x; |
| 34 #endif | 35 #endif |
| 35 if (x >= 0x10000) { | 36 if (x >= 0x10000) { |
| 36 bits += 16; | 37 bits += 16; |
| 37 x >>= 16; | 38 x >>= 16; |
| 38 } | 39 } |
| 39 if (x >= 0x100) { | 40 if (x >= 0x100) { |
| 40 bits += 8; | 41 bits += 8; |
| (...skipping 1490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1531 } | 1532 } |
| 1532 | 1533 |
| 1533 *index = result; | 1534 *index = result; |
| 1534 return true; | 1535 return true; |
| 1535 } | 1536 } |
| 1536 | 1537 |
| 1537 | 1538 |
| 1538 } } // namespace v8::internal | 1539 } } // namespace v8::internal |
| 1539 | 1540 |
| 1540 #endif // V8_UTILS_H_ | 1541 #endif // V8_UTILS_H_ |
| OLD | NEW |