OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 hash = ~hash + (hash << 15); // hash = (hash << 15) - hash - 1; | 259 hash = ~hash + (hash << 15); // hash = (hash << 15) - hash - 1; |
260 hash = hash ^ (hash >> 12); | 260 hash = hash ^ (hash >> 12); |
261 hash = hash + (hash << 2); | 261 hash = hash + (hash << 2); |
262 hash = hash ^ (hash >> 4); | 262 hash = hash ^ (hash >> 4); |
263 hash = hash * 2057; // hash = (hash + (hash << 3)) + (hash << 11); | 263 hash = hash * 2057; // hash = (hash + (hash << 3)) + (hash << 11); |
264 hash = hash ^ (hash >> 16); | 264 hash = hash ^ (hash >> 16); |
265 return hash; | 265 return hash; |
266 } | 266 } |
267 | 267 |
268 | 268 |
| 269 static inline uint32_t ComputeLongHash(uint64_t key) { |
| 270 uint64_t hash = key; |
| 271 hash = ~hash + (hash << 18); // hash = (hash << 18) - hash - 1; |
| 272 hash = hash ^ (hash >> 31); |
| 273 hash = hash * 21; // hash = (hash + (hash << 2)) + (hash << 4); |
| 274 hash = hash ^ (hash >> 11); |
| 275 hash = hash + (hash << 6); |
| 276 hash = hash ^ (hash >> 22); |
| 277 return (uint32_t) hash; |
| 278 } |
| 279 |
| 280 |
269 static inline uint32_t ComputePointerHash(void* ptr) { | 281 static inline uint32_t ComputePointerHash(void* ptr) { |
270 return ComputeIntegerHash( | 282 return ComputeIntegerHash( |
271 static_cast<uint32_t>(reinterpret_cast<intptr_t>(ptr))); | 283 static_cast<uint32_t>(reinterpret_cast<intptr_t>(ptr))); |
272 } | 284 } |
273 | 285 |
274 | 286 |
275 // ---------------------------------------------------------------------------- | 287 // ---------------------------------------------------------------------------- |
276 // Miscellaneous | 288 // Miscellaneous |
277 | 289 |
278 // A static resource holds a static instance that can be reserved in | 290 // A static resource holds a static instance that can be reserved in |
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
926 ASSERT(element < static_cast<int>(sizeof(T) * CHAR_BIT)); | 938 ASSERT(element < static_cast<int>(sizeof(T) * CHAR_BIT)); |
927 return 1 << element; | 939 return 1 << element; |
928 } | 940 } |
929 | 941 |
930 T bits_; | 942 T bits_; |
931 }; | 943 }; |
932 | 944 |
933 } } // namespace v8::internal | 945 } } // namespace v8::internal |
934 | 946 |
935 #endif // V8_UTILS_H_ | 947 #endif // V8_UTILS_H_ |
OLD | NEW |