Bug 647367 - Sequester jshash.{h,cpp} in js/jsd/ (attempt 2). r=luke.
authorNicholas Nethercote <nnethercote@mozilla.com>
Wed, 18 Jul 2012 17:38:10 -0700
changeset 101937 3c589e94b3e00d357ad8d3dba86c439430c47706
parent 101936 beb7a4c0d06f6dbec6cff778cd64df780b3f1f4b
child 101938 9249f0c9ca93f2f51bf7559a19725a8469f28ae0
child 101941 d65e9bb1608ccab34bf02f71eb4fc18ee0716287
push id994
push userttaubert@mozilla.com
push dateThu, 09 Aug 2012 18:49:12 +0000
treeherderfx-team@4770bca01046 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs647367
milestone17.0a1
Bug 647367 - Sequester jshash.{h,cpp} in js/jsd/ (attempt 2). r=luke.
js/jsd/Makefile.in
js/jsd/jshash.cpp
js/jsd/jshash.h
js/src/Makefile.in
js/src/jsatom.cpp
js/src/jsatom.h
js/src/jsgc.cpp
js/src/jshash.cpp
js/src/jshash.h
js/src/jsobj.cpp
js/src/jsobj.h
js/src/jsscope.cpp
js/src/jsscript.h
js/src/jsstr.cpp
js/src/jstypedarray.cpp
js/xpconnect/src/XPCMaps.cpp
mfbt/HashFunctions.h
--- a/js/jsd/Makefile.in
+++ b/js/jsd/Makefile.in
@@ -12,17 +12,19 @@ VPATH		= @srcdir@
 srcdir		= @srcdir@
 relativesrcdir  = @relativesrcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE		= jsdebug
 LIBRARY_NAME	= jsd
 DIRS	= idl
-CPPSRCS	 = jsd_xpc.cpp
+CPPSRCS	 = \
+		jsd_xpc.cpp \
+		jshash.cpp
 IS_COMPONENT = 1
 LIBXUL_LIBRARY = 1
 
 MODULE_NAME = JavaScript_Debugger
 EXPORT_LIBRARY = 1
 
 XPCSHELL_TESTS  = test
 
rename from js/src/jshash.cpp
rename to js/jsd/jshash.cpp
--- a/js/src/jshash.cpp
+++ b/js/jsd/jshash.cpp
@@ -56,17 +56,17 @@ DefaultFreeEntry(void *pool, JSHashEntry
         UnwantedForeground::free_(he);
 }
 
 static JSHashAllocOps defaultHashAllocOps = {
     DefaultAllocTable, DefaultFreeTable,
     DefaultAllocEntry, DefaultFreeEntry
 };
 
-JS_PUBLIC_API(JSHashTable *)
+JSHashTable *
 JS_NewHashTable(uint32_t n, JSHashFunction keyHash,
                 JSHashComparator keyCompare, JSHashComparator valueCompare,
                 JSHashAllocOps *allocOps, void *allocPriv)
 {
     JSHashTable *ht;
     size_t nb;
 
     if (n <= MINBUCKETS) {
@@ -96,17 +96,17 @@ JS_NewHashTable(uint32_t n, JSHashFuncti
     ht->keyHash = keyHash;
     ht->keyCompare = keyCompare;
     ht->valueCompare = valueCompare;
     ht->allocOps = allocOps;
     ht->allocPriv = allocPriv;
     return ht;
 }
 
-JS_PUBLIC_API(void)
+void
 JS_HashTableDestroy(JSHashTable *ht)
 {
     uint32_t i, n;
     JSHashEntry *he, **hep;
     JSHashAllocOps *allocOps = ht->allocOps;
     void *allocPriv = ht->allocPriv;
 
     n = NBUCKETS(ht);
@@ -128,17 +128,17 @@ JS_HashTableDestroy(JSHashTable *ht)
 }
 
 /*
  * Multiplicative hash, from Knuth 6.4.
  */
 #define BUCKET_HEAD(ht, keyHash)                                              \
     (&(ht)->buckets[((keyHash) * JS_GOLDEN_RATIO) >> (ht)->shift])
 
-JS_PUBLIC_API(JSHashEntry **)
+JSHashEntry **
 JS_HashTableRawLookup(JSHashTable *ht, JSHashNumber keyHash, const void *key)
 {
     JSHashEntry *he, **hep, **hep0;
 
 #ifdef JS_HASHMETER
     ht->nlookups++;
 #endif
     hep = hep0 = BUCKET_HEAD(ht, keyHash);
@@ -207,17 +207,17 @@ Resize(JSHashTable *ht, uint32_t newshif
 #ifdef DEBUG
     memset(oldbuckets, 0xDB, nold * sizeof oldbuckets[0]);
 #endif
     ht->allocOps->freeTable(ht->allocPriv, oldbuckets,
                             nold * sizeof oldbuckets[0]);
     return JS_TRUE;
 }
 
-JS_PUBLIC_API(JSHashEntry *)
+JSHashEntry *
 JS_HashTableRawAdd(JSHashTable *ht, JSHashEntry **&hep,
                    JSHashNumber keyHash, const void *key, void *value)
 {
     uint32_t n;
     JSHashEntry *he;
 
     /* Grow the table if it is overloaded */
     n = NBUCKETS(ht);
@@ -238,17 +238,17 @@ JS_HashTableRawAdd(JSHashTable *ht, JSHa
     he->key = key;
     he->value = value;
     he->next = *hep;
     *hep = he;
     ht->nentries++;
     return he;
 }
 
-JS_PUBLIC_API(JSHashEntry *)
+JSHashEntry *
 JS_HashTableAdd(JSHashTable *ht, const void *key, void *value)
 {
     JSHashNumber keyHash;
     JSHashEntry *he, **hep;
 
     keyHash = ht->keyHash(key);
     hep = JS_HashTableRawLookup(ht, keyHash, key);
     if ((he = *hep) != NULL) {
@@ -260,17 +260,17 @@ JS_HashTableAdd(JSHashTable *ht, const v
         if (he->value)
             ht->allocOps->freeEntry(ht->allocPriv, he, HT_FREE_VALUE);
         he->value = value;
         return he;
     }
     return JS_HashTableRawAdd(ht, hep, keyHash, key, value);
 }
 
-JS_PUBLIC_API(void)
+void
 JS_HashTableRawRemove(JSHashTable *ht, JSHashEntry **hep, JSHashEntry *he)
 {
     uint32_t n;
 
     *hep = he->next;
     ht->allocOps->freeEntry(ht->allocPriv, he, HT_FREE_ENTRY);
 
     /* Shrink table if it's underloaded */
@@ -278,33 +278,33 @@ JS_HashTableRawRemove(JSHashTable *ht, J
     if (--ht->nentries < UNDERLOADED(n)) {
         Resize(ht, ht->shift + 1);
 #ifdef JS_HASHMETER
         ht->nshrinks++;
 #endif
     }
 }
 
-JS_PUBLIC_API(JSBool)
+JSBool
 JS_HashTableRemove(JSHashTable *ht, const void *key)
 {
     JSHashNumber keyHash;
     JSHashEntry *he, **hep;
 
     keyHash = ht->keyHash(key);
     hep = JS_HashTableRawLookup(ht, keyHash, key);
     if ((he = *hep) == NULL)
         return JS_FALSE;
 
     /* Hit; remove element */
     JS_HashTableRawRemove(ht, hep, he);
     return JS_TRUE;
 }
 
-JS_PUBLIC_API(void *)
+void *
 JS_HashTableLookup(JSHashTable *ht, const void *key)
 {
     JSHashNumber keyHash;
     JSHashEntry *he, **hep;
 
     keyHash = ht->keyHash(key);
     hep = JS_HashTableRawLookup(ht, keyHash, key);
     if ((he = *hep) != NULL) {
@@ -313,17 +313,17 @@ JS_HashTableLookup(JSHashTable *ht, cons
     return NULL;
 }
 
 /*
 ** Iterate over the entries in the hash table calling func for each
 ** entry found. Stop if "f" says to (return value & JS_ENUMERATE_STOP).
 ** Return a count of the number of elements scanned.
 */
-JS_PUBLIC_API(int)
+int
 JS_HashTableEnumerateEntries(JSHashTable *ht, JSHashEnumerator f, void *arg)
 {
     JSHashEntry *he, **hep, **bucket;
     uint32_t nlimit, n, nbuckets, newlog2;
     int rv;
 
     nlimit = ht->nentries;
     n = 0;
@@ -362,17 +362,17 @@ out:
         }
     }
     return (int)n;
 }
 
 #ifdef JS_HASHMETER
 #include <stdio.h>
 
-JS_PUBLIC_API(void)
+void
 JS_HashTableDumpMeter(JSHashTable *ht, JSHashEnumerator dump, FILE *fp)
 {
     double sqsum, mean, sigma;
     uint32_t nchains, nbuckets;
     uint32_t i, n, maxChain, maxChainLen;
     JSHashEntry *he;
 
     sqsum = 0;
@@ -408,37 +408,37 @@ JS_HashTableDumpMeter(JSHashTable *ht, J
     fprintf(fp, "        max hash chain: [%u]\n", maxChain);
 
     for (he = ht->buckets[maxChain], i = 0; he; he = he->next, i++)
         if (dump(he, i, fp) != HT_ENUMERATE_NEXT)
             break;
 }
 #endif /* JS_HASHMETER */
 
-JS_PUBLIC_API(int)
+int
 JS_HashTableDump(JSHashTable *ht, JSHashEnumerator dump, FILE *fp)
 {
     int count;
 
     count = JS_HashTableEnumerateEntries(ht, dump, fp);
 #ifdef JS_HASHMETER
     JS_HashTableDumpMeter(ht, dump, fp);
 #endif
     return count;
 }
 
-JS_PUBLIC_API(JSHashNumber)
+JSHashNumber
 JS_HashString(const void *key)
 {
     JSHashNumber h;
     const unsigned char *s;
 
     h = 0;
     for (s = (const unsigned char *)key; *s; s++)
         h = JS_ROTATE_LEFT32(h, 4) ^ *s;
     return h;
 }
 
-JS_PUBLIC_API(int)
+int
 JS_CompareValues(const void *v1, const void *v2)
 {
     return v1 == v2;
 }
rename from js/src/jshash.h
rename to js/jsd/jshash.h
--- a/js/src/jshash.h
+++ b/js/jsd/jshash.h
@@ -65,56 +65,56 @@ struct JSHashTable {
     uint32_t            nshrinks;       /* number of table contractions */
 #endif
 };
 
 /*
  * Create a new hash table.
  * If allocOps is null, use default allocator ops built on top of malloc().
  */
-extern JS_PUBLIC_API(JSHashTable *)
+extern JSHashTable * 
 JS_NewHashTable(uint32_t n, JSHashFunction keyHash,
                 JSHashComparator keyCompare, JSHashComparator valueCompare,
                 JSHashAllocOps *allocOps, void *allocPriv);
 
-extern JS_PUBLIC_API(void)
+extern void
 JS_HashTableDestroy(JSHashTable *ht);
 
 /* Low level access methods */
-extern JS_PUBLIC_API(JSHashEntry **)
+extern JSHashEntry **
 JS_HashTableRawLookup(JSHashTable *ht, JSHashNumber keyHash, const void *key);
 
 #ifdef __cplusplus
-extern JS_PUBLIC_API(JSHashEntry *)
+extern JSHashEntry *
 JS_HashTableRawAdd(JSHashTable *ht, JSHashEntry **&hep, JSHashNumber keyHash,
                    const void *key, void *value);
 #endif
 
-extern JS_PUBLIC_API(void)
+extern void
 JS_HashTableRawRemove(JSHashTable *ht, JSHashEntry **hep, JSHashEntry *he);
 
 /* Higher level access methods */
-extern JS_PUBLIC_API(JSHashEntry *)
+extern JSHashEntry *
 JS_HashTableAdd(JSHashTable *ht, const void *key, void *value);
 
-extern JS_PUBLIC_API(JSBool)
+extern JSBool
 JS_HashTableRemove(JSHashTable *ht, const void *key);
 
-extern JS_PUBLIC_API(int)
+extern int
 JS_HashTableEnumerateEntries(JSHashTable *ht, JSHashEnumerator f, void *arg);
 
-extern JS_PUBLIC_API(void *)
+extern void *
 JS_HashTableLookup(JSHashTable *ht, const void *key);
 
-extern JS_PUBLIC_API(int)
+extern int
 JS_HashTableDump(JSHashTable *ht, JSHashEnumerator dump, FILE *fp);
 
 /* General-purpose C string hash function. */
-extern JS_PUBLIC_API(JSHashNumber)
+extern JSHashNumber
 JS_HashString(const void *key);
 
 /* Stub function just returns v1 == v2 */
-extern JS_PUBLIC_API(int)
+extern int
 JS_CompareValues(const void *v1, const void *v2);
 
 JS_END_EXTERN_C
 
 #endif /* jshash_h___ */
--- a/js/src/Makefile.in
+++ b/js/src/Makefile.in
@@ -77,17 +77,16 @@ CPPSRCS		= \
 		jsdbgapi.cpp \
 		jsdhash.cpp \
 		jsdtoa.cpp \
 		jsexn.cpp \
 		jsfriendapi.cpp \
 		jsfun.cpp \
 		jsgc.cpp \
 		jscrashreport.cpp \
-		jshash.cpp \
 		jsinfer.cpp \
 		jsinterp.cpp \
 		jsiter.cpp \
 		jslog2.cpp \
 		jsmath.cpp \
 		jsnativestack.cpp \
 		jsnum.cpp \
 		jsobj.cpp \
@@ -157,17 +156,16 @@ INSTALLED_HEADERS = \
 		jsatom.h \
 		jsatom.tbl \
 		jsclass.h \
 		jsclist.h \
 		jsdbgapi.h \
 		jsdhash.h \
 		jsfriendapi.h \
 		jsgc.h \
-		jshash.h \
 		jslock.h \
 		json.h \
 		jsproxy.h \
 		jsprf.h \
 		jsproto.tbl \
 		jsprvtd.h \
 		jspubtd.h \
 		jstypes.h \
--- a/js/src/jsatom.cpp
+++ b/js/src/jsatom.cpp
@@ -10,17 +10,16 @@
 #include <stdlib.h>
 #include <string.h>
 
 #include "mozilla/RangedPtr.h"
 #include "mozilla/Util.h"
 
 #include "jstypes.h"
 #include "jsutil.h"
-#include "jshash.h"
 #include "jsprf.h"
 #include "jsapi.h"
 #include "jsatom.h"
 #include "jscntxt.h"
 #include "jsgc.h"
 #include "jslock.h"
 #include "jsnum.h"
 #include "jsstr.h"
@@ -38,22 +37,16 @@
 #include "vm/Xdr.h"
 
 using namespace mozilla;
 using namespace js;
 using namespace js::gc;
 
 const size_t JSAtomState::commonAtomsOffset = offsetof(JSAtomState, emptyAtom);
 
-/*
- * ATOM_HASH assumes that JSHashNumber is 32-bit even on 64-bit systems.
- */
-JS_STATIC_ASSERT(sizeof(JSHashNumber) == 4);
-JS_STATIC_ASSERT(sizeof(JSAtom *) == JS_BYTES_PER_WORD);
-
 const char *
 js_AtomToPrintableString(JSContext *cx, JSAtom *atom, JSAutoByteString *bytes)
 {
     return js_ValueToPrintable(cx, StringValue(atom), bytes);
 }
 
 #define JS_PROTO(name,code,init) const char js_##name##_str[] = #name;
 #include "jsproto.tbl"
--- a/js/src/jsatom.h
+++ b/js/src/jsatom.h
@@ -7,22 +7,22 @@
 #ifndef jsatom_h___
 #define jsatom_h___
 
 #include <stddef.h>
 #include "jsversion.h"
 #include "jsalloc.h"
 #include "jsapi.h"
 #include "jsprvtd.h"
-#include "jshash.h"
 #include "jspubtd.h"
 #include "jslock.h"
 
 #include "gc/Barrier.h"
 #include "js/HashTable.h"
+#include "mozilla/HashFunctions.h"
 
 struct JSIdArray {
     int length;
     js::HeapId vector[1];    /* actually, length jsid words */
 };
 
 /* Engine-internal extensions of jsid */
 
@@ -78,33 +78,25 @@ JSID_IS_ATOM(jsid id, JSAtom *atom)
 }
 
 static JS_ALWAYS_INLINE JSAtom *
 JSID_TO_ATOM(jsid id)
 {
     return (JSAtom *)JSID_TO_STRING(id);
 }
 
-JS_STATIC_ASSERT(sizeof(JSHashNumber) == 4);
+JS_STATIC_ASSERT(sizeof(js::HashNumber) == 4);
 JS_STATIC_ASSERT(sizeof(jsid) == JS_BYTES_PER_WORD);
 
 namespace js {
 
-static JS_ALWAYS_INLINE JSHashNumber
+static JS_ALWAYS_INLINE js::HashNumber
 HashId(jsid id)
 {
-    JSHashNumber n =
-#if JS_BYTES_PER_WORD == 4
-        JSHashNumber(JSID_BITS(id));
-#elif JS_BYTES_PER_WORD == 8
-        JSHashNumber(JSID_BITS(id)) ^ JSHashNumber(JSID_BITS(id) >> 32);
-#else
-# error "Unsupported configuration"
-#endif
-    return n * JS_GOLDEN_RATIO;
+    return HashGeneric(JSID_BITS(id));
 }
 
 static JS_ALWAYS_INLINE Value
 IdToValue(jsid id)
 {
     if (JSID_IS_STRING(id))
         return StringValue(JSID_TO_STRING(id));
     if (JS_LIKELY(JSID_IS_INT(id)))
@@ -130,25 +122,16 @@ struct DefaultHasher<jsid>
     }
     static bool match(const jsid &id, const Lookup &l) {
         return id == l;
     }
 };
 
 }
 
-#if JS_BYTES_PER_WORD == 4
-# define ATOM_HASH(atom)          ((JSHashNumber)(atom) >> 2)
-#elif JS_BYTES_PER_WORD == 8
-# define ATOM_HASH(atom)          (((JSHashNumber)(uintptr_t)(atom) >> 3) ^   \
-                                   (JSHashNumber)((uintptr_t)(atom) >> 32))
-#else
-# error "Unsupported configuration"
-#endif
-
 /*
  * Return a printable, lossless char[] representation of a string-type atom.
  * The lifetime of the result matches the lifetime of bytes.
  */
 extern const char *
 js_AtomToPrintableString(JSContext *cx, JSAtom *atom, JSAutoByteString *bytes);
 
 namespace js {
--- a/js/src/jsgc.cpp
+++ b/js/src/jsgc.cpp
@@ -39,17 +39,16 @@
  * barriers on them.
  */
 
 #include <math.h>
 #include <string.h>     /* for memset used when DEBUG */
 
 #include "jstypes.h"
 #include "jsutil.h"
-#include "jshash.h"
 #include "jsclist.h"
 #include "jsprf.h"
 #include "jsapi.h"
 #include "jsatom.h"
 #include "jscompartment.h"
 #include "jscrashreport.h"
 #include "jscrashformat.h"
 #include "jscntxt.h"
--- a/js/src/jsobj.cpp
+++ b/js/src/jsobj.cpp
@@ -10,17 +10,16 @@
  */
 #include <stdlib.h>
 #include <string.h>
 
 #include "mozilla/Util.h"
 
 #include "jstypes.h"
 #include "jsutil.h"
-#include "jshash.h"
 #include "jsprf.h"
 #include "jsapi.h"
 #include "jsarray.h"
 #include "jsatom.h"
 #include "jsbool.h"
 #include "jscntxt.h"
 #include "jsversion.h"
 #include "jsfun.h"
--- a/js/src/jsobj.h
+++ b/js/src/jsobj.h
@@ -16,17 +16,16 @@
  * values, called slots.  The map/slot pointer pair is GC'ed, while the map
  * is reference counted and the slot vector is malloc'ed.
  */
 #include "jsapi.h"
 #include "jsatom.h"
 #include "jsclass.h"
 #include "jsfriendapi.h"
 #include "jsinfer.h"
-#include "jshash.h"
 #include "jspubtd.h"
 #include "jsprvtd.h"
 #include "jslock.h"
 
 #include "gc/Barrier.h"
 #include "gc/Heap.h"
 
 #include "vm/ObjectImpl.h"
--- a/js/src/jsscope.cpp
+++ b/js/src/jsscope.cpp
@@ -19,16 +19,17 @@
 #include "jscntxt.h"
 #include "jsdbgapi.h"
 #include "jslock.h"
 #include "jsnum.h"
 #include "jsobj.h"
 #include "jsscope.h"
 #include "jsstr.h"
 
+#include "js/HashTable.h"
 #include "js/MemoryMetrics.h"
 
 #include "jsatominlines.h"
 #include "jscntxtinlines.h"
 #include "jsobjinlines.h"
 #include "jsscopeinlines.h"
 
 using namespace js;
@@ -140,17 +141,17 @@ Shape::hashify(JSContext *cx)
  * size, so we simply make hash2 odd.
  */
 #define HASH1(hash0,shift)      ((hash0) >> (shift))
 #define HASH2(hash0,log2,shift) ((((hash0) << (log2)) >> (shift)) | 1)
 
 Shape **
 ShapeTable::search(jsid id, bool adding)
 {
-    JSHashNumber hash0, hash1, hash2;
+    js::HashNumber hash0, hash1, hash2;
     int sizeLog2;
     Shape *stored, *shape, **spp, **firstRemoved;
     uint32_t sizeMask;
 
     JS_ASSERT(entries);
     JS_ASSERT(!JSID_IS_EMPTY(id));
 
     /* Compute the primary hash address. */
--- a/js/src/jsscript.h
+++ b/js/src/jsscript.h
@@ -1160,17 +1160,17 @@ struct ScriptFilenameEntry
     static ScriptFilenameEntry *fromFilename(const char *filename) {
         return (ScriptFilenameEntry *)(filename - offsetof(ScriptFilenameEntry, filename));
     }
 };
 
 struct ScriptFilenameHasher
 {
     typedef const char *Lookup;
-    static HashNumber hash(const char *l) { return JS_HashString(l); }
+    static HashNumber hash(const char *l) { return mozilla::HashString(l); }
     static bool match(const ScriptFilenameEntry *e, const char *l) {
         return strcmp(e->filename, l) == 0;
     }
 };
 
 typedef HashSet<ScriptFilenameEntry *,
                 ScriptFilenameHasher,
                 SystemAllocPolicy> ScriptFilenameTable;
--- a/js/src/jsstr.cpp
+++ b/js/src/jsstr.cpp
@@ -18,17 +18,16 @@
 
 #include "mozilla/Attributes.h"
 #include "mozilla/FloatingPoint.h"
 
 #include <stdlib.h>
 #include <string.h>
 #include "jstypes.h"
 #include "jsutil.h"
-#include "jshash.h"
 #include "jsprf.h"
 #include "jsapi.h"
 #include "jsarray.h"
 #include "jsatom.h"
 #include "jsbool.h"
 #include "jscntxt.h"
 #include "jsgc.h"
 #include "jsinterp.h"
@@ -37,16 +36,17 @@
 #include "jsobj.h"
 #include "jsopcode.h"
 #include "jsprobes.h"
 #include "jsscope.h"
 #include "jsstr.h"
 #include "jsversion.h"
 
 #include "builtin/RegExp.h"
+#include "js/HashTable.h"
 #include "vm/GlobalObject.h"
 #include "vm/NumericConversions.h"
 #include "vm/RegExpObject.h"
 #include "vm/StringBuffer.h"
 
 #include "jsinferinlines.h"
 #include "jsobjinlines.h"
 #include "jsstrinlines.h"
--- a/js/src/jstypedarray.cpp
+++ b/js/src/jstypedarray.cpp
@@ -4,17 +4,16 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include <string.h>
 
 #include "mozilla/FloatingPoint.h"
 #include "jstypes.h"
 #include "jsutil.h"
-#include "jshash.h"
 #include "jsprf.h"
 #include "jsapi.h"
 #include "jsarray.h"
 #include "jsatom.h"
 #include "jsbool.h"
 #include "jscntxt.h"
 #include "jscpucfg.h"
 #include "jsversion.h"
--- a/js/xpconnect/src/XPCMaps.cpp
+++ b/js/xpconnect/src/XPCMaps.cpp
@@ -3,28 +3,28 @@
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* Private maps (hashtables). */
 
 #include "xpcprivate.h"
 
-#include "jshash.h"
+#include "js/HashTable.h"
 
 /***************************************************************************/
 // static shared...
 
 // Note this is returning the bit pattern of the first part of the nsID, not
 // the pointer to the nsID.
 
 static JSDHashNumber
 HashIIDPtrKey(JSDHashTable *table, const void *key)
 {
-    return *((JSHashNumber*)key);
+    return *((js::HashNumber*)key);
 }
 
 static JSBool
 MatchIIDPtrKey(JSDHashTable *table,
                const JSDHashEntryHdr *entry,
                const void *key)
 {
     return ((const nsID*)key)->
@@ -51,31 +51,31 @@ HashNativeKey(JSDHashTable *table, const
         Addition = nullptr;
         Position = 0;
     }
 
     if (!Set) {
         NS_ASSERTION(Addition, "bad key");
         // This would be an XOR like below.
         // But "0 ^ x == x". So it does not matter.
-        h = (JSHashNumber) NS_PTR_TO_INT32(Addition) >> 2;
+        h = (js::HashNumber) NS_PTR_TO_INT32(Addition) >> 2;
     } else {
         XPCNativeInterface** Current = Set->GetInterfaceArray();
         PRUint16 count = Set->GetInterfaceCount();
         if (Addition) {
             count++;
             for (PRUint16 i = 0; i < count; i++) {
                 if (i == Position)
-                    h ^= (JSHashNumber) NS_PTR_TO_INT32(Addition) >> 2;
+                    h ^= (js::HashNumber) NS_PTR_TO_INT32(Addition) >> 2;
                 else
-                    h ^= (JSHashNumber) NS_PTR_TO_INT32(*(Current++)) >> 2;
+                    h ^= (js::HashNumber) NS_PTR_TO_INT32(*(Current++)) >> 2;
             }
         } else {
             for (PRUint16 i = 0; i < count; i++)
-                h ^= (JSHashNumber) NS_PTR_TO_INT32(*(Current++)) >> 2;
+                h ^= (js::HashNumber) NS_PTR_TO_INT32(*(Current++)) >> 2;
         }
     }
 
     return h;
 }
 
 /***************************************************************************/
 // implement JSObject2WrappedJSMap...
--- a/mfbt/HashFunctions.h
+++ b/mfbt/HashFunctions.h
@@ -174,16 +174,24 @@ AddToHash(uint32_t hash, A* a)
    */
 
   MOZ_STATIC_ASSERT(sizeof(a) == sizeof(uintptr_t),
                     "Strange pointer!");
 
   return detail::AddUintptrToHash<sizeof(uintptr_t)>(hash, uintptr_t(a));
 }
 
+template<>
+MOZ_WARN_UNUSED_RESULT
+inline uint32_t
+AddToHash(uint32_t hash, uintptr_t a)
+{
+  return detail::AddUintptrToHash<sizeof(uintptr_t)>(hash, a);
+}
+
 template<typename A, typename B>
 MOZ_WARN_UNUSED_RESULT
 uint32_t
 AddToHash(uint32_t hash, A a, B b)
 {
   return AddToHash(AddToHash(hash, a), b);
 }