Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: src/utils.h

Issue 10824079: Use a special EnumLength field to indicate number of valid enum cache values. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: u Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 // ---------------------------------------------------------------------------- 241 // ----------------------------------------------------------------------------
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 252
252 // Value for the field with all bits set. 253 // Value for the field with all bits set.
253 static const T kMax = static_cast<T>((1U << size) - 1); 254 static const T kMax = static_cast<T>((1U << size) - 1);
254 255
255 // Tells whether the provided value fits into the bit field. 256 // Tells whether the provided value fits into the bit field.
256 static bool is_valid(T value) { 257 static bool is_valid(T value) {
257 return (static_cast<uint32_t>(value) & ~static_cast<uint32_t>(kMax)) == 0; 258 return (static_cast<uint32_t>(value) & ~static_cast<uint32_t>(kMax)) == 0;
258 } 259 }
259 260
260 // Returns a uint32_t with the bit field value encoded. 261 // Returns a uint32_t with the bit field value encoded.
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after
976 ASSERT(element < static_cast<int>(sizeof(T) * CHAR_BIT)); 977 ASSERT(element < static_cast<int>(sizeof(T) * CHAR_BIT));
977 return 1 << element; 978 return 1 << element;
978 } 979 }
979 980
980 T bits_; 981 T bits_;
981 }; 982 };
982 983
983 } } // namespace v8::internal 984 } } // namespace v8::internal
984 985
985 #endif // V8_UTILS_H_ 986 #endif // V8_UTILS_H_
OLDNEW
« src/objects.h ('K') | « src/objects.cc ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698