From a27473cbc2462f5acbc2268bd5287b4a121fe69e Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 13 Jul 2020 20:23:00 +0200 Subject: [PATCH] UserspaceEmulator+LibX86: Turn on -O3 optimization for emulation code Since this code is performance-sensitive, let's have the compiler do whatever it can to help us with the most important files. This yields a ~8% speedup. --- DevTools/UserspaceEmulator/Emulator.cpp | 7 ++++++- DevTools/UserspaceEmulator/SoftCPU.cpp | 4 ++++ Libraries/LibX86/Instruction.cpp | 4 ++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/DevTools/UserspaceEmulator/Emulator.cpp b/DevTools/UserspaceEmulator/Emulator.cpp index 961d08533f..a0ad483b50 100644 --- a/DevTools/UserspaceEmulator/Emulator.cpp +++ b/DevTools/UserspaceEmulator/Emulator.cpp @@ -38,6 +38,10 @@ #include #include +#if defined(__GNUC__) && !defined(__clang__) +# pragma GCC optimize("O3") +#endif + //#define DEBUG_SPAM namespace UserspaceEmulator { @@ -171,7 +175,8 @@ void Emulator::dump_backtrace() if (!ret_ptr) return; symbol = m_elf->symbolicate(ret_ptr, &offset); - printf("> %#08x %s +%#x\n", ret_ptr, symbol.characters(), offset); + if (!symbol.is_null()) + printf("> %#08x %s +%#x\n", ret_ptr, symbol.characters(), offset); frame_ptr = m_mmu.read32({ 0x20, frame_ptr }); } diff --git a/DevTools/UserspaceEmulator/SoftCPU.cpp b/DevTools/UserspaceEmulator/SoftCPU.cpp index 980ce3bb83..1c6459f20b 100644 --- a/DevTools/UserspaceEmulator/SoftCPU.cpp +++ b/DevTools/UserspaceEmulator/SoftCPU.cpp @@ -30,6 +30,10 @@ #include #include +#if defined(__GNUC__) && !defined(__clang__) +# pragma GCC optimize("O3") +#endif + //#define MEMORY_DEBUG namespace UserspaceEmulator { diff --git a/Libraries/LibX86/Instruction.cpp b/Libraries/LibX86/Instruction.cpp index 6d59beccec..54f878b3e3 100644 --- a/Libraries/LibX86/Instruction.cpp +++ b/Libraries/LibX86/Instruction.cpp @@ -29,6 +29,10 @@ #include #include +#if defined(__GNUC__) && !defined(__clang__) +# pragma GCC optimize("O3") +#endif + namespace X86 { enum IsLockPrefixAllowed {