]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Gradually move popular translations towards the start of the
authorJulian Seward <jseward@acm.org>
Mon, 28 Feb 2005 14:26:22 +0000 (14:26 +0000)
committerJulian Seward <jseward@acm.org>
Mon, 28 Feb 2005 14:26:22 +0000 (14:26 +0000)
table, so they can be found more quickly on subsequent lookups.

git-svn-id: svn://svn.valgrind.org/vex/trunk@986

VEX/switchback/switchback.c

index 3776301dfd59f9ffd4b562e4eb32a322f9e6b3bb..c149819997c5f31b15617add371701a7b1210025 100644 (file)
@@ -503,6 +503,19 @@ HWord find_translation ( Addr64 guest_addr )
       if (0) printf("none\n");
       return 0; /* not found */
    }
+
+   /* Move this translation one step towards the front, so finding it
+      next time round is just that little bit cheaper. */
+   if (i > 2) {
+      VexGuestExtents tmpE = trans_table[i-1];
+      ULong*          tmpP = trans_tableP[i-1];
+      trans_table[i-1]  = trans_table[i];
+      trans_tableP[i-1] = trans_tableP[i];
+      trans_table[i] = tmpE;
+      trans_tableP[i] = tmpP;
+      i--;
+   }
+
    res = (HWord)trans_tableP[i];
    if (0) printf("%p\n", (void*)res);
    return res;