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

Unified Diff: src/utils.h

Issue 8404030: Version 3.7.1 (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 9 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/type-info.cc ('k') | src/v8.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils.h
===================================================================
--- src/utils.h (revision 9808)
+++ src/utils.h (working copy)
@@ -143,6 +143,16 @@
}
+// Compare function to compare the object pointer value of two
+// handlified objects. The handles are passed as pointers to the
+// handles.
+template<typename T> class Handle; // Forward declaration.
+template <typename T>
+static int HandleObjectPointerCompare(const Handle<T>* a, const Handle<T>* b) {
+ return Compare<T*>(*(*a), *(*b));
+}
+
+
// Returns the smallest power of two which is >= x. If you pass in a
// number that is already a power of two, it is returned as is.
// Implementation is from "Hacker's Delight" by Henry S. Warren, Jr.,
@@ -168,7 +178,6 @@
template <typename T, typename U>
static inline bool IsAligned(T value, U alignment) {
- ASSERT(IsPowerOf2(alignment));
return (value & (alignment - 1)) == 0;
}
@@ -257,6 +266,18 @@
}
+static inline uint32_t ComputeLongHash(uint64_t key) {
+ uint64_t hash = key;
+ hash = ~hash + (hash << 18); // hash = (hash << 18) - hash - 1;
+ hash = hash ^ (hash >> 31);
+ hash = hash * 21; // hash = (hash + (hash << 2)) + (hash << 4);
+ hash = hash ^ (hash >> 11);
+ hash = hash + (hash << 6);
+ hash = hash ^ (hash >> 22);
+ return (uint32_t) hash;
+}
+
+
static inline uint32_t ComputePointerHash(void* ptr) {
return ComputeIntegerHash(
static_cast<uint32_t>(reinterpret_cast<intptr_t>(ptr)));
« no previous file with comments | « src/type-info.cc ('k') | src/v8.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698