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

Side by Side Diff: src/utils.h

Issue 9295047: Revert 10542 (boot time memory reduction) due to map alignment (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/store-buffer.cc ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 // Compare function to compare the object pointer value of two 146 // Compare function to compare the object pointer value of two
147 // handlified objects. The handles are passed as pointers to the 147 // handlified objects. The handles are passed as pointers to the
148 // handles. 148 // handles.
149 template<typename T> class Handle; // Forward declaration. 149 template<typename T> class Handle; // Forward declaration.
150 template <typename T> 150 template <typename T>
151 int HandleObjectPointerCompare(const Handle<T>* a, const Handle<T>* b) { 151 int HandleObjectPointerCompare(const Handle<T>* a, const Handle<T>* b) {
152 return Compare<T*>(*(*a), *(*b)); 152 return Compare<T*>(*(*a), *(*b));
153 } 153 }
154 154
155 155
156 template<typename int_type> 156 // Returns the smallest power of two which is >= x. If you pass in a
157 inline int RoundUpToPowerOf2(int_type x_argument) { 157 // number that is already a power of two, it is returned as is.
158 uintptr_t x = static_cast<uintptr_t>(x_argument); 158 // Implementation is from "Hacker's Delight" by Henry S. Warren, Jr.,
159 // figure 3-3, page 48, where the function is called clp2.
160 inline uint32_t RoundUpToPowerOf2(uint32_t x) {
159 ASSERT(x <= 0x80000000u); 161 ASSERT(x <= 0x80000000u);
160 x = x - 1; 162 x = x - 1;
161 x = x | (x >> 1); 163 x = x | (x >> 1);
162 x = x | (x >> 2); 164 x = x | (x >> 2);
163 x = x | (x >> 4); 165 x = x | (x >> 4);
164 x = x | (x >> 8); 166 x = x | (x >> 8);
165 x = x | (x >> 16); 167 x = x | (x >> 16);
166 return static_cast<int_type>(x + 1); 168 return x + 1;
167 } 169 }
168 170
169 171
170 inline uint32_t RoundDownToPowerOf2(uint32_t x) { 172 inline uint32_t RoundDownToPowerOf2(uint32_t x) {
171 uint32_t rounded_up = RoundUpToPowerOf2(x); 173 uint32_t rounded_up = RoundUpToPowerOf2(x);
172 if (rounded_up > x) return rounded_up >> 1; 174 if (rounded_up > x) return rounded_up >> 1;
173 return rounded_up; 175 return rounded_up;
174 } 176 }
175 177
176 178
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 ASSERT(element < static_cast<int>(sizeof(T) * CHAR_BIT)); 950 ASSERT(element < static_cast<int>(sizeof(T) * CHAR_BIT));
949 return 1 << element; 951 return 1 << element;
950 } 952 }
951 953
952 T bits_; 954 T bits_;
953 }; 955 };
954 956
955 } } // namespace v8::internal 957 } } // namespace v8::internal
956 958
957 #endif // V8_UTILS_H_ 959 #endif // V8_UTILS_H_
OLDNEW
« no previous file with comments | « src/store-buffer.cc ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698