UserspaceEmulator+LibX86: Sprinkle some [[unlikely]] and ALWAYS_INLINE

This commit is contained in:
Andreas Kling 2021-03-09 15:10:08 +01:00
parent c192b6c61d
commit 656cd477c2
3 changed files with 12 additions and 9 deletions

View file

@ -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())

View file

@ -66,17 +66,17 @@ static inline Dest bit_cast(Source source)
}
template<typename T>
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();
}

View file

@ -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());