JitCommon/JitCache: Make JitBlock's checkedEntry and normalEntry members non-const pointers

In both cases of the x64 and AArch64 JITs, these would have const casted
away from them, followed by them being placed within an emitter and
having breakpoint instructions written in them.

In this case, we shouldn't be using const period if we're writing to the
emitted data.
This commit is contained in:
Lioncash 2018-08-27 09:58:32 -04:00
parent 25898cfa55
commit e81408588f
8 changed files with 17 additions and 17 deletions

View File

@ -71,9 +71,9 @@ void CachedInterpreter::Shutdown()
m_block_cache.Shutdown(); m_block_cache.Shutdown();
} }
const u8* CachedInterpreter::GetCodePtr() const u8* CachedInterpreter::GetCodePtr()
{ {
return reinterpret_cast<const u8*>(m_code.data() + m_code.size()); return reinterpret_cast<u8*>(m_code.data() + m_code.size());
} }
void CachedInterpreter::ExecuteOneBlock() void CachedInterpreter::ExecuteOneBlock()

View File

@ -35,7 +35,7 @@ public:
private: private:
struct Instruction; struct Instruction;
const u8* GetCodePtr() const; u8* GetCodePtr();
void ExecuteOneBlock(); void ExecuteOneBlock();
bool HandleFunctionHooking(u32 address); bool HandleFunctionHooking(u32 address);

View File

@ -646,7 +646,7 @@ void Jit64::Jit(u32 em_address)
blocks.FinalizeBlock(*b, jo.enableBlocklink, code_block.m_physical_addresses); blocks.FinalizeBlock(*b, jo.enableBlocklink, code_block.m_physical_addresses);
} }
const u8* Jit64::DoJit(u32 em_address, JitBlock* b, u32 nextPC) u8* Jit64::DoJit(u32 em_address, JitBlock* b, u32 nextPC)
{ {
js.firstFPInstructionFound = false; js.firstFPInstructionFound = false;
js.isLastInstruction = false; js.isLastInstruction = false;
@ -657,8 +657,8 @@ const u8* Jit64::DoJit(u32 em_address, JitBlock* b, u32 nextPC)
js.numLoadStoreInst = 0; js.numLoadStoreInst = 0;
js.numFloatingPointInst = 0; js.numFloatingPointInst = 0;
const u8* start = // TODO: Test if this or AlignCode16 make a difference from GetCodePtr
AlignCode4(); // TODO: Test if this or AlignCode16 make a difference from GetCodePtr u8* const start = AlignCode4();
b->checkedEntry = start; b->checkedEntry = start;
// Downcount flag check. The last block decremented downcounter, and the flag should still be // Downcount flag check. The last block decremented downcounter, and the flag should still be
@ -668,8 +668,8 @@ const u8* Jit64::DoJit(u32 em_address, JitBlock* b, u32 nextPC)
JMP(asm_routines.do_timing, true); // downcount hit zero - go do_timing. JMP(asm_routines.do_timing, true); // downcount hit zero - go do_timing.
SetJumpTarget(skip); SetJumpTarget(skip);
const u8* normalEntry = GetCodePtr(); u8* const normal_entry = GetWritableCodePtr();
b->normalEntry = normalEntry; b->normalEntry = normal_entry;
// Used to get a trace of the last few blocks before a crash, sometimes VERY useful // Used to get a trace of the last few blocks before a crash, sometimes VERY useful
if (ImHereDebug) if (ImHereDebug)
@ -959,7 +959,7 @@ const u8* Jit64::DoJit(u32 em_address, JitBlock* b, u32 nextPC)
LogGeneratedX86(code_block.m_num_instructions, m_code_buffer, start, b); LogGeneratedX86(code_block.m_num_instructions, m_code_buffer, start, b);
#endif #endif
return normalEntry; return normal_entry;
} }
BitSet8 Jit64::ComputeStaticGQRs(const PPCAnalyst::CodeBlock& cb) const BitSet8 Jit64::ComputeStaticGQRs(const PPCAnalyst::CodeBlock& cb) const

View File

@ -52,7 +52,7 @@ public:
// Jit! // Jit!
void Jit(u32 em_address) override; void Jit(u32 em_address) override;
const u8* DoJit(u32 em_address, JitBlock* b, u32 nextPC); u8* DoJit(u32 em_address, JitBlock* b, u32 nextPC);
BitSet32 CallerSavedRegistersInUse() const; BitSet32 CallerSavedRegistersInUse() const;
BitSet8 ComputeStaticGQRs(const PPCAnalyst::CodeBlock&) const; BitSet8 ComputeStaticGQRs(const PPCAnalyst::CodeBlock&) const;

View File

@ -37,8 +37,8 @@ void JitBlockCache::WriteLinkBlock(const JitBlock::LinkData& source, const JitBl
void JitBlockCache::WriteDestroyBlock(const JitBlock& block) void JitBlockCache::WriteDestroyBlock(const JitBlock& block)
{ {
// Only clear the entry points as we might still be within this block. // Only clear the entry points as we might still be within this block.
Gen::XEmitter emit(const_cast<u8*>(block.checkedEntry)); Gen::XEmitter emit(block.checkedEntry);
emit.INT3(); emit.INT3();
Gen::XEmitter emit2(const_cast<u8*>(block.normalEntry)); Gen::XEmitter emit2(block.normalEntry);
emit2.INT3(); emit2.INT3();
} }

View File

@ -607,7 +607,7 @@ void JitArm64::DoJit(u32 em_address, JitBlock* b, u32 nextPC)
js.curBlock = b; js.curBlock = b;
js.carryFlagSet = false; js.carryFlagSet = false;
const u8* start = GetCodePtr(); u8* const start = GetWritableCodePtr();
b->checkedEntry = start; b->checkedEntry = start;
// Downcount flag check, Only valid for linked blocks // Downcount flag check, Only valid for linked blocks
@ -619,7 +619,7 @@ void JitArm64::DoJit(u32 em_address, JitBlock* b, u32 nextPC)
} }
// Normal entry doesn't need to check for downcount. // Normal entry doesn't need to check for downcount.
b->normalEntry = GetCodePtr(); b->normalEntry = GetWritableCodePtr();
// Conditionally add profiling code. // Conditionally add profiling code.
if (Profiler::g_ProfileBlocks) if (Profiler::g_ProfileBlocks)

View File

@ -70,7 +70,7 @@ void JitArm64BlockCache::WriteLinkBlock(const JitBlock::LinkData& source, const
void JitArm64BlockCache::WriteDestroyBlock(const JitBlock& block) void JitArm64BlockCache::WriteDestroyBlock(const JitBlock& block)
{ {
// Only clear the entry points as we might still be within this block. // Only clear the entry points as we might still be within this block.
ARM64XEmitter emit((u8*)block.checkedEntry); ARM64XEmitter emit(block.checkedEntry);
while (emit.GetWritableCodePtr() <= block.normalEntry) while (emit.GetWritableCodePtr() <= block.normalEntry)
emit.BRK(0x123); emit.BRK(0x123);

View File

@ -30,9 +30,9 @@ struct JitBlock
// A special entry point for block linking; usually used to check the // A special entry point for block linking; usually used to check the
// downcount. // downcount.
const u8* checkedEntry; u8* checkedEntry;
// The normal entry point for the block, returned by Dispatch(). // The normal entry point for the block, returned by Dispatch().
const u8* normalEntry; u8* normalEntry;
// The effective address (PC) for the beginning of the block. // The effective address (PC) for the beginning of the block.
u32 effectiveAddress; u32 effectiveAddress;