| 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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 215     // 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. | 
| 216     return ((1U << shift) << size) - (1U << shift); | 216     return ((1U << shift) << size) - (1U << shift); | 
| 217   } | 217   } | 
| 218 | 218 | 
| 219   // Returns a uint32_t with the bit field value encoded. | 219   // Returns a uint32_t with the bit field value encoded. | 
| 220   static uint32_t encode(T value) { | 220   static uint32_t encode(T value) { | 
| 221     ASSERT(is_valid(value)); | 221     ASSERT(is_valid(value)); | 
| 222     return static_cast<uint32_t>(value) << shift; | 222     return static_cast<uint32_t>(value) << shift; | 
| 223   } | 223   } | 
| 224 | 224 | 
|  | 225   // Returns a uint32_t with the bit field value updated. | 
|  | 226   static uint32_t update(uint32_t previous, T value) { | 
|  | 227     return (previous & ~mask()) | encode(value); | 
|  | 228   } | 
|  | 229 | 
| 225   // Extracts the bit field from the value. | 230   // Extracts the bit field from the value. | 
| 226   static T decode(uint32_t value) { | 231   static T decode(uint32_t value) { | 
| 227     return static_cast<T>((value & mask()) >> shift); | 232     return static_cast<T>((value & mask()) >> shift); | 
| 228   } | 233   } | 
| 229 | 234 | 
| 230   // Value for the field with all bits set. | 235   // Value for the field with all bits set. | 
| 231   static T max() { | 236   static T max() { | 
| 232     return decode(mask()); | 237     return decode(mask()); | 
| 233   } | 238   } | 
| 234 }; | 239 }; | 
| (...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 786 INLINE(Dest BitCast(const Source& source)); | 791 INLINE(Dest BitCast(const Source& source)); | 
| 787 | 792 | 
| 788 template <class Dest, class Source> | 793 template <class Dest, class Source> | 
| 789 inline Dest BitCast(const Source& source) { | 794 inline Dest BitCast(const Source& source) { | 
| 790   return BitCastHelper<Dest, Source>::cast(source); | 795   return BitCastHelper<Dest, Source>::cast(source); | 
| 791 } | 796 } | 
| 792 | 797 | 
| 793 } }  // namespace v8::internal | 798 } }  // namespace v8::internal | 
| 794 | 799 | 
| 795 #endif  // V8_UTILS_H_ | 800 #endif  // V8_UTILS_H_ | 
| OLD | NEW | 
|---|