block_of_code: Always specify codeptr to run from

This commit is contained in:
MerryMage 2020-04-06 15:45:15 +01:00
parent b6536115ef
commit 7e0c415473
4 changed files with 15 additions and 31 deletions

View file

@ -70,7 +70,7 @@ struct Jit::Impl {
return GetCurrentBlock();
}();
block_of_code.RunCodeFrom(&jit_state, current_codeptr);
block_of_code.RunCode(&jit_state, current_codeptr);
}
void Step() {

View file

@ -64,7 +64,7 @@ public:
return GetCurrentBlock();
}();
block_of_code.RunCodeFrom(&jit_state, current_code_ptr);
block_of_code.RunCode(&jit_state, current_code_ptr);
PerformRequestedCacheInvalidation();
}

View file

@ -134,12 +134,8 @@ size_t BlockOfCode::SpaceRemaining() const {
return std::min(TOTAL_CODE_SIZE - far_code_offset, FAR_CODE_OFFSET - near_code_offset);
}
void BlockOfCode::RunCode(void* jit_state) const {
run_code(jit_state);
}
void BlockOfCode::RunCodeFrom(void* jit_state, CodePtr code_ptr) const {
run_code_from(jit_state, code_ptr);
void BlockOfCode::RunCode(void* jit_state, CodePtr code_ptr) const {
run_code(jit_state, code_ptr);
}
void BlockOfCode::StepCode(void* jit_state, CodePtr code_ptr) const {
@ -164,8 +160,12 @@ void BlockOfCode::GenRunCode() {
Xbyak::Label loop, enter_mxcsr_then_loop;
align();
run_code_from = getCurr<RunCodeFromFuncType>();
run_code = getCurr<RunCodeFuncType>();
// This serves two purposes:
// 1. It saves all the registers we as a callee need to save.
// 2. It aligns the stack so that the code the JIT emits can assume
// that the stack is appropriately aligned for CALLs.
ABI_PushCalleeSaveRegistersAndAdjustStack(*this);
mov(r15, ABI_PARAM1);
@ -179,7 +179,7 @@ void BlockOfCode::GenRunCode() {
jmp(r14);
align();
step_code = getCurr<RunCodeFromFuncType>();
step_code = getCurr<RunCodeFuncType>();
ABI_PushCalleeSaveRegistersAndAdjustStack(*this);
@ -192,25 +192,13 @@ void BlockOfCode::GenRunCode() {
jmp(ABI_PARAM2);
align();
run_code = getCurr<RunCodeFuncType>();
// This serves two purposes:
// 1. It saves all the registers we as a callee need to save.
// 2. It aligns the stack so that the code the JIT emits can assume
// that the stack is appropriately aligned for CALLs.
ABI_PushCalleeSaveRegistersAndAdjustStack(*this);
mov(r15, ABI_PARAM1);
cb.GetTicksRemaining->EmitCall(*this);
mov(qword[r15 + jsi.offsetof_cycles_to_run], ABI_RETURN);
mov(qword[r15 + jsi.offsetof_cycles_remaining], ABI_RETURN);
// Dispatcher loop
L(enter_mxcsr_then_loop);
SwitchMxcsrOnEntry();
L(loop);
cb.LookupBlock->EmitCall(*this);
jmp(ABI_RETURN);
// Return from run code variants
@ -249,7 +237,7 @@ void BlockOfCode::GenRunCode() {
return_from_run_code[MXCSR_ALREADY_EXITED | FORCE_RETURN] = getCurr<const void*>();
emit_return_from_run_code(true, true);
PerfMapRegister(run_code_from, getCurr(), "dynarmic_dispatcher");
PerfMapRegister(run_code, getCurr(), "dynarmic_dispatcher");
}
void BlockOfCode::SwitchMxcsrOnEntry() {

View file

@ -47,10 +47,8 @@ public:
/// Calculates how much space is remaining to use. This is the minimum of near code and far code.
size_t SpaceRemaining() const;
/// Runs emulated code.
void RunCode(void* jit_state) const;
/// Runs emulated code from code_ptr.
void RunCodeFrom(void* jit_state, CodePtr code_ptr) const;
void RunCode(void* jit_state, CodePtr code_ptr) const;
/// Runs emulated code from code_ptr for a single cycle.
void StepCode(void* jit_state, CodePtr code_ptr) const;
/// Code emitter: Returns to dispatcher
@ -157,11 +155,9 @@ private:
CodePtr near_code_ptr;
CodePtr far_code_ptr;
using RunCodeFuncType = void(*)(void*);
using RunCodeFromFuncType = void(*)(void*, CodePtr);
using RunCodeFuncType = void(*)(void*, CodePtr);
RunCodeFuncType run_code = nullptr;
RunCodeFromFuncType step_code = nullptr;
RunCodeFromFuncType run_code_from = nullptr;
RunCodeFuncType step_code = 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;