| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_UTILS_H_ | 5 #ifndef V8_UTILS_H_ |
| 6 #define V8_UTILS_H_ | 6 #define V8_UTILS_H_ |
| 7 | 7 |
| 8 #include <limits.h> | 8 #include <limits.h> |
| 9 #include <stdlib.h> | 9 #include <stdlib.h> |
| 10 #include <string.h> | 10 #include <string.h> |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 // http://www.concentric.net/~Ttwang/tech/inthash.htm | 333 // http://www.concentric.net/~Ttwang/tech/inthash.htm |
| 334 inline uint32_t ComputeIntegerHash(uint32_t key, uint32_t seed) { | 334 inline uint32_t ComputeIntegerHash(uint32_t key, uint32_t seed) { |
| 335 uint32_t hash = key; | 335 uint32_t hash = key; |
| 336 hash = hash ^ seed; | 336 hash = hash ^ seed; |
| 337 hash = ~hash + (hash << 15); // hash = (hash << 15) - hash - 1; | 337 hash = ~hash + (hash << 15); // hash = (hash << 15) - hash - 1; |
| 338 hash = hash ^ (hash >> 12); | 338 hash = hash ^ (hash >> 12); |
| 339 hash = hash + (hash << 2); | 339 hash = hash + (hash << 2); |
| 340 hash = hash ^ (hash >> 4); | 340 hash = hash ^ (hash >> 4); |
| 341 hash = hash * 2057; // hash = (hash + (hash << 3)) + (hash << 11); | 341 hash = hash * 2057; // hash = (hash + (hash << 3)) + (hash << 11); |
| 342 hash = hash ^ (hash >> 16); | 342 hash = hash ^ (hash >> 16); |
| 343 return hash; | 343 return hash & 0x3fffffff; |
| 344 } | 344 } |
| 345 | 345 |
| 346 | 346 |
| 347 inline uint32_t ComputeLongHash(uint64_t key) { | 347 inline uint32_t ComputeLongHash(uint64_t key) { |
| 348 uint64_t hash = key; | 348 uint64_t hash = key; |
| 349 hash = ~hash + (hash << 18); // hash = (hash << 18) - hash - 1; | 349 hash = ~hash + (hash << 18); // hash = (hash << 18) - hash - 1; |
| 350 hash = hash ^ (hash >> 31); | 350 hash = hash ^ (hash >> 31); |
| 351 hash = hash * 21; // hash = (hash + (hash << 2)) + (hash << 4); | 351 hash = hash * 21; // hash = (hash + (hash << 2)) + (hash << 4); |
| 352 hash = hash ^ (hash >> 11); | 352 hash = hash ^ (hash >> 11); |
| 353 hash = hash + (hash << 6); | 353 hash = hash + (hash << 6); |
| (...skipping 1351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1705 // Takes the address of the limit variable in order to find out where | 1705 // Takes the address of the limit variable in order to find out where |
| 1706 // the top of stack is right now. | 1706 // the top of stack is right now. |
| 1707 uintptr_t limit = reinterpret_cast<uintptr_t>(&limit); | 1707 uintptr_t limit = reinterpret_cast<uintptr_t>(&limit); |
| 1708 return limit; | 1708 return limit; |
| 1709 } | 1709 } |
| 1710 | 1710 |
| 1711 } // namespace internal | 1711 } // namespace internal |
| 1712 } // namespace v8 | 1712 } // namespace v8 |
| 1713 | 1713 |
| 1714 #endif // V8_UTILS_H_ | 1714 #endif // V8_UTILS_H_ |
| OLD | NEW |