Add re-entry prediction to avoid std::unordered_map lookups

This commit is contained in:
MerryMage 2017-12-12 14:18:21 +00:00
parent 5c6fcf378f
commit 6e834de072
4 changed files with 24 additions and 1 deletions

View file

@ -82,7 +82,14 @@ void BlockOfCode::RunCode(JitState* jit_state, size_t cycles_to_run) const {
jit_state->cycles_to_run = cycles_to_run;
jit_state->cycles_remaining = cycles_to_run;
run_code(jit_state);
u32 new_rsb_ptr = (jit_state->rsb_ptr - 1) & JitState::RSBPtrMask;
if (jit_state->GetUniqueHash() == jit_state->rsb_location_descriptors[new_rsb_ptr]) {
jit_state->rsb_ptr = new_rsb_ptr;
run_code_from(jit_state, jit_state->rsb_codeptrs[new_rsb_ptr]);
} else {
run_code(jit_state);
}
}
void BlockOfCode::ReturnFromRunCode(bool mxcsr_already_exited) {
@ -102,6 +109,14 @@ void BlockOfCode::ForceReturnFromRunCode(bool mxcsr_already_exited) {
void BlockOfCode::GenRunCode() {
Xbyak::Label loop, enter_mxcsr_then_loop;
align();
run_code_from = getCurr<RunCodeFromFuncType>();
ABI_PushCalleeSaveRegistersAndAdjustStack(this);
mov(r15, ABI_PARAM1);
SwitchMxcsrOnEntry();
jmp(ABI_PARAM2);
align();
run_code = getCurr<RunCodeFuncType>();

View file

@ -138,7 +138,9 @@ private:
CodePtr far_code_ptr;
using RunCodeFuncType = void(*)(JitState*);
using RunCodeFromFuncType = void(*)(JitState*, u64);
RunCodeFuncType run_code = nullptr;
RunCodeFromFuncType run_code_from = nullptr;
static constexpr size_t MXCSR_ALREADY_EXITED = 1 << 0;
static constexpr size_t FORCE_RETURN = 1 << 1;
std::array<const void*, 4> return_from_run_code;

View file

@ -199,5 +199,9 @@ void JitState::SetFpscr(u32 FPSCR) {
}
}
u64 JitState::GetUniqueHash() const {
return CPSR_et | FPSCR_mode | (static_cast<u64>(Reg[15]) << 32);
}
} // namespace BackendX64
} // namespace Dynarmic

View file

@ -67,6 +67,8 @@ struct JitState {
u32 old_FPSCR = 0;
u32 Fpscr() const;
void SetFpscr(u32 FPSCR);
u64 GetUniqueHash() const;
};
#ifdef _MSC_VER