Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 195 return static_cast<int>(length); | 195 return static_cast<int>(length); |
| 196 } | 196 } |
| 197 | 197 |
| 198 | 198 |
| 199 // ---------------------------------------------------------------------------- | 199 // ---------------------------------------------------------------------------- |
| 200 // BitField is a help template for encoding and decode bitfield with | 200 // BitField is a help template for encoding and decode bitfield with |
| 201 // unsigned content. | 201 // unsigned content. |
| 202 template<class T, int shift, int size> | 202 template<class T, int shift, int size> |
| 203 class BitField { | 203 class BitField { |
| 204 public: | 204 public: |
| 205 typedef T ValueType; | |
|
Vyacheslav Egorov (Chromium)
2011/06/06 12:59:22
I did not find place where it is used.
Vitaly Repeshko
2011/06/06 15:19:43
Oops, this got in from another change.
| |
| 206 | |
| 205 // Tells whether the provided value fits into the bit field. | 207 // Tells whether the provided value fits into the bit field. |
| 206 static bool is_valid(T value) { | 208 static bool is_valid(T value) { |
| 207 return (static_cast<uint32_t>(value) & ~((1U << (size)) - 1)) == 0; | 209 return (static_cast<uint32_t>(value) & ~((1U << (size)) - 1)) == 0; |
| 208 } | 210 } |
| 209 | 211 |
| 210 // Returns a uint32_t mask of bit field. | 212 // Returns a uint32_t mask of bit field. |
| 211 static uint32_t mask() { | 213 static uint32_t mask() { |
| 212 // To use all bits of a uint32 in a bitfield without compiler warnings we | 214 // To use all bits of a uint32 in a bitfield without compiler warnings we |
| 213 // have to compute 2^32 without using a shift count of 32. | 215 // have to compute 2^32 without using a shift count of 32. |
| 214 return ((1U << shift) << size) - (1U << shift); | 216 return ((1U << shift) << size) - (1U << shift); |
| (...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 789 INLINE(Dest BitCast(const Source& source)); | 791 INLINE(Dest BitCast(const Source& source)); |
| 790 | 792 |
| 791 template <class Dest, class Source> | 793 template <class Dest, class Source> |
| 792 inline Dest BitCast(const Source& source) { | 794 inline Dest BitCast(const Source& source) { |
| 793 return BitCastHelper<Dest, Source>::cast(source); | 795 return BitCastHelper<Dest, Source>::cast(source); |
| 794 } | 796 } |
| 795 | 797 |
| 796 } } // namespace v8::internal | 798 } } // namespace v8::internal |
| 797 | 799 |
| 798 #endif // V8_UTILS_H_ | 800 #endif // V8_UTILS_H_ |
| OLD | NEW |