exec-all: bring tb->invalid into tb->cflags
[qemu/ar7.git] / include / exec / tb-lookup.h
blob436b6d5ecf4df8a0c7a690376ab5b83e8d7fd31f
1 /*
2 * Copyright (C) 2017, Emilio G. Cota <cota@braap.org>
4 * License: GNU GPL, version 2 or later.
5 * See the COPYING file in the top-level directory.
6 */
7 #ifndef EXEC_TB_LOOKUP_H
8 #define EXEC_TB_LOOKUP_H
10 #include "qemu/osdep.h"
12 #ifdef NEED_CPU_H
13 #include "cpu.h"
14 #else
15 #include "exec/poison.h"
16 #endif
18 #include "exec/exec-all.h"
19 #include "exec/tb-hash.h"
21 /* Might cause an exception, so have a longjmp destination ready */
22 static inline TranslationBlock *
23 tb_lookup__cpu_state(CPUState *cpu, target_ulong *pc, target_ulong *cs_base,
24 uint32_t *flags)
26 CPUArchState *env = (CPUArchState *)cpu->env_ptr;
27 TranslationBlock *tb;
28 uint32_t hash;
30 cpu_get_tb_cpu_state(env, pc, cs_base, flags);
31 hash = tb_jmp_cache_hash_func(*pc);
32 tb = atomic_rcu_read(&cpu->tb_jmp_cache[hash]);
33 if (likely(tb &&
34 tb->pc == *pc &&
35 tb->cs_base == *cs_base &&
36 tb->flags == *flags &&
37 tb->trace_vcpu_dstate == *cpu->trace_dstate &&
38 !(atomic_read(&tb->cflags) & CF_INVALID))) {
39 return tb;
41 tb = tb_htable_lookup(cpu, *pc, *cs_base, *flags);
42 if (tb == NULL) {
43 return NULL;
45 atomic_set(&cpu->tb_jmp_cache[hash], tb);
46 return tb;
49 #endif /* EXEC_TB_LOOKUP_H */