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

Unified Diff: src/utils.h

Issue 660095: Merge revision 3813 to 3930 from bleeding_edge to partial snapshots branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/partial_snapshots/
Patch Set: '' Created 10 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/top.cc ('k') | src/utils.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils.h
===================================================================
--- src/utils.h (revision 3935)
+++ src/utils.h (working copy)
@@ -157,7 +157,9 @@
// Returns a uint32_t mask of bit field.
static uint32_t mask() {
- return (1U << (size + shift)) - (1U << shift);
+ // To use all bits of a uint32 in a bitfield without compiler warnings we
+ // have to compute 2^32 without using a shift count of 32.
+ return ((1U << shift) << size) - (1U << shift);
}
// Returns a uint32_t with the bit field value encoded.
@@ -168,54 +170,12 @@
// Extracts the bit field from the value.
static T decode(uint32_t value) {
- return static_cast<T>((value >> shift) & ((1U << (size)) - 1));
+ return static_cast<T>((value & mask()) >> shift);
}
};
// ----------------------------------------------------------------------------
-// Support for compressed, machine-independent encoding
-// and decoding of integer values of arbitrary size.
-
-// Encoding and decoding from/to a buffer at position p;
-// the result is the position after the encoded integer.
-// Small signed integers in the range -64 <= x && x < 64
-// are encoded in 1 byte; larger values are encoded in 2
-// or more bytes. At most sizeof(int) + 1 bytes are used
-// in the worst case.
-byte* EncodeInt(byte* p, int x);
-byte* DecodeInt(byte* p, int* x);
-
-
-// Encoding and decoding from/to a buffer at position p - 1
-// moving backward; the result is the position of the last
-// byte written. These routines are useful to read/write
-// into a buffer starting at the end of the buffer.
-byte* EncodeUnsignedIntBackward(byte* p, unsigned int x);
-
-// The decoding function is inlined since its performance is
-// important to mark-sweep garbage collection.
-inline byte* DecodeUnsignedIntBackward(byte* p, unsigned int* x) {
- byte b = *--p;
- if (b >= 128) {
- *x = static_cast<unsigned int>(b) - 128;
- return p;
- }
- unsigned int r = static_cast<unsigned int>(b);
- unsigned int s = 7;
- b = *--p;
- while (b < 128) {
- r |= static_cast<unsigned int>(b) << s;
- s += 7;
- b = *--p;
- }
- // b >= 128
- *x = r | ((static_cast<unsigned int>(b) - 128) << s);
- return p;
-}
-
-
-// ----------------------------------------------------------------------------
// Hash function.
uint32_t ComputeIntegerHash(uint32_t key);
« no previous file with comments | « src/top.cc ('k') | src/utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698