mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-17 21:32:48 +00:00
UserspaceEmulator+LibX86: Sprinkle some [[unlikely]] and ALWAYS_INLINE
This commit is contained in:
parent
c192b6c61d
commit
656cd477c2
|
@ -248,24 +248,27 @@ 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())
|
||||
tracer->dump_leak_report();
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
|
|
Loading…
Reference in a new issue