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

Side by Side Diff: runtime/platform/utils.h

Issue 10806078: Improve the performance of bit set searches with a compiler intrinsic. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address review comments Created 8 years, 5 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 | « no previous file | runtime/platform/utils_linux.h » ('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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef PLATFORM_UTILS_H_ 5 #ifndef PLATFORM_UTILS_H_
6 #define PLATFORM_UTILS_H_ 6 #define PLATFORM_UTILS_H_
7 7
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "platform/globals.h" 9 #include "platform/globals.h"
10 10
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 } 72 }
73 73
74 template<typename T> 74 template<typename T>
75 static inline T* RoundUp(T* x, int n) { 75 static inline T* RoundUp(T* x, int n) {
76 return reinterpret_cast<T*>(RoundUp(reinterpret_cast<uword>(x), n)); 76 return reinterpret_cast<T*>(RoundUp(reinterpret_cast<uword>(x), n));
77 } 77 }
78 78
79 static uint32_t RoundUpToPowerOfTwo(uint32_t x); 79 static uint32_t RoundUpToPowerOfTwo(uint32_t x);
80 static int CountOneBits(uint32_t x); 80 static int CountOneBits(uint32_t x);
81 81
82 static int CountTrailingZeros(uint32_t x);
83 static int CountTrailingZeros(uint64_t x);
84
82 // Computes a hash value for the given string. 85 // Computes a hash value for the given string.
83 static uint32_t StringHash(const char* data, int length); 86 static uint32_t StringHash(const char* data, int length);
84 87
85 // Computes a hash value for the given word. 88 // Computes a hash value for the given word.
86 static uint32_t WordHash(word key); 89 static uint32_t WordHash(word key);
87 90
88 // Check whether an N-bit two's-complement representation can hold value. 91 // Check whether an N-bit two's-complement representation can hold value.
89 template<typename T> 92 template<typename T>
90 static inline bool IsInt(int N, T value) { 93 static inline bool IsInt(int N, T value) {
91 ASSERT((0 < N) && 94 ASSERT((0 < N) &&
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 intptr_t length) { 166 intptr_t length) {
164 return offset >= 0 && 167 return offset >= 0 &&
165 count >= 0 && 168 count >= 0 &&
166 length >= 0 && 169 length >= 0 &&
167 count <= (length - offset); 170 count <= (length - offset);
168 } 171 }
169 }; 172 };
170 173
171 } // namespace dart 174 } // namespace dart
172 175
176 #if defined(TARGET_OS_LINUX)
177 #include "platform/utils_linux.h"
178 #elif defined(TARGET_OS_MACOS)
179 #include "platform/utils_macos.h"
180 #elif defined(TARGET_OS_WINDOWS)
181 #include "platform/utils_win.h"
182 #else
183 #error Unknown target os.
184 #endif
185
173 #endif // PLATFORM_UTILS_H_ 186 #endif // PLATFORM_UTILS_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/platform/utils_linux.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698