backend_x64: Inline Routines::GenReturnFromRunCode into emitted code
This commit is contained in:
parent
619b451902
commit
08e848044d
3 changed files with 8 additions and 18 deletions
|
@ -702,11 +702,11 @@ void EmitX64::EmitTerminalInterpret(IR::Term::Interpret terminal, Arm::LocationD
|
|||
code->MOV(32, MJitStateReg(Arm::Reg::PC), R(ABI_PARAM1));
|
||||
code->MOV(64, R(RSP), MDisp(R15, offsetof(JitState, save_host_RSP)));
|
||||
code->ABI_CallFunction(reinterpret_cast<void*>(cb.InterpreterFallback));
|
||||
code->JMP(routines->RunCodeReturnAddress(), true); // TODO: Check cycles
|
||||
routines->GenReturnFromRunCode(code); // TODO: Check cycles
|
||||
}
|
||||
|
||||
void EmitX64::EmitTerminalReturnToDispatch(IR::Term::ReturnToDispatch, Arm::LocationDescriptor initial_location) {
|
||||
code->JMP(routines->RunCodeReturnAddress(), true);
|
||||
routines->GenReturnFromRunCode(code);
|
||||
}
|
||||
|
||||
void EmitX64::EmitTerminalLinkBlock(IR::Term::LinkBlock terminal, Arm::LocationDescriptor initial_location) {
|
||||
|
@ -714,7 +714,7 @@ void EmitX64::EmitTerminalLinkBlock(IR::Term::LinkBlock terminal, Arm::LocationD
|
|||
ASSERT_MSG(terminal.next.EFlag == initial_location.EFlag, "Unimplemented");
|
||||
|
||||
code->MOV(32, MJitStateReg(Arm::Reg::PC), Imm32(terminal.next.arm_pc));
|
||||
code->JMP(routines->RunCodeReturnAddress(), true); // TODO: Check cycles, Properly do a link
|
||||
routines->GenReturnFromRunCode(code); // TODO: Check cycles, Properly do a link
|
||||
}
|
||||
|
||||
void EmitX64::EmitTerminalLinkBlockFast(IR::Term::LinkBlockFast terminal, Arm::LocationDescriptor initial_location) {
|
||||
|
|
|
@ -19,7 +19,6 @@ Routines::Routines() {
|
|||
AllocCodeSpace(1024);
|
||||
|
||||
GenRunCode();
|
||||
GenReturnFromRunCode();
|
||||
}
|
||||
|
||||
size_t Routines::RunCode(JitState* jit_state, CodePtr basic_block, size_t cycles_to_run) const {
|
||||
|
@ -30,10 +29,6 @@ size_t Routines::RunCode(JitState* jit_state, CodePtr basic_block, size_t cycles
|
|||
return cycles_to_run - jit_state->cycles_remaining; // Return number of cycles actually run.
|
||||
}
|
||||
|
||||
CodePtr Routines::RunCodeReturnAddress() const {
|
||||
return return_from_run_code;
|
||||
}
|
||||
|
||||
void Routines::GenRunCode() {
|
||||
run_code = reinterpret_cast<RunCodeFuncType>(const_cast<u8*>(this->GetCodePtr()));
|
||||
|
||||
|
@ -49,12 +44,10 @@ void Routines::GenRunCode() {
|
|||
JMPptr(R(ABI_PARAM2));
|
||||
}
|
||||
|
||||
void Routines::GenReturnFromRunCode() {
|
||||
return_from_run_code = this->GetCodePtr();
|
||||
|
||||
MOV(64, R(RSP), MDisp(R15, offsetof(JitState, save_host_RSP)));
|
||||
ABI_PopRegistersAndAdjustStack(ABI_ALL_CALLEE_SAVED, 8);
|
||||
RET();
|
||||
void Routines::GenReturnFromRunCode(XEmitter* code) const {
|
||||
code->MOV(64, R(RSP), MDisp(R15, offsetof(JitState, save_host_RSP)));
|
||||
code->ABI_PopRegistersAndAdjustStack(ABI_ALL_CALLEE_SAVED, 8);
|
||||
code->RET();
|
||||
}
|
||||
|
||||
} // namespace BackendX64
|
||||
|
|
|
@ -18,15 +18,12 @@ public:
|
|||
Routines();
|
||||
|
||||
size_t RunCode(JitState* jit_state, CodePtr basic_block, size_t cycles_to_run) const;
|
||||
CodePtr RunCodeReturnAddress() const;
|
||||
void GenReturnFromRunCode(Gen::XEmitter* code) const;
|
||||
|
||||
private:
|
||||
using RunCodeFuncType = void(*)(JitState*, CodePtr);
|
||||
RunCodeFuncType run_code;
|
||||
void GenRunCode();
|
||||
|
||||
CodePtr return_from_run_code;
|
||||
void GenReturnFromRunCode();
|
||||
};
|
||||
|
||||
} // namespace BackendX64
|
||||
|
|
Loading…
Reference in a new issue