1
2
3
4
5
6
7#ifndef EXEC_TB_LOOKUP_H
8#define EXEC_TB_LOOKUP_H
9
10#ifdef NEED_CPU_H
11#include "cpu.h"
12#else
13#include "exec/poison.h"
14#endif
15
16#include "exec/exec-all.h"
17#include "exec/tb-hash.h"
18
19
20static inline TranslationBlock *
21tb_lookup__cpu_state(CPUState *cpu, target_ulong *pc, target_ulong *cs_base,
22 uint32_t *flags, uint32_t cf_mask)
23{
24 CPUArchState *env = (CPUArchState *)cpu->env_ptr;
25 TranslationBlock *tb;
26 uint32_t hash;
27
28 cpu_get_tb_cpu_state(env, pc, cs_base, flags);
29 hash = tb_jmp_cache_hash_func(*pc);
30 tb = atomic_rcu_read(&cpu->tb_jmp_cache[hash]);
31 if (likely(tb &&
32 tb->pc == *pc &&
33 tb->cs_base == *cs_base &&
34 tb->flags == *flags &&
35 tb->trace_vcpu_dstate == *cpu->trace_dstate &&
36 (tb_cflags(tb) & (CF_HASH_MASK | CF_INVALID)) == cf_mask)) {
37 return tb;
38 }
39 tb = tb_htable_lookup(cpu, *pc, *cs_base, *flags, cf_mask);
40 if (tb == NULL) {
41 return NULL;
42 }
43 atomic_set(&cpu->tb_jmp_cache[hash], tb);
44 return tb;
45}
46
47#endif
48