]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Change the TT_FAST hash function for from "insn_address >> 2" to
authorJulian Seward <jseward@acm.org>
Thu, 28 Apr 2011 14:58:15 +0000 (14:58 +0000)
committerJulian Seward <jseward@acm.org>
Thu, 28 Apr 2011 14:58:15 +0000 (14:58 +0000)
"insn_address >> 1".  The former is appropriate for ARM code, where
all insns are 4-sized and 4-aligned, but not for Thumb code, where the
minimum size and alignment is 2.  The old scheme happened to work for
Thumb (indeed, any hash function would), but caused huge amounts of
conflict misses in the fast cache for some programs.

The change has been observed to reduce conflict misses by up to 100
times, and in some cases, improves performance significantly for Thumb
code.  Performance of ARM code is unchanged or possibly a bit worse.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11716

coregrind/m_dispatch/dispatch-arm-linux.S
coregrind/pub_core_transtab_asm.h

index 8c9281415306db010c80675a2bf0fc94aa8cdc47..f67aeefa7d7647b293fd4502e8883fe9acf7e691 100644 (file)
@@ -99,7 +99,7 @@ VG_(run_innerloop__dispatch_unprofiled):
         /* try a fast lookup in the translation cache */
         // r0 = next guest, r1,r2,r3 scratch
        ldr  r1, =VG_TT_FAST_MASK       // r1 = VG_TT_FAST_MASK
-       and  r2, r1, r0, LSR #2         // r2 = entry #
+       and  r2, r1, r0, LSR #1         // r2 = entry #
        ldr  r1, =VG_(tt_fast)          // r1 = &tt_fast[0]
        add  r1, r1, r2, LSL #3         // r1 = &tt_fast[entry#]
        ldr  r3, [r1, #0]               /* .guest */
@@ -144,7 +144,7 @@ VG_(run_innerloop__dispatch_profiled):
         /* try a fast lookup in the translation cache */
         // r0 = next guest, r1,r2,r3 scratch
        ldr  r1, =VG_TT_FAST_MASK       // r1 = VG_TT_FAST_MASK
-       and  r2, r1, r0, LSR #2         // r2 = entry #
+       and  r2, r1, r0, LSR #1         // r2 = entry #
        ldr  r1, =VG_(tt_fast)          // r1 = &tt_fast[0]
        add  r1, r1, r2, LSL #3         // r1 = &tt_fast[entry#]
        ldr  r3, [r1, #0]               /* .guest */
index 76e48db1b572893283a9405ebc7d54d12b0209a8..f76924764a926058bf8b99c26473349a8743ea1d 100644 (file)
 
 /* This macro isn't usable in asm land; nevertheless this seems
    like a good place to put it. */
+
 #if defined(VGA_x86) || defined(VGA_amd64)
 #  define VG_TT_FAST_HASH(_addr)  ((((UWord)(_addr))     ) & VG_TT_FAST_MASK)
-#elif defined(VGA_ppc32) || defined(VGA_ppc64) || defined(VGA_arm)
-#  define VG_TT_FAST_HASH(_addr)  ((((UWord)(_addr)) >> 2) & VG_TT_FAST_MASK)
-#elif defined(VGA_s390x)
+
+#elif defined(VGA_s390x) || defined(VGA_arm)
 #  define VG_TT_FAST_HASH(_addr)  ((((UWord)(_addr)) >> 1) & VG_TT_FAST_MASK)
+
+#elif defined(VGA_ppc32) || defined(VGA_ppc64)
+#  define VG_TT_FAST_HASH(_addr)  ((((UWord)(_addr)) >> 2) & VG_TT_FAST_MASK)
+
 #else
 #  error "VG_TT_FAST_HASH: unknown platform"
 #endif