diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2011-10-10 11:52:42 -0700 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2011-10-10 11:52:42 -0700 |
commit | 56e6952e639ba1557a5b22333788583e9e39fa29 (patch) | |
tree | 4937ad22037de82e7be0caf7d6bc2a4d4655db51 /deps/v8/src/utils.h | |
parent | 0fec21365612621cedaabeec6300d97e49c601c0 (diff) | |
download | node-new-56e6952e639ba1557a5b22333788583e9e39fa29.tar.gz |
Upgrade V8 to 3.6.6
Diffstat (limited to 'deps/v8/src/utils.h')
-rw-r--r-- | deps/v8/src/utils.h | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/deps/v8/src/utils.h b/deps/v8/src/utils.h index 26c522b89f..a523118a39 100644 --- a/deps/v8/src/utils.h +++ b/deps/v8/src/utils.h @@ -113,7 +113,7 @@ static inline T AddressFrom(intptr_t x) { // Return the largest multiple of m which is <= x. template <typename T> -static inline T RoundDown(T x, int m) { +static inline T RoundDown(T x, intptr_t m) { ASSERT(IsPowerOf2(m)); return AddressFrom<T>(OffsetFrom(x) & -m); } @@ -121,8 +121,8 @@ static inline T RoundDown(T x, int m) { // Return the smallest multiple of m which is >= x. template <typename T> -static inline T RoundUp(T x, int m) { - return RoundDown(x + m - 1, m); +static inline T RoundUp(T x, intptr_t m) { + return RoundDown<T>(static_cast<T>(x + m - 1), m); } @@ -159,9 +159,15 @@ static inline uint32_t RoundUpToPowerOf2(uint32_t x) { } +static inline uint32_t RoundDownToPowerOf2(uint32_t x) { + uint32_t rounded_up = RoundUpToPowerOf2(x); + if (rounded_up > x) return rounded_up >> 1; + return rounded_up; +} -template <typename T> -static inline bool IsAligned(T value, T alignment) { + +template <typename T, typename U> +static inline bool IsAligned(T value, U alignment) { ASSERT(IsPowerOf2(alignment)); return (value & (alignment - 1)) == 0; } @@ -170,7 +176,7 @@ static inline bool IsAligned(T value, T alignment) { // Returns true if (addr + offset) is aligned. static inline bool IsAddressAligned(Address addr, intptr_t alignment, - int offset) { + int offset = 0) { intptr_t offs = OffsetFrom(addr + offset); return IsAligned(offs, alignment); } |