aboutsummaryrefslogtreecommitdiff
path: root/cpu-exec.c
diff options
context:
space:
mode:
authorKirill Batuzov <batuzovk@ispras.ru>2010-12-02 16:12:46 +0300
committerBlue Swirl <blauwirbel@gmail.com>2010-12-05 08:09:07 +0000
commit2c90fe2b71df2534884bce96d90cbfcc93aeedb8 (patch)
treeba23388055adb31979cc475db0c3b3a51c02e5c9 /cpu-exec.c
parent53016fa69c1fc7ed257272f36cb84b6623f73332 (diff)
Speedup 'tb_find_slow' by using the same heuristic as during memory page lookup
Move the last found TB to the head of the list so it will be found more quickly next time it will be looked for. Signed-off-by: Kirill Batuzov <batuzovk@ispras.ru> Signed-off-by: Pavel Yushchenko <pau@ispras.ru> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Diffstat (limited to 'cpu-exec.c')
-rw-r--r--cpu-exec.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/cpu-exec.c b/cpu-exec.c
index dbdfdccd8c..39e5eeaa8f 100644
--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -167,6 +167,12 @@ static TranslationBlock *tb_find_slow(target_ulong pc,
tb = tb_gen_code(env, pc, cs_base, flags, 0);
found:
+ /* Move the last found TB to the head of the list */
+ if (likely(*ptb1)) {
+ *ptb1 = tb->phys_hash_next;
+ tb->phys_hash_next = tb_phys_hash[h];
+ tb_phys_hash[h] = tb;
+ }
/* we add the TB in the virtual pc hash table */
env->tb_jmp_cache[tb_jmp_cache_hash_func(pc)] = tb;
return tb;