☠☠ backed out by 675d4af07c28 ☠ ☠ | |
author | Nicholas Nethercote <nnethercote@mozilla.com> |
Wed, 18 Jul 2012 17:38:10 -0700 | |
changeset 105208 | 61d052e202c8ca786b42f7f9116c2619d5a45fe6 |
parent 105207 | 205aaea8796db13d1ed1e1b0e84d740768ac6a0e |
child 105209 | 675d4af07c28c76b45df169ebf9f1acc61ad7f85 |
push id | 1490 |
push user | akeybl@mozilla.com |
push date | Mon, 08 Oct 2012 18:29:50 +0000 |
treeherder | mozilla-beta@f335e7dacdc1 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | luke |
bugs | 647367 |
milestone | 17.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
|
--- a/js/jsd/Makefile.in +++ b/js/jsd/Makefile.in @@ -12,17 +12,19 @@ VPATH = @srcdir@ srcdir = @srcdir@ relativesrcdir = js/jsd 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
--- 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 \ @@ -156,17 +155,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 @@ -950,17 +950,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 = nsnull; 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); }