Commit 0aff6c26 authored by erik.corry@gmail.com's avatar erik.corry@gmail.com

Fix zero hash handling on ARM.

Some cleanup.
Review URL: http://codereview.chromium.org/9169010

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10362 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent df8b359f
......@@ -5759,13 +5759,12 @@ void StringHelper::GenerateHashGetHash(MacroAssembler* masm,
// hash ^= hash >> 11;
__ eor(hash, hash, Operand(hash, LSR, 11));
// hash += hash << 15;
__ add(hash, hash, Operand(hash, LSL, 15), SetCC);
__ add(hash, hash, Operand(hash, LSL, 15));
uint32_t kHashShiftCutOffMask = (1 << (32 - String::kHashShift)) - 1;
__ and_(hash, hash, Operand(kHashShiftCutOffMask));
__ and_(hash, hash, Operand(String::kHashBitMask), SetCC);
// if (hash == 0) hash = 27;
__ mov(hash, Operand(27), LeaveCC, eq);
__ mov(hash, Operand(StringHasher::kZeroHash), LeaveCC, eq);
}
......
......@@ -6091,14 +6091,12 @@ void StringHelper::GenerateHashGetHash(MacroAssembler* masm,
__ shl(scratch, 15);
__ add(hash, scratch);
uint32_t kHashShiftCutOffMask = (1 << (32 - String::kHashShift)) - 1;
__ and_(hash, kHashShiftCutOffMask);
__ and_(hash, String::kHashBitMask);
// if (hash == 0) hash = 27;
Label hash_not_zero;
__ test(hash, hash);
__ j(not_zero, &hash_not_zero, Label::kNear);
__ mov(hash, Immediate(27));
__ mov(hash, Immediate(StringHasher::kZeroHash));
__ bind(&hash_not_zero);
}
......
......@@ -5954,7 +5954,7 @@ void StringHelper::GenerateHashAddCharacter(MacroAssembler* masm,
void StringHelper::GenerateHashGetHash(MacroAssembler* masm,
Register hash) {
Register hash) {
// hash += hash << 3;
__ sll(at, hash, 3);
__ addu(hash, hash, at);
......@@ -5965,12 +5965,11 @@ void StringHelper::GenerateHashGetHash(MacroAssembler* masm,
__ sll(at, hash, 15);
__ addu(hash, hash, at);
uint32_t kHashShiftCutOffMask = (1 << (32 - String::kHashShift)) - 1;
__ li(at, Operand(kHashShiftCutOffMask));
__ li(at, Operand(String::kHashBitMask));
__ and_(hash, hash, at);
// if (hash == 0) hash = 27;
__ ori(at, zero_reg, 27);
__ ori(at, zero_reg, StringHasher::kZeroHash);
__ movz(hash, at, hash);
}
......
......@@ -11577,7 +11577,7 @@ class TwoCharHashTableKey : public HashTableKey {
hash += hash << 3;
hash ^= hash >> 11;
hash += hash << 15;
if ((hash & String::kHashBitMask) == 0) hash = 27;
if ((hash & String::kHashBitMask) == 0) hash = String::kZeroHash;
#ifdef DEBUG
StringHasher hasher(2, seed);
hasher.AddCharacter(c1);
......
......@@ -6210,6 +6210,11 @@ class StringHasher {
// value is represented decimal value.
static uint32_t MakeArrayIndexHash(uint32_t value, int length);
// No string is allowed to have a hash of zero. That value is reserved
// for internal properties. If the hash calculation yields zero then we
// use 27 instead.
static const int kZeroHash = 27;
private:
uint32_t array_index() {
ASSERT(is_array_index());
......
......@@ -5003,13 +5003,12 @@ void StringHelper::GenerateHashGetHash(MacroAssembler* masm,
__ shll(scratch, Immediate(15));
__ addl(hash, scratch);
uint32_t kHashShiftCutOffMask = (1 << (32 - String::kHashShift)) - 1;
__ andl(hash, Immediate(kHashShiftCutOffMask));
__ andl(hash, Immediate(String::kHashBitMask));
// if (hash == 0) hash = 27;
Label hash_not_zero;
__ j(not_zero, &hash_not_zero);
__ Set(hash, 27);
__ Set(hash, StringHasher::kZeroHash);
__ bind(&hash_not_zero);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment