| 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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 static const U kOne = static_cast<U>(1U); | 306 static const U kOne = static_cast<U>(1U); |
| 307 static const U kMask = ((kOne << shift) << size) - (kOne << shift); | 307 static const U kMask = ((kOne << shift) << size) - (kOne << shift); |
| 308 static const U kShift = shift; | 308 static const U kShift = shift; |
| 309 static const U kSize = size; | 309 static const U kSize = size; |
| 310 static const U kNext = kShift + kSize; | 310 static const U kNext = kShift + kSize; |
| 311 | 311 |
| 312 // Value for the field with all bits set. | 312 // Value for the field with all bits set. |
| 313 static const T kMax = static_cast<T>((kOne << size) - 1); | 313 static const T kMax = static_cast<T>((kOne << size) - 1); |
| 314 | 314 |
| 315 // Tells whether the provided value fits into the bit field. | 315 // Tells whether the provided value fits into the bit field. |
| 316 static bool is_valid(T value) { | 316 static constexpr bool is_valid(T value) { |
| 317 return (static_cast<U>(value) & ~static_cast<U>(kMax)) == 0; | 317 return (static_cast<U>(value) & ~static_cast<U>(kMax)) == 0; |
| 318 } | 318 } |
| 319 | 319 |
| 320 // Returns a type U with the bit field value encoded. | 320 // Returns a type U with the bit field value encoded. |
| 321 static U encode(T value) { | 321 static U encode(T value) { |
| 322 DCHECK(is_valid(value)); | 322 DCHECK(is_valid(value)); |
| 323 return static_cast<U>(value) << shift; | 323 return static_cast<U>(value) << shift; |
| 324 } | 324 } |
| 325 | 325 |
| 326 // Returns a type U with the bit field value updated. | 326 // Returns a type U with the bit field value updated. |
| (...skipping 1395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1722 private: | 1722 private: |
| 1723 T value_; | 1723 T value_; |
| 1724 ThreadedListZoneEntry<T>* next_; | 1724 ThreadedListZoneEntry<T>* next_; |
| 1725 DISALLOW_COPY_AND_ASSIGN(ThreadedListZoneEntry); | 1725 DISALLOW_COPY_AND_ASSIGN(ThreadedListZoneEntry); |
| 1726 }; | 1726 }; |
| 1727 | 1727 |
| 1728 } // namespace internal | 1728 } // namespace internal |
| 1729 } // namespace v8 | 1729 } // namespace v8 |
| 1730 | 1730 |
| 1731 #endif // V8_UTILS_H_ | 1731 #endif // V8_UTILS_H_ |
| OLD | NEW |