Bug 937952 - Replace JS_ROTATE_LEFT32 with mozilla::RotateLeft; r=Waldo

This commit is contained in:
Ms2ger 2014-01-20 08:58:26 +01:00
Родитель 4f1e9b830b
Коммит 7b4adf5c0f
7 изменённых файлов: 31 добавлений и 42 удалений

Просмотреть файл

@ -22,6 +22,7 @@
using namespace js;
using mozilla::CeilingLog2Size;
using mozilla::RotateLeft;
/* Compute the number of buckets in ht */
#define NBUCKETS(ht) JS_BIT(JS_HASH_BITS - (ht)->shift)
@ -441,7 +442,7 @@ JS_HashString(const void *key)
h = 0;
for (s = (const unsigned char *)key; *s; s++)
h = JS_ROTATE_LEFT32(h, 4) ^ *s;
h = RotateLeft(h, 4) ^ *s;
return h;
}

Просмотреть файл

@ -168,26 +168,6 @@ static inline void js_free(void* p)
}
#endif/* JS_USE_CUSTOM_ALLOCATOR */
/*
* JS_ROTATE_LEFT32
*
* There is no rotate operation in the C Language so the construct (a << 4) |
* (a >> 28) is used instead. Most compilers convert this to a rotate
* instruction but some versions of MSVC don't without a little help. To get
* MSVC to generate a rotate instruction, we have to use the _rotl intrinsic
* and use a pragma to make _rotl inline.
*
* MSVC in VS2005 will do an inline rotate instruction on the above construct.
*/
#if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_AMD64) || \
defined(_M_X64))
#include <stdlib.h>
#pragma intrinsic(_rotl)
#define JS_ROTATE_LEFT32(a, bits) _rotl(a, bits)
#else
#define JS_ROTATE_LEFT32(a, bits) (((a) << (bits)) | ((a) >> (32 - (bits))))
#endif
#include <new>
/*

Просмотреть файл

@ -8,6 +8,7 @@
#define jit_RegisterAllocator_h
#include "mozilla/Attributes.h"
#include "mozilla/MathAlgorithms.h"
#include "jit/LIR.h"
#include "jit/MIRGenerator.h"
@ -97,8 +98,8 @@ struct AllocationIntegrityState
typedef IntegrityItem Lookup;
static HashNumber hash(const IntegrityItem &item) {
HashNumber hash = item.alloc.hash();
hash = JS_ROTATE_LEFT32(hash, 4) ^ item.vreg;
hash = JS_ROTATE_LEFT32(hash, 4) ^ HashNumber(item.block->mir()->id());
hash = mozilla::RotateLeft(hash, 4) ^ item.vreg;
hash = mozilla::RotateLeft(hash, 4) ^ HashNumber(item.block->mir()->id());
return hash;
}
static bool match(const IntegrityItem &one, const IntegrityItem &two) {

Просмотреть файл

@ -10,6 +10,7 @@
#include "jsscriptinlines.h"
#include "mozilla/MathAlgorithms.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/PodOperations.h"
@ -51,6 +52,7 @@ using namespace js::frontend;
using mozilla::PodCopy;
using mozilla::PodZero;
using mozilla::RotateLeft;
typedef Rooted<GlobalObject *> RootedGlobalObject;
@ -3226,13 +3228,13 @@ LazyScriptHash(uint32_t lineno, uint32_t column, uint32_t begin, uint32_t end,
HashNumber hashes[3])
{
HashNumber hash = lineno;
hash = JS_ROTATE_LEFT32(hash, 4) ^ column;
hash = JS_ROTATE_LEFT32(hash, 4) ^ begin;
hash = JS_ROTATE_LEFT32(hash, 4) ^ end;
hash = RotateLeft(hash, 4) ^ column;
hash = RotateLeft(hash, 4) ^ begin;
hash = RotateLeft(hash, 4) ^ end;
hashes[0] = hash;
hashes[1] = JS_ROTATE_LEFT32(hashes[0], 4) ^ begin;
hashes[2] = JS_ROTATE_LEFT32(hashes[1], 4) ^ end;
hashes[1] = RotateLeft(hashes[0], 4) ^ begin;
hashes[2] = RotateLeft(hashes[1], 4) ^ end;
}
void

Просмотреть файл

@ -28,9 +28,10 @@
using namespace js;
using namespace js::gc;
using mozilla::CeilingLog2Size;
using mozilla::DebugOnly;
using mozilla::PodZero;
using mozilla::CeilingLog2Size;
using mozilla::RotateLeft;
bool
ShapeTable::init(ThreadSafeContext *cx, Shape *lastProp)
@ -1432,11 +1433,11 @@ Shape::setObjectFlag(ExclusiveContext *cx, BaseShape::Flag flag, TaggedProto pro
StackBaseShape::hash(const StackBaseShape *base)
{
HashNumber hash = base->flags;
hash = JS_ROTATE_LEFT32(hash, 4) ^ (uintptr_t(base->clasp) >> 3);
hash = JS_ROTATE_LEFT32(hash, 4) ^ (uintptr_t(base->parent) >> 3);
hash = JS_ROTATE_LEFT32(hash, 4) ^ (uintptr_t(base->metadata) >> 3);
hash = JS_ROTATE_LEFT32(hash, 4) ^ uintptr_t(base->rawGetter);
hash = JS_ROTATE_LEFT32(hash, 4) ^ uintptr_t(base->rawSetter);
hash = RotateLeft(hash, 4) ^ (uintptr_t(base->clasp) >> 3);
hash = RotateLeft(hash, 4) ^ (uintptr_t(base->parent) >> 3);
hash = RotateLeft(hash, 4) ^ (uintptr_t(base->metadata) >> 3);
hash = RotateLeft(hash, 4) ^ uintptr_t(base->rawGetter);
hash = RotateLeft(hash, 4) ^ uintptr_t(base->rawSetter);
return hash;
}
@ -1575,9 +1576,9 @@ InitialShapeEntry::getLookup() const
InitialShapeEntry::hash(const Lookup &lookup)
{
HashNumber hash = uintptr_t(lookup.clasp) >> 3;
hash = JS_ROTATE_LEFT32(hash, 4) ^
hash = RotateLeft(hash, 4) ^
(uintptr_t(lookup.hashProto.toWord()) >> 3);
hash = JS_ROTATE_LEFT32(hash, 4) ^
hash = RotateLeft(hash, 4) ^
(uintptr_t(lookup.hashParent) >> 3) ^
(uintptr_t(lookup.hashMetadata) >> 3);
return hash + lookup.nfixed;

Просмотреть файл

@ -9,6 +9,7 @@
#include "mozilla/Attributes.h"
#include "mozilla/GuardObjects.h"
#include "mozilla/MathAlgorithms.h"
#include "mozilla/Maybe.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/TemplateLib.h"
@ -1549,11 +1550,11 @@ struct StackShape
HashNumber hash = uintptr_t(base);
/* Accumulate from least to most random so the low bits are most random. */
hash = JS_ROTATE_LEFT32(hash, 4) ^ (flags & Shape::PUBLIC_FLAGS);
hash = JS_ROTATE_LEFT32(hash, 4) ^ attrs;
hash = JS_ROTATE_LEFT32(hash, 4) ^ shortid;
hash = JS_ROTATE_LEFT32(hash, 4) ^ slot_;
hash = JS_ROTATE_LEFT32(hash, 4) ^ JSID_BITS(propid);
hash = mozilla::RotateLeft(hash, 4) ^ (flags & Shape::PUBLIC_FLAGS);
hash = mozilla::RotateLeft(hash, 4) ^ attrs;
hash = mozilla::RotateLeft(hash, 4) ^ shortid;
hash = mozilla::RotateLeft(hash, 4) ^ slot_;
hash = mozilla::RotateLeft(hash, 4) ^ JSID_BITS(propid);
return hash;
}

Просмотреть файл

@ -6,11 +6,14 @@
/* Private maps (hashtables). */
#include "mozilla/MathAlgorithms.h"
#include "mozilla/MemoryReporting.h"
#include "xpcprivate.h"
#include "js/HashTable.h"
using namespace mozilla;
/***************************************************************************/
// static shared...
@ -518,7 +521,7 @@ XPCNativeScriptableSharedMap::Entry::Hash(PLDHashTable *table, const void *key)
h = (PLDHashNumber) obj->GetFlags();
for (s = (const unsigned char*) obj->GetJSClass()->name; *s != '\0'; s++)
h = JS_ROTATE_LEFT32(h, 4) ^ *s;
h = RotateLeft(h, 4) ^ *s;
return h;
}