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

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

Issue 712993005: Infer range for BIT_XOR. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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 | « runtime/lib/integers.cc ('k') | runtime/vm/flow_graph_compiler_arm64.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 (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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 template<typename T> 74 template<typename T>
75 static inline T* RoundUp(T* x, intptr_t n) { 75 static inline T* RoundUp(T* x, intptr_t 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 uintptr_t RoundUpToPowerOfTwo(uintptr_t x); 79 static uintptr_t RoundUpToPowerOfTwo(uintptr_t x);
80 static int CountOneBits(uint32_t x); 80 static int CountOneBits(uint32_t x);
81 81
82 static int HighestBit(int64_t v); 82 static int HighestBit(int64_t v);
83 83
84 static int BitLength(int64_t value) {
85 // Flip bits if negative (-1 becomes 0).
86 value ^= value >> (8 * sizeof(value) - 1);
87 return (value == 0) ? 0 : (Utils::HighestBit(value) + 1);
88 }
89
84 static int CountLeadingZeros(uword x); 90 static int CountLeadingZeros(uword x);
85 static int CountTrailingZeros(uword x); 91 static int CountTrailingZeros(uword x);
86 92
87 // Computes a hash value for the given string. 93 // Computes a hash value for the given string.
88 static uint32_t StringHash(const char* data, int length); 94 static uint32_t StringHash(const char* data, int length);
89 95
90 // Computes a hash value for the given word. 96 // Computes a hash value for the given word.
91 static uint32_t WordHash(intptr_t key); 97 static uint32_t WordHash(intptr_t key);
92 98
93 // Check whether an N-bit two's-complement representation can hold value. 99 // Check whether an N-bit two's-complement representation can hold value.
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 #include "platform/utils_linux.h" 211 #include "platform/utils_linux.h"
206 #elif defined(TARGET_OS_MACOS) 212 #elif defined(TARGET_OS_MACOS)
207 #include "platform/utils_macos.h" 213 #include "platform/utils_macos.h"
208 #elif defined(TARGET_OS_WINDOWS) 214 #elif defined(TARGET_OS_WINDOWS)
209 #include "platform/utils_win.h" 215 #include "platform/utils_win.h"
210 #else 216 #else
211 #error Unknown target os. 217 #error Unknown target os.
212 #endif 218 #endif
213 219
214 #endif // PLATFORM_UTILS_H_ 220 #endif // PLATFORM_UTILS_H_
OLDNEW
« no previous file with comments | « runtime/lib/integers.cc ('k') | runtime/vm/flow_graph_compiler_arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698