Bug 1379351 - Improve some of the XPConnect hash routines; r=mccr8
authorEhsan Akhgari <ehsan@mozilla.com>
Sat, 08 Jul 2017 00:47:51 -0400
changeset 418327 b0bdb045b7ec192f0c129b161c865552d8f5cc53
parent 418326 190aa46c11c4463e5227b486ef9d66bcd9622b96
child 418328 2604d9b17f09e6f4adc63814dfbdcb8402c6b8c1
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1379351
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1379351 - Improve some of the XPConnect hash routines; r=mccr8
js/xpconnect/src/XPCMaps.cpp
js/xpconnect/src/XPCWrappedNativeInfo.cpp
--- a/js/xpconnect/src/XPCMaps.cpp
+++ b/js/xpconnect/src/XPCMaps.cpp
@@ -12,23 +12,23 @@
 
 #include "js/HashTable.h"
 
 using namespace mozilla;
 
 /***************************************************************************/
 // static shared...
 
-// Note this is returning the bit pattern of the first part of the nsID, not
-// the pointer to the nsID.
+// Note this is returning the hash of the bit pattern of the first part of the nsID, not
+// the hash of the pointer to the nsID.
 
 static PLDHashNumber
 HashIIDPtrKey(const void* key)
 {
-    return *((js::HashNumber*)key);
+    return HashGeneric(*((uintptr_t*)key));
 }
 
 static bool
 MatchIIDPtrKey(const PLDHashEntryHdr* entry, const void* key)
 {
     return ((const nsID*)key)->
                 Equals(*((const nsID*)((PLDHashEntryStub*)entry)->key));
 }
--- a/js/xpconnect/src/XPCWrappedNativeInfo.cpp
+++ b/js/xpconnect/src/XPCWrappedNativeInfo.cpp
@@ -8,16 +8,17 @@
 
 #include "xpcprivate.h"
 #include "jswrapper.h"
 
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/XPTInterfaceInfoManager.h"
 #include "nsIScriptError.h"
 #include "nsPrintfCString.h"
+#include "nsPointerHashKeys.h"
 
 using namespace JS;
 using namespace mozilla;
 
 /***************************************************************************/
 
 // XPCNativeMember
 
@@ -424,17 +425,17 @@ XPCNativeInterface::DebugDump(int16_t de
 }
 
 /***************************************************************************/
 // XPCNativeSetKey
 
 static PLDHashNumber
 HashPointer(const void* ptr)
 {
-    return NS_PTR_TO_UINT32(ptr) >> 2;
+    return nsPtrHashKey<const void>::HashKey(ptr);
 }
 
 PLDHashNumber
 XPCNativeSetKey::Hash() const
 {
     PLDHashNumber h = 0;
 
     if (mBaseSet) {