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/bits.h" |
16 #include "src/base/logging.h" | 16 #include "src/base/logging.h" |
17 #include "src/base/macros.h" | 17 #include "src/base/macros.h" |
18 #include "src/base/platform/platform.h" | 18 #include "src/base/platform/platform.h" |
19 #include "src/globals.h" | 19 #include "src/globals.h" |
20 #include "src/list.h" | 20 #include "src/list.h" |
21 #include "src/vector.h" | 21 #include "src/vector.h" |
22 | 22 |
23 namespace v8 { | 23 namespace v8 { |
24 namespace internal { | 24 namespace internal { |
25 | 25 |
26 // ---------------------------------------------------------------------------- | 26 // ---------------------------------------------------------------------------- |
27 // General helper functions | 27 // General helper functions |
28 | 28 |
29 | 29 |
| 30 inline int BoolToInt(bool b) { return b ? 1 : 0; } |
| 31 |
| 32 |
30 // Same as strcmp, but can handle NULL arguments. | 33 // Same as strcmp, but can handle NULL arguments. |
31 inline bool CStringEquals(const char* s1, const char* s2) { | 34 inline bool CStringEquals(const char* s1, const char* s2) { |
32 return (s1 == s2) || (s1 != NULL && s2 != NULL && strcmp(s1, s2) == 0); | 35 return (s1 == s2) || (s1 != NULL && s2 != NULL && strcmp(s1, s2) == 0); |
33 } | 36 } |
34 | 37 |
35 | 38 |
36 // X must be a power of 2. Returns the number of trailing zeros. | 39 // X must be a power of 2. Returns the number of trailing zeros. |
37 inline int WhichPowerOf2(uint32_t x) { | 40 inline int WhichPowerOf2(uint32_t x) { |
38 DCHECK(base::bits::IsPowerOfTwo32(x)); | 41 DCHECK(base::bits::IsPowerOfTwo32(x)); |
39 int bits = 0; | 42 int bits = 0; |
(...skipping 1497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1537 // Takes the address of the limit variable in order to find out where | 1540 // Takes the address of the limit variable in order to find out where |
1538 // the top of stack is right now. | 1541 // the top of stack is right now. |
1539 uintptr_t limit = reinterpret_cast<uintptr_t>(&limit); | 1542 uintptr_t limit = reinterpret_cast<uintptr_t>(&limit); |
1540 return limit; | 1543 return limit; |
1541 } | 1544 } |
1542 | 1545 |
1543 } // namespace internal | 1546 } // namespace internal |
1544 } // namespace v8 | 1547 } // namespace v8 |
1545 | 1548 |
1546 #endif // V8_UTILS_H_ | 1549 #endif // V8_UTILS_H_ |
OLD | NEW |