Revision: 4872
Author: [email protected]
Date: Wed Jun 16 01:29:25 2010
Log: Change hash computation for transcendental cache to use arithmetic
shifts. Leads to fewer collisions.

Review URL: http://codereview.chromium.org/2809012
http://code.google.com/p/v8/source/detail?r=4872

Modified:
 /branches/bleeding_edge/src/arm/codegen-arm.cc
 /branches/bleeding_edge/src/heap.h
 /branches/bleeding_edge/src/ia32/codegen-ia32.cc
 /branches/bleeding_edge/src/x64/codegen-x64.cc

=======================================
--- /branches/bleeding_edge/src/arm/codegen-arm.cc      Mon Jun 14 04:37:05 2010
+++ /branches/bleeding_edge/src/arm/codegen-arm.cc      Wed Jun 16 01:29:25 2010
@@ -8304,11 +8304,11 @@
     __ bind(&loaded);
     // r2 = low 32 bits of double value
     // r3 = high 32 bits of double value
-    // Compute hash:
+    // Compute hash (the shifts are arithmetic):
// h = (low ^ high); h ^= h >> 16; h ^= h >> 8; h = h & (cacheSize - 1);
     __ eor(r1, r2, Operand(r3));
-    __ eor(r1, r1, Operand(r1, LSR, 16));
-    __ eor(r1, r1, Operand(r1, LSR, 8));
+    __ eor(r1, r1, Operand(r1, ASR, 16));
+    __ eor(r1, r1, Operand(r1, ASR, 8));
     ASSERT(IsPowerOf2(TranscendentalCache::kCacheSize));
     __ And(r1, r1, Operand(TranscendentalCache::kCacheSize - 1));

=======================================
--- /branches/bleeding_edge/src/heap.h  Tue Jun  8 02:35:47 2010
+++ /branches/bleeding_edge/src/heap.h  Wed Jun 16 01:29:25 2010
@@ -1882,8 +1882,8 @@
   };
   inline static int Hash(const Converter& c) {
     uint32_t hash = (c.integers[0] ^ c.integers[1]);
-    hash ^= hash >> 16;
-    hash ^= hash >> 8;
+    hash ^= static_cast<int32_t>(hash) >> 16;
+    hash ^= static_cast<int32_t>(hash) >> 8;
     return (hash & (kCacheSize - 1));
   }

=======================================
--- /branches/bleeding_edge/src/ia32/codegen-ia32.cc Mon Jun 14 05:08:39 2010 +++ /branches/bleeding_edge/src/ia32/codegen-ia32.cc Wed Jun 16 01:29:25 2010
@@ -10293,15 +10293,15 @@
   // ST[0] == double value
   // ebx = low 32 bits of double value
   // edx = high 32 bits of double value
-  // Compute hash:
+  // Compute hash (the shifts are arithmetic):
// h = (low ^ high); h ^= h >> 16; h ^= h >> 8; h = h & (cacheSize - 1);
   __ mov(ecx, ebx);
   __ xor_(ecx, Operand(edx));
   __ mov(eax, ecx);
-  __ shr(eax, 16);
+  __ sar(eax, 16);
   __ xor_(ecx, Operand(eax));
   __ mov(eax, ecx);
-  __ shr(eax, 8);
+  __ sar(eax, 8);
   __ xor_(ecx, Operand(eax));
   ASSERT(IsPowerOf2(TranscendentalCache::kCacheSize));
   __ and_(Operand(ecx), Immediate(TranscendentalCache::kCacheSize - 1));
=======================================
--- /branches/bleeding_edge/src/x64/codegen-x64.cc      Mon Jun 14 05:55:37 2010
+++ /branches/bleeding_edge/src/x64/codegen-x64.cc      Wed Jun 16 01:29:25 2010
@@ -8177,7 +8177,7 @@
   // ST[0] == double value
   // rbx = bits of double value.
   // rdx = also bits of double value.
-  // Compute hash (h is 32 bits, bits are 64):
+ // Compute hash (h is 32 bits, bits are 64 and the shifts are arithmetic):
   //   h = h0 = bits ^ (bits >> 32);
   //   h ^= h >> 16;
   //   h ^= h >> 8;
@@ -8188,9 +8188,9 @@
   __ movl(rcx, rdx);
   __ movl(rax, rdx);
   __ movl(rdi, rdx);
-  __ shrl(rdx, Immediate(8));
-  __ shrl(rcx, Immediate(16));
-  __ shrl(rax, Immediate(24));
+  __ sarl(rdx, Immediate(8));
+  __ sarl(rcx, Immediate(16));
+  __ sarl(rax, Immediate(24));
   __ xorl(rcx, rdx);
   __ xorl(rax, rdi);
   __ xorl(rcx, rax);

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to