mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-13 05:25:46 -04:00
JitCodeBuffer: Expose FlushInstructionCache() to callers
This commit is contained in:
@ -7,16 +7,6 @@
|
|||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void DoCacheFlush(u8* address, u32 len)
|
|
||||||
{
|
|
||||||
#if defined(Y_PLATFORM_WINDOWS)
|
|
||||||
FlushInstructionCache(GetCurrentProcess(), address, len);
|
|
||||||
#elif defined(Y_COMPILER_GCC) || defined(Y_COMPILER_CLANG)
|
|
||||||
__builtin___clear_cache(reinterpret_cast<char*>(address), reinterpret_cast<char*>(address + len));
|
|
||||||
#else
|
|
||||||
#error Unknown platform.
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
JitCodeBuffer::JitCodeBuffer(u32 size /* = 64 * 1024 * 1024 */, u32 far_code_size /* = 0 */)
|
JitCodeBuffer::JitCodeBuffer(u32 size /* = 64 * 1024 * 1024 */, u32 far_code_size /* = 0 */)
|
||||||
{
|
{
|
||||||
@ -85,11 +75,11 @@ void JitCodeBuffer::CommitFarCode(u32 length)
|
|||||||
void JitCodeBuffer::Reset()
|
void JitCodeBuffer::Reset()
|
||||||
{
|
{
|
||||||
std::memset(m_code_ptr, 0, m_code_size);
|
std::memset(m_code_ptr, 0, m_code_size);
|
||||||
DoCacheFlush(m_code_ptr, m_code_size);
|
FlushInstructionCache(m_code_ptr, m_code_size);
|
||||||
if (m_far_code_size > 0)
|
if (m_far_code_size > 0)
|
||||||
{
|
{
|
||||||
std::memset(m_far_code_ptr, 0, m_far_code_size);
|
std::memset(m_far_code_ptr, 0, m_far_code_size);
|
||||||
DoCacheFlush(m_far_code_ptr, m_far_code_size);
|
FlushInstructionCache(m_far_code_ptr, m_far_code_size);
|
||||||
}
|
}
|
||||||
m_free_code_ptr = m_code_ptr;
|
m_free_code_ptr = m_code_ptr;
|
||||||
m_code_used = 0;
|
m_code_used = 0;
|
||||||
@ -109,3 +99,14 @@ void JitCodeBuffer::Align(u32 alignment, u8 padding_value)
|
|||||||
m_free_code_ptr += num_padding_bytes;
|
m_free_code_ptr += num_padding_bytes;
|
||||||
m_code_used += num_padding_bytes;
|
m_code_used += num_padding_bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void JitCodeBuffer::FlushInstructionCache(void* address, u32 size)
|
||||||
|
{
|
||||||
|
#if defined(Y_PLATFORM_WINDOWS)
|
||||||
|
::FlushInstructionCache(GetCurrentProcess(), address, size);
|
||||||
|
#elif defined(Y_COMPILER_GCC) || defined(Y_COMPILER_CLANG)
|
||||||
|
__builtin___clear_cache(reinterpret_cast<char*>(address), reinterpret_cast<char*>(address + size));
|
||||||
|
#else
|
||||||
|
#error Unknown platform.
|
||||||
|
#endif
|
||||||
|
}
|
@ -21,6 +21,9 @@ public:
|
|||||||
/// Assumes alignment is a power-of-two.
|
/// Assumes alignment is a power-of-two.
|
||||||
void Align(u32 alignment, u8 padding_value);
|
void Align(u32 alignment, u8 padding_value);
|
||||||
|
|
||||||
|
/// Flushes the instruction cache on the host for the specified range.
|
||||||
|
static void FlushInstructionCache(void* address, u32 size);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
u8* m_code_ptr;
|
u8* m_code_ptr;
|
||||||
u8* m_free_code_ptr;
|
u8* m_free_code_ptr;
|
||||||
|
Reference in New Issue
Block a user