Index: src/mips/macro-assembler-mips.cc |
=================================================================== |
--- src/mips/macro-assembler-mips.cc (revision 10379) |
+++ src/mips/macro-assembler-mips.cc (working copy) |
@@ -343,6 +343,44 @@ |
} |
+void MacroAssembler::GetNumberHash(Register reg0, Register scratch) { |
+ // First of all we assign the hash seed to scratch. |
+ LoadRoot(scratch, Heap::kHashSeedRootIndex); |
+ SmiUntag(scratch); |
+ |
+ // Xor original key with a seed. |
+ xor_(reg0, reg0, scratch); |
+ |
+ // Compute the hash code from the untagged key. This must be kept in sync |
+ // with ComputeIntegerHash in utils.h. |
+ // |
+ // hash = ~hash + (hash << 15); |
+ nor(scratch, reg0, zero_reg); |
+ sll(at, reg0, 15); |
+ addu(reg0, scratch, at); |
+ |
+ // hash = hash ^ (hash >> 12); |
+ srl(at, reg0, 12); |
+ xor_(reg0, reg0, at); |
+ |
+ // hash = hash + (hash << 2); |
+ sll(at, reg0, 2); |
+ addu(reg0, reg0, at); |
+ |
+ // hash = hash ^ (hash >> 4); |
+ srl(at, reg0, 4); |
+ xor_(reg0, reg0, at); |
+ |
+ // hash = hash * 2057; |
+ li(scratch, Operand(2057)); |
+ mul(reg0, reg0, scratch); |
+ |
+ // hash = hash ^ (hash >> 16); |
+ srl(at, reg0, 16); |
+ xor_(reg0, reg0, at); |
+} |
+ |
+ |
void MacroAssembler::LoadFromNumberDictionary(Label* miss, |
Register elements, |
Register key, |
@@ -374,34 +412,8 @@ |
// at - Temporary (avoid MacroAssembler instructions also using 'at'). |
Label done; |
- // Compute the hash code from the untagged key. This must be kept in sync |
- // with ComputeIntegerHash in utils.h. |
- // |
- // hash = ~hash + (hash << 15); |
- nor(reg1, reg0, zero_reg); |
- sll(at, reg0, 15); |
- addu(reg0, reg1, at); |
+ GetNumberHash(reg0, reg1); |
- // hash = hash ^ (hash >> 12); |
- srl(at, reg0, 12); |
- xor_(reg0, reg0, at); |
- |
- // hash = hash + (hash << 2); |
- sll(at, reg0, 2); |
- addu(reg0, reg0, at); |
- |
- // hash = hash ^ (hash >> 4); |
- srl(at, reg0, 4); |
- xor_(reg0, reg0, at); |
- |
- // hash = hash * 2057; |
- li(reg1, Operand(2057)); |
- mul(reg0, reg0, reg1); |
- |
- // hash = hash ^ (hash >> 16); |
- srl(at, reg0, 16); |
- xor_(reg0, reg0, at); |
- |
// Compute the capacity mask. |
lw(reg1, FieldMemOperand(elements, NumberDictionary::kCapacityOffset)); |
sra(reg1, reg1, kSmiTagSize); |