On Tue, 18 Aug 2026, Richard Henderson wrote:
On 8/18/26 10:42, Matt Turner wrote:
curr_cflags() is called once per TB dispatch, from helper_lookup_tb_ptr()
and from the cpu_exec() loop. It recomputes the same value every time:

     uint32_t cflags = cpu->tcg_cflags;
     if (unlikely(cpu_single_stepping(cpu))) { ... }
     else if (qatomic_read(&one_insn_per_tb)) { ... }
     else if (qemu_loglevel_mask(CPU_LOG_TB_NOCHAIN)) { ... }

That is three loads and three branches on the hottest path in the
interpreter, for state that changes only when gdb enables single-step,
when one-insn-per-tb is toggled, or when the log mask changes.

Compute the value once into CPUState::tcg_curr_cflags and recompute it
from the four places that can change an input: tcg_cflags_set(),
cpu_single_step(), tcg_set_one_insn_per_tb() and qemu_set_log_internal().
curr_cflags() becomes a single load.

Certainly one_insn_per_tb can only be set from the command-line, so that should never have been handled along this path.

QEMU 11.1.50 monitor - type 'help' for more information
(qemu) help one-insn-per-tb
one-insn-per-tb [on|off] -- run emulation with one guest instruction per translation block

Regards,
BALATON Zoltan

Reply via email to