block_of_code: Always specify codeptr to run from
This commit is contained in:
parent
b6536115ef
commit
7e0c415473
4 changed files with 15 additions and 31 deletions
|
@ -70,7 +70,7 @@ struct Jit::Impl {
|
||||||
return GetCurrentBlock();
|
return GetCurrentBlock();
|
||||||
}();
|
}();
|
||||||
|
|
||||||
block_of_code.RunCodeFrom(&jit_state, current_codeptr);
|
block_of_code.RunCode(&jit_state, current_codeptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Step() {
|
void Step() {
|
||||||
|
|
|
@ -64,7 +64,7 @@ public:
|
||||||
|
|
||||||
return GetCurrentBlock();
|
return GetCurrentBlock();
|
||||||
}();
|
}();
|
||||||
block_of_code.RunCodeFrom(&jit_state, current_code_ptr);
|
block_of_code.RunCode(&jit_state, current_code_ptr);
|
||||||
|
|
||||||
PerformRequestedCacheInvalidation();
|
PerformRequestedCacheInvalidation();
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,12 +134,8 @@ size_t BlockOfCode::SpaceRemaining() const {
|
||||||
return std::min(TOTAL_CODE_SIZE - far_code_offset, FAR_CODE_OFFSET - near_code_offset);
|
return std::min(TOTAL_CODE_SIZE - far_code_offset, FAR_CODE_OFFSET - near_code_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlockOfCode::RunCode(void* jit_state) const {
|
void BlockOfCode::RunCode(void* jit_state, CodePtr code_ptr) const {
|
||||||
run_code(jit_state);
|
run_code(jit_state, code_ptr);
|
||||||
}
|
|
||||||
|
|
||||||
void BlockOfCode::RunCodeFrom(void* jit_state, CodePtr code_ptr) const {
|
|
||||||
run_code_from(jit_state, code_ptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlockOfCode::StepCode(void* jit_state, CodePtr code_ptr) const {
|
void BlockOfCode::StepCode(void* jit_state, CodePtr code_ptr) const {
|
||||||
|
@ -164,8 +160,12 @@ void BlockOfCode::GenRunCode() {
|
||||||
Xbyak::Label loop, enter_mxcsr_then_loop;
|
Xbyak::Label loop, enter_mxcsr_then_loop;
|
||||||
|
|
||||||
align();
|
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);
|
ABI_PushCalleeSaveRegistersAndAdjustStack(*this);
|
||||||
|
|
||||||
mov(r15, ABI_PARAM1);
|
mov(r15, ABI_PARAM1);
|
||||||
|
@ -179,7 +179,7 @@ void BlockOfCode::GenRunCode() {
|
||||||
jmp(r14);
|
jmp(r14);
|
||||||
|
|
||||||
align();
|
align();
|
||||||
step_code = getCurr<RunCodeFromFuncType>();
|
step_code = getCurr<RunCodeFuncType>();
|
||||||
|
|
||||||
ABI_PushCalleeSaveRegistersAndAdjustStack(*this);
|
ABI_PushCalleeSaveRegistersAndAdjustStack(*this);
|
||||||
|
|
||||||
|
@ -192,25 +192,13 @@ void BlockOfCode::GenRunCode() {
|
||||||
jmp(ABI_PARAM2);
|
jmp(ABI_PARAM2);
|
||||||
|
|
||||||
align();
|
align();
|
||||||
run_code = getCurr<RunCodeFuncType>();
|
|
||||||
|
|
||||||
// This serves two purposes:
|
// Dispatcher loop
|
||||||
// 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);
|
|
||||||
|
|
||||||
L(enter_mxcsr_then_loop);
|
L(enter_mxcsr_then_loop);
|
||||||
SwitchMxcsrOnEntry();
|
SwitchMxcsrOnEntry();
|
||||||
L(loop);
|
L(loop);
|
||||||
cb.LookupBlock->EmitCall(*this);
|
cb.LookupBlock->EmitCall(*this);
|
||||||
|
|
||||||
jmp(ABI_RETURN);
|
jmp(ABI_RETURN);
|
||||||
|
|
||||||
// Return from run code variants
|
// Return from run code variants
|
||||||
|
@ -249,7 +237,7 @@ void BlockOfCode::GenRunCode() {
|
||||||
return_from_run_code[MXCSR_ALREADY_EXITED | FORCE_RETURN] = getCurr<const void*>();
|
return_from_run_code[MXCSR_ALREADY_EXITED | FORCE_RETURN] = getCurr<const void*>();
|
||||||
emit_return_from_run_code(true, true);
|
emit_return_from_run_code(true, true);
|
||||||
|
|
||||||
PerfMapRegister(run_code_from, getCurr(), "dynarmic_dispatcher");
|
PerfMapRegister(run_code, getCurr(), "dynarmic_dispatcher");
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlockOfCode::SwitchMxcsrOnEntry() {
|
void BlockOfCode::SwitchMxcsrOnEntry() {
|
||||||
|
|
|
@ -47,10 +47,8 @@ public:
|
||||||
/// Calculates how much space is remaining to use. This is the minimum of near code and far code.
|
/// Calculates how much space is remaining to use. This is the minimum of near code and far code.
|
||||||
size_t SpaceRemaining() const;
|
size_t SpaceRemaining() const;
|
||||||
|
|
||||||
/// Runs emulated code.
|
|
||||||
void RunCode(void* jit_state) const;
|
|
||||||
/// Runs emulated code from code_ptr.
|
/// 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.
|
/// Runs emulated code from code_ptr for a single cycle.
|
||||||
void StepCode(void* jit_state, CodePtr code_ptr) const;
|
void StepCode(void* jit_state, CodePtr code_ptr) const;
|
||||||
/// Code emitter: Returns to dispatcher
|
/// Code emitter: Returns to dispatcher
|
||||||
|
@ -157,11 +155,9 @@ private:
|
||||||
CodePtr near_code_ptr;
|
CodePtr near_code_ptr;
|
||||||
CodePtr far_code_ptr;
|
CodePtr far_code_ptr;
|
||||||
|
|
||||||
using RunCodeFuncType = void(*)(void*);
|
using RunCodeFuncType = void(*)(void*, CodePtr);
|
||||||
using RunCodeFromFuncType = void(*)(void*, CodePtr);
|
|
||||||
RunCodeFuncType run_code = nullptr;
|
RunCodeFuncType run_code = nullptr;
|
||||||
RunCodeFromFuncType step_code = nullptr;
|
RunCodeFuncType step_code = nullptr;
|
||||||
RunCodeFromFuncType run_code_from = nullptr;
|
|
||||||
static constexpr size_t MXCSR_ALREADY_EXITED = 1 << 0;
|
static constexpr size_t MXCSR_ALREADY_EXITED = 1 << 0;
|
||||||
static constexpr size_t FORCE_RETURN = 1 << 1;
|
static constexpr size_t FORCE_RETURN = 1 << 1;
|
||||||
std::array<const void*, 4> return_from_run_code;
|
std::array<const void*, 4> return_from_run_code;
|
||||||
|
|
Loading…
Reference in a new issue