EmuCodeBlock: Use ConstantPool

This commit is contained in:
MerryMage 2017-03-19 12:37:25 +00:00
parent 9951961338
commit ff441efc26
3 changed files with 31 additions and 2 deletions

View File

@ -42,7 +42,7 @@ public:
}
// Call this before you generate any code.
void AllocCodeSpace(size_t size, bool need_low = true)
virtual void AllocCodeSpace(size_t size, bool need_low = true)
{
region_size = size;
region = static_cast<u8*>(Common::AllocateExecutableMemory(region_size, need_low));
@ -51,7 +51,7 @@ public:
// Always clear code space with breakpoints, so that if someone accidentally executes
// uninitialized, it just breaks into the debugger.
void ClearCodeSpace()
virtual void ClearCodeSpace()
{
PoisonMemory();
ResetCodePtr();

View File

@ -40,6 +40,18 @@ OpArg FixImmediate(int access_size, OpArg arg)
}
} // Anonymous namespace
void EmuCodeBlock::ClearCodeSpace()
{
X64CodeBlock::ClearCodeSpace();
m_const_pool.ClearCodeSpace();
}
void EmuCodeBlock::AllocCodeSpace(size_t size, bool need_low)
{
X64CodeBlock::AllocCodeSpace(size + ConstantPool::CONST_POOL_SIZE, need_low);
m_const_pool.AllocCodeSpace();
}
void EmuCodeBlock::MemoryExceptionCheck()
{
// TODO: We really should untangle the trampolines, exception handlers and

View File

@ -10,6 +10,7 @@
#include "Common/CommonTypes.h"
#include "Common/x64Emitter.h"
#include "Core/PowerPC/Jit64Common/ConstantPool.h"
#include "Core/PowerPC/Jit64Common/FarCodeCache.h"
#include "Core/PowerPC/Jit64Common/TrampolineInfo.h"
@ -22,12 +23,27 @@ class Mapping;
class EmuCodeBlock : public Gen::X64CodeBlock
{
public:
void ClearCodeSpace() override;
void AllocCodeSpace(size_t size, bool need_low = true) override;
void MemoryExceptionCheck();
// Simple functions to switch between near and far code emitting
void SwitchToFarCode();
void SwitchToNearCode();
template <typename T>
Gen::OpArg MConst(const T& value)
{
return m_const_pool.GetConstantOpArg(&value, sizeof(T), 1, 0);
}
template <typename T, size_t N>
Gen::OpArg MConst(const T (&value)[N], size_t index = 0)
{
return m_const_pool.GetConstantOpArg(&value, sizeof(T), N, index);
}
Gen::FixupBranch CheckIfSafeAddress(const Gen::OpArg& reg_value, Gen::X64Reg reg_addr,
BitSet32 registers_in_use);
void UnsafeLoadRegToReg(Gen::X64Reg reg_addr, Gen::X64Reg reg_value, int accessSize,
@ -105,6 +121,7 @@ public:
void Clear();
protected:
ConstantPool m_const_pool{this};
FarCodeCache m_far_code;
u8* m_near_code; // Backed up when we switch to far code.