| 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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 | 185 |
| 186 | 186 |
| 187 // Returns true if (addr + offset) is aligned. | 187 // Returns true if (addr + offset) is aligned. |
| 188 inline bool IsAddressAligned(Address addr, | 188 inline bool IsAddressAligned(Address addr, |
| 189 intptr_t alignment, | 189 intptr_t alignment, |
| 190 int offset = 0) { | 190 int offset = 0) { |
| 191 intptr_t offs = OffsetFrom(addr + offset); | 191 intptr_t offs = OffsetFrom(addr + offset); |
| 192 return IsAligned(offs, alignment); | 192 return IsAligned(offs, alignment); |
| 193 } | 193 } |
| 194 | 194 |
| 195 template <typename T, typename U> | |
| 196 inline T RoundUpToMultipleOfPowOf2(T value, U multiple) { | |
| 197 DCHECK(multiple && ((multiple & (multiple - 1)) == 0)); | |
| 198 return (value + multiple - 1) & ~(multiple - 1); | |
| 199 } | |
| 200 | 195 |
| 201 // Returns the maximum of the two parameters. | 196 // Returns the maximum of the two parameters. |
| 202 template <typename T> | 197 template <typename T> |
| 203 T Max(T a, T b) { | 198 T Max(T a, T b) { |
| 204 return a < b ? b : a; | 199 return a < b ? b : a; |
| 205 } | 200 } |
| 206 | 201 |
| 207 | 202 |
| 208 // Returns the minimum of the two parameters. | 203 // Returns the minimum of the two parameters. |
| 209 template <typename T> | 204 template <typename T> |
| (...skipping 1517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1727 private: | 1722 private: |
| 1728 T value_; | 1723 T value_; |
| 1729 ThreadedListZoneEntry<T>* next_; | 1724 ThreadedListZoneEntry<T>* next_; |
| 1730 DISALLOW_COPY_AND_ASSIGN(ThreadedListZoneEntry); | 1725 DISALLOW_COPY_AND_ASSIGN(ThreadedListZoneEntry); |
| 1731 }; | 1726 }; |
| 1732 | 1727 |
| 1733 } // namespace internal | 1728 } // namespace internal |
| 1734 } // namespace v8 | 1729 } // namespace v8 |
| 1735 | 1730 |
| 1736 #endif // V8_UTILS_H_ | 1731 #endif // V8_UTILS_H_ |
| OLD | NEW |