Reviewers: Vyacheslav Egorov, Description: Fix zero hash handling on ARM. Some cleanup.
Please review this at http://codereview.chromium.org/9169010/ SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/ Affected files: M src/arm/code-stubs-arm.cc M src/ia32/code-stubs-ia32.cc M src/mips/code-stubs-mips.cc M src/objects.h M src/objects.cc M src/x64/code-stubs-x64.cc Index: src/arm/code-stubs-arm.cc =================================================================== --- src/arm/code-stubs-arm.cc (revision 10360) +++ src/arm/code-stubs-arm.cc (working copy) @@ -5759,13 +5759,12 @@ // 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); } Index: src/ia32/code-stubs-ia32.cc =================================================================== --- src/ia32/code-stubs-ia32.cc (revision 10360) +++ src/ia32/code-stubs-ia32.cc (working copy) @@ -6091,14 +6091,12 @@ __ 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); } Index: src/mips/code-stubs-mips.cc =================================================================== --- src/mips/code-stubs-mips.cc (revision 10360) +++ src/mips/code-stubs-mips.cc (working copy) @@ -5954,7 +5954,7 @@ void StringHelper::GenerateHashGetHash(MacroAssembler* masm, - Register hash) { + Register hash) { // hash += hash << 3; __ sll(at, hash, 3); __ addu(hash, hash, at); @@ -5965,12 +5965,11 @@ __ 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); } Index: src/objects.cc =================================================================== --- src/objects.cc (revision 10360) +++ src/objects.cc (working copy) @@ -11577,7 +11577,7 @@ 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); Index: src/objects.h =================================================================== --- src/objects.h (revision 10360) +++ src/objects.h (working copy) @@ -6210,6 +6210,11 @@ // 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()); Index: src/x64/code-stubs-x64.cc =================================================================== --- src/x64/code-stubs-x64.cc (revision 10360) +++ src/x64/code-stubs-x64.cc (working copy) @@ -5003,13 +5003,12 @@ __ 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); } -- v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev
