From 2f81c20002b6712e905e66f00219dfce5e33df61 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 13 Jul 2020 20:41:48 +0200 Subject: [PATCH] UserspaceEmulator: Move the SoftCPU stream virtuals to the header They don't actually get inlined yet, but at least this devirtualizes them which is nice. --- DevTools/UserspaceEmulator/SoftCPU.cpp | 33 -------------------------- DevTools/UserspaceEmulator/SoftCPU.h | 33 ++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/DevTools/UserspaceEmulator/SoftCPU.cpp b/DevTools/UserspaceEmulator/SoftCPU.cpp index 1c6459f20b..facb9d6f4b 100644 --- a/DevTools/UserspaceEmulator/SoftCPU.cpp +++ b/DevTools/UserspaceEmulator/SoftCPU.cpp @@ -74,39 +74,6 @@ void SoftCPU::update_code_cache() m_cached_code_end = region->cacheable_ptr(region->size()); } -u8 SoftCPU::read8() -{ - if (!m_cached_code_ptr || m_cached_code_ptr >= m_cached_code_end) - update_code_cache(); - - u8 value = *m_cached_code_ptr; - m_cached_code_ptr += 1; - m_eip += 1; - return value; -} - -u16 SoftCPU::read16() -{ - if (!m_cached_code_ptr || (m_cached_code_ptr + 2) >= m_cached_code_end) - update_code_cache(); - - u16 value = *reinterpret_cast(m_cached_code_ptr); - m_cached_code_ptr += 2; - m_eip += 2; - return value; -} - -u32 SoftCPU::read32() -{ - if (!m_cached_code_ptr || (m_cached_code_ptr + 4) >= m_cached_code_end) - update_code_cache(); - - u32 value = *reinterpret_cast(m_cached_code_ptr); - m_cached_code_ptr += 4; - m_eip += 4; - return value; -} - u8 SoftCPU::read_memory8(X86::LogicalAddress address) { ASSERT(address.selector() == 0x18 || address.selector() == 0x20 || address.selector() == 0x28); diff --git a/DevTools/UserspaceEmulator/SoftCPU.h b/DevTools/UserspaceEmulator/SoftCPU.h index 137506daab..71ae4f3143 100644 --- a/DevTools/UserspaceEmulator/SoftCPU.h +++ b/DevTools/UserspaceEmulator/SoftCPU.h @@ -812,4 +812,37 @@ private: const u8* m_cached_code_end { nullptr }; }; +ALWAYS_INLINE u8 SoftCPU::read8() +{ + if (!m_cached_code_ptr || m_cached_code_ptr >= m_cached_code_end) + update_code_cache(); + + u8 value = *m_cached_code_ptr; + m_cached_code_ptr += 1; + m_eip += 1; + return value; +} + +ALWAYS_INLINE u16 SoftCPU::read16() +{ + if (!m_cached_code_ptr || (m_cached_code_ptr + 2) >= m_cached_code_end) + update_code_cache(); + + u16 value = *reinterpret_cast(m_cached_code_ptr); + m_cached_code_ptr += 2; + m_eip += 2; + return value; +} + +ALWAYS_INLINE u32 SoftCPU::read32() +{ + if (!m_cached_code_ptr || (m_cached_code_ptr + 4) >= m_cached_code_end) + update_code_cache(); + + u32 value = *reinterpret_cast(m_cached_code_ptr); + m_cached_code_ptr += 4; + m_eip += 4; + return value; +} + }