OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 // BitField is a help template for encoding and decode bitfield with | 242 // BitField is a help template for encoding and decode bitfield with |
243 // unsigned content. | 243 // unsigned content. |
244 template<class T, int shift, int size> | 244 template<class T, int shift, int size> |
245 class BitField { | 245 class BitField { |
246 public: | 246 public: |
247 // A uint32_t mask of bit field. To use all bits of a uint32 in a | 247 // A uint32_t mask of bit field. To use all bits of a uint32 in a |
248 // bitfield without compiler warnings we have to compute 2^32 without | 248 // bitfield without compiler warnings we have to compute 2^32 without |
249 // using a shift count of 32. | 249 // using a shift count of 32. |
250 static const uint32_t kMask = ((1U << shift) << size) - (1U << shift); | 250 static const uint32_t kMask = ((1U << shift) << size) - (1U << shift); |
251 static const uint32_t kShift = shift; | 251 static const uint32_t kShift = shift; |
| 252 static const uint32_t kSize = size; |
252 | 253 |
253 // Value for the field with all bits set. | 254 // Value for the field with all bits set. |
254 static const T kMax = static_cast<T>((1U << size) - 1); | 255 static const T kMax = static_cast<T>((1U << size) - 1); |
255 | 256 |
256 // Tells whether the provided value fits into the bit field. | 257 // Tells whether the provided value fits into the bit field. |
257 static bool is_valid(T value) { | 258 static bool is_valid(T value) { |
258 return (static_cast<uint32_t>(value) & ~static_cast<uint32_t>(kMax)) == 0; | 259 return (static_cast<uint32_t>(value) & ~static_cast<uint32_t>(kMax)) == 0; |
259 } | 260 } |
260 | 261 |
261 // Returns a uint32_t with the bit field value encoded. | 262 // Returns a uint32_t with the bit field value encoded. |
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1076 | 1077 |
1077 // Every compiled stub starts with this id. | 1078 // Every compiled stub starts with this id. |
1078 static const int kStubEntryId = 5; | 1079 static const int kStubEntryId = 5; |
1079 | 1080 |
1080 int id_; | 1081 int id_; |
1081 }; | 1082 }; |
1082 | 1083 |
1083 } } // namespace v8::internal | 1084 } } // namespace v8::internal |
1084 | 1085 |
1085 #endif // V8_UTILS_H_ | 1086 #endif // V8_UTILS_H_ |
OLD | NEW |