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

Unified Diff: src/utils.h

Issue 9017009: Reduce signal sender thread stack size to 32k. Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
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
« src/spaces.cc ('K') | « src/store-buffer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils.h
===================================================================
--- src/utils.h (revision 10282)
+++ src/utils.h (working copy)
@@ -157,7 +157,8 @@
// number that is already a power of two, it is returned as is.
// Implementation is from "Hacker's Delight" by Henry S. Warren, Jr.,
// figure 3-3, page 48, where the function is called clp2.
-inline uint32_t RoundUpToPowerOf2(uint32_t x) {
+template<typename uint_type>
+inline uint_type RoundUpToPowerOf2(uint_type x) {
ASSERT(x <= 0x80000000u);
x = x - 1;
x = x | (x >> 1);
@@ -169,6 +170,20 @@
}
+template<typename int_type>
+inline int SignedRoundUpToPowerOf2(int_type x_argument) {
+ uintptr_t x = static_cast<uintptr_t>(x_argument);
Vyacheslav Egorov (Chromium) 2011/12/21 13:22:12 inline int SignedRoundUpToPowerOf2(int_type x_argu
+ ASSERT(x <= 0x80000000u);
+ x = x - 1;
+ x = x | (x >> 1);
+ x = x | (x >> 2);
+ x = x | (x >> 4);
+ x = x | (x >> 8);
+ x = x | (x >> 16);
+ return static_cast<int>(x + 1);
+}
+
+
inline uint32_t RoundDownToPowerOf2(uint32_t x) {
uint32_t rounded_up = RoundUpToPowerOf2(x);
if (rounded_up > x) return rounded_up >> 1;
« src/spaces.cc ('K') | « src/store-buffer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698