diff --git a/Userland/DevTools/UserspaceEmulator/Emulator.cpp b/Userland/DevTools/UserspaceEmulator/Emulator.cpp index 0c9ea2c73a..307ed2b1d0 100644 --- a/Userland/DevTools/UserspaceEmulator/Emulator.cpp +++ b/Userland/DevTools/UserspaceEmulator/Emulator.cpp @@ -248,23 +248,26 @@ int Emulator::exec() // X86::ELFSymbolProvider symbol_provider(*m_elf); X86::ELFSymbolProvider* symbol_provider = nullptr; - bool trace = false; + constexpr bool trace = false; while (!m_shutdown) { m_cpu.save_base_eip(); auto insn = X86::Instruction::from_stream(m_cpu, true, true); - if (trace) + if constexpr (trace) { outln("{:p} \033[33;1m{}\033[0m", m_cpu.base_eip(), insn.to_string(m_cpu.base_eip(), symbol_provider)); + } (m_cpu.*insn.handler())(insn); - if (trace) + if constexpr (trace) { m_cpu.dump(); + } - if (m_pending_signals) + if (m_pending_signals) [[unlikely]] { dispatch_one_pending_signal(); + } } if (auto* tracer = malloc_tracer()) diff --git a/Userland/DevTools/UserspaceEmulator/SoftCPU.cpp b/Userland/DevTools/UserspaceEmulator/SoftCPU.cpp index 5f7e2892ff..98383a2991 100644 --- a/Userland/DevTools/UserspaceEmulator/SoftCPU.cpp +++ b/Userland/DevTools/UserspaceEmulator/SoftCPU.cpp @@ -66,17 +66,17 @@ static inline Dest bit_cast(Source source) } template -void warn_if_uninitialized(T value_with_shadow, const char* message) +ALWAYS_INLINE void warn_if_uninitialized(T value_with_shadow, const char* message) { - if (value_with_shadow.is_uninitialized()) { + if (value_with_shadow.is_uninitialized()) [[unlikely]] { reportln("\033[31;1mWarning! Use of uninitialized value: {}\033[0m\n", message); Emulator::the().dump_backtrace(); } } -void SoftCPU::warn_if_flags_tainted(const char* message) const +ALWAYS_INLINE void SoftCPU::warn_if_flags_tainted(const char* message) const { - if (m_flags_tainted) { + if (m_flags_tainted) [[unlikely]] { reportln("\n=={}== \033[31;1mConditional depends on uninitialized data\033[0m ({})\n", getpid(), message); Emulator::the().dump_backtrace(); } diff --git a/Userland/Libraries/LibX86/Instruction.h b/Userland/Libraries/LibX86/Instruction.h index 0473841724..62debebd9c 100644 --- a/Userland/Libraries/LibX86/Instruction.h +++ b/Userland/Libraries/LibX86/Instruction.h @@ -833,7 +833,7 @@ ALWAYS_INLINE Instruction::Instruction(InstructionStreamType& stream, bool o32, m_descriptor = &m_descriptor->slashes[rm() & 7]; } - if (!m_descriptor->mnemonic) { + if (!m_descriptor->mnemonic) [[unlikely]] { if (has_sub_op()) { if (has_slash) fprintf(stderr, "Instruction %02X %02X /%u not understood\n", m_op, m_sub_op, slash());