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

Unified Diff: vm/bitfield.h

Issue 9021042: Make snapshots 32 or 64 bit compliant by using Write<int64_t> and Read<int64_t> for intptr_t type... (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: '' Created 9 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | vm/globals.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: vm/bitfield.h
===================================================================
--- vm/bitfield.h (revision 2835)
+++ vm/bitfield.h (working copy)
@@ -7,6 +7,8 @@
namespace dart {
+static const uword kUwordOne = 1U;
+
// BitField is a template for encoding and decoding a bit field inside
// an unsigned machine word.
template<typename T, int position, int size>
@@ -14,18 +16,18 @@
public:
// Tells whether the provided value fits into the bit field.
static bool is_valid(T value) {
- return (static_cast<uword>(value) & ~((1U << size) - 1)) == 0;
+ return (static_cast<uword>(value) & ~((kUwordOne << size) - 1)) == 0;
}
// Returns a uword mask of the bit field.
static uword mask() {
- return (1U << size) - 1;
+ return (kUwordOne << size) - 1;
}
// Returns a uword mask of the bit field which can be applied directly to
// to the raw unshifted bits.
static uword mask_in_place() {
- return ((1U << size) - 1) << position;
+ return ((kUwordOne << size) - 1) << position;
}
// Returns the shift count needed to right-shift the bit field to
@@ -47,7 +49,7 @@
// Extracts the bit field from the value.
static T decode(uword value) {
- return static_cast<T>((value >> position) & ((1U << size) - 1));
+ return static_cast<T>((value >> position) & ((kUwordOne << size) - 1));
}
// Returns a uword with the bit field value encoded based on the
« no previous file with comments | « no previous file | vm/globals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698