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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
178 | 178 |
179 | 179 |
180 // Returns true if (addr + offset) is aligned. | 180 // Returns true if (addr + offset) is aligned. |
181 inline bool IsAddressAligned(Address addr, | 181 inline bool IsAddressAligned(Address addr, |
182 intptr_t alignment, | 182 intptr_t alignment, |
183 int offset = 0) { | 183 int offset = 0) { |
184 intptr_t offs = OffsetFrom(addr + offset); | 184 intptr_t offs = OffsetFrom(addr + offset); |
185 return IsAligned(offs, alignment); | 185 return IsAligned(offs, alignment); |
186 } | 186 } |
187 | 187 |
188 template <typename T, typename U> | |
189 inline T RoundUpToMultipleOfPowOf2(T value, U multiple) { | |
190 DCHECK(multiple && ((multiple & (multiple - 1)) == 0)); | |
Clemens Hammacher
2017/05/18 11:52:05
There is base::bits::IsPowerOfTwo64.
ivica.bogosavljevic
2017/05/18 12:21:43
Acknowledged.
| |
191 return (value + multiple - 1) & ~(multiple - 1); | |
192 } | |
188 | 193 |
189 // Returns the maximum of the two parameters. | 194 // Returns the maximum of the two parameters. |
190 template <typename T> | 195 template <typename T> |
191 T Max(T a, T b) { | 196 T Max(T a, T b) { |
192 return a < b ? b : a; | 197 return a < b ? b : a; |
193 } | 198 } |
194 | 199 |
195 | 200 |
196 // Returns the minimum of the two parameters. | 201 // Returns the minimum of the two parameters. |
197 template <typename T> | 202 template <typename T> |
(...skipping 1514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1712 private: | 1717 private: |
1713 T value_; | 1718 T value_; |
1714 ThreadedListZoneEntry<T>* next_; | 1719 ThreadedListZoneEntry<T>* next_; |
1715 DISALLOW_COPY_AND_ASSIGN(ThreadedListZoneEntry); | 1720 DISALLOW_COPY_AND_ASSIGN(ThreadedListZoneEntry); |
1716 }; | 1721 }; |
1717 | 1722 |
1718 } // namespace internal | 1723 } // namespace internal |
1719 } // namespace v8 | 1724 } // namespace v8 |
1720 | 1725 |
1721 #endif // V8_UTILS_H_ | 1726 #endif // V8_UTILS_H_ |
OLD | NEW |