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

Side by Side Diff: src/utils.h

Issue 9148006: [objects] seed NumberDictionary (only ia32 now) Base URL: gh:v8/v8@master
Patch Set: added test, decoupled code Created 8 years, 11 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
OLDNEW
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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 return static_cast<T>((value & kMask) >> shift); 247 return static_cast<T>((value & kMask) >> shift);
248 } 248 }
249 }; 249 };
250 250
251 251
252 // ---------------------------------------------------------------------------- 252 // ----------------------------------------------------------------------------
253 // Hash function. 253 // Hash function.
254 254
255 // Thomas Wang, Integer Hash Functions. 255 // Thomas Wang, Integer Hash Functions.
256 // http://www.concentric.net/~Ttwang/tech/inthash.htm 256 // http://www.concentric.net/~Ttwang/tech/inthash.htm
257 inline uint32_t ComputeIntegerHash(uint32_t key) { 257 inline uint32_t ComputeIntegerHash(uint32_t key, uint32_t seed = 0) {
Erik Corry 2012/01/10 11:53:16 No default arguments.
258 uint32_t hash = key; 258 uint32_t hash = key;
259 hash = hash ^ seed;
259 hash = ~hash + (hash << 15); // hash = (hash << 15) - hash - 1; 260 hash = ~hash + (hash << 15); // hash = (hash << 15) - hash - 1;
260 hash = hash ^ (hash >> 12); 261 hash = hash ^ (hash >> 12);
261 hash = hash + (hash << 2); 262 hash = hash + (hash << 2);
262 hash = hash ^ (hash >> 4); 263 hash = hash ^ (hash >> 4);
263 hash = hash * 2057; // hash = (hash + (hash << 3)) + (hash << 11); 264 hash = hash * 2057; // hash = (hash + (hash << 3)) + (hash << 11);
264 hash = hash ^ (hash >> 16); 265 hash = hash ^ (hash >> 16);
265 return hash; 266 return hash;
266 } 267 }
267 268
268 269
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 ASSERT(element < static_cast<int>(sizeof(T) * CHAR_BIT)); 939 ASSERT(element < static_cast<int>(sizeof(T) * CHAR_BIT));
939 return 1 << element; 940 return 1 << element;
940 } 941 }
941 942
942 T bits_; 943 T bits_;
943 }; 944 };
944 945
945 } } // namespace v8::internal 946 } } // namespace v8::internal
946 947
947 #endif // V8_UTILS_H_ 948 #endif // V8_UTILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698