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

Unified Diff: src/utils.h

Issue 7945009: Merge experimental/gc branch to the bleeding_edge. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 years, 3 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/store-buffer-inl.h ('k') | src/v8.h » ('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 9327)
+++ src/utils.h (working copy)
@@ -113,7 +113,7 @@
// 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 @@
// 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 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 @@
// 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);
}
« no previous file with comments | « src/store-buffer-inl.h ('k') | src/v8.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698