backend/x64: Move save_host_MXCSR from JitState to stack

This commit is contained in:
MerryMage 2021-05-04 14:19:05 +01:00
parent ddbc50cee0
commit a1950d1d2f
5 changed files with 4 additions and 6 deletions

View file

@ -42,7 +42,6 @@ struct A32JitState {
// For internal use (See: BlockOfCode::RunCode) // For internal use (See: BlockOfCode::RunCode)
u32 guest_MXCSR = 0x00001f80; u32 guest_MXCSR = 0x00001f80;
u32 asimd_MXCSR = 0x00009fc0; u32 asimd_MXCSR = 0x00009fc0;
u32 save_host_MXCSR = 0;
s64 cycles_to_run = 0; s64 cycles_to_run = 0;
s64 cycles_remaining = 0; s64 cycles_remaining = 0;
bool halt_requested = false; bool halt_requested = false;

View file

@ -45,7 +45,6 @@ struct A64JitState {
// For internal use (See: BlockOfCode::RunCode) // For internal use (See: BlockOfCode::RunCode)
u32 guest_MXCSR = 0x00001f80; u32 guest_MXCSR = 0x00001f80;
u32 asimd_MXCSR = 0x00009fc0; u32 asimd_MXCSR = 0x00009fc0;
u32 save_host_MXCSR = 0;
s64 cycles_to_run = 0; s64 cycles_to_run = 0;
s64 cycles_remaining = 0; s64 cycles_remaining = 0;
bool halt_requested = false; bool halt_requested = false;

View file

@ -230,13 +230,13 @@ void BlockOfCode::GenRunCode(std::function<void(BlockOfCode&)> rcp) {
} }
void BlockOfCode::SwitchMxcsrOnEntry() { void BlockOfCode::SwitchMxcsrOnEntry() {
stmxcsr(dword[r15 + jsi.offsetof_save_host_MXCSR]); stmxcsr(dword[rsp + ABI_SHADOW_SPACE + offsetof(StackLayout, save_host_MXCSR)]);
ldmxcsr(dword[r15 + jsi.offsetof_guest_MXCSR]); ldmxcsr(dword[r15 + jsi.offsetof_guest_MXCSR]);
} }
void BlockOfCode::SwitchMxcsrOnExit() { void BlockOfCode::SwitchMxcsrOnExit() {
stmxcsr(dword[r15 + jsi.offsetof_guest_MXCSR]); stmxcsr(dword[r15 + jsi.offsetof_guest_MXCSR]);
ldmxcsr(dword[r15 + jsi.offsetof_save_host_MXCSR]); ldmxcsr(dword[rsp + ABI_SHADOW_SPACE + offsetof(StackLayout, save_host_MXCSR)]);
} }
void BlockOfCode::EnterStandardASIMD() { void BlockOfCode::EnterStandardASIMD() {

View file

@ -14,7 +14,6 @@ struct JitStateInfo {
JitStateInfo(const JitStateType&) JitStateInfo(const JitStateType&)
: offsetof_cycles_remaining(offsetof(JitStateType, cycles_remaining)) : offsetof_cycles_remaining(offsetof(JitStateType, cycles_remaining))
, offsetof_cycles_to_run(offsetof(JitStateType, cycles_to_run)) , offsetof_cycles_to_run(offsetof(JitStateType, cycles_to_run))
, offsetof_save_host_MXCSR(offsetof(JitStateType, save_host_MXCSR))
, offsetof_guest_MXCSR(offsetof(JitStateType, guest_MXCSR)) , offsetof_guest_MXCSR(offsetof(JitStateType, guest_MXCSR))
, offsetof_asimd_MXCSR(offsetof(JitStateType, asimd_MXCSR)) , offsetof_asimd_MXCSR(offsetof(JitStateType, asimd_MXCSR))
, offsetof_rsb_ptr(offsetof(JitStateType, rsb_ptr)) , offsetof_rsb_ptr(offsetof(JitStateType, rsb_ptr))
@ -28,7 +27,6 @@ struct JitStateInfo {
const size_t offsetof_cycles_remaining; const size_t offsetof_cycles_remaining;
const size_t offsetof_cycles_to_run; const size_t offsetof_cycles_to_run;
const size_t offsetof_save_host_MXCSR;
const size_t offsetof_guest_MXCSR; const size_t offsetof_guest_MXCSR;
const size_t offsetof_asimd_MXCSR; const size_t offsetof_asimd_MXCSR;
const size_t offsetof_rsb_ptr; const size_t offsetof_rsb_ptr;

View file

@ -15,6 +15,8 @@ constexpr size_t SpillCount = 64;
struct alignas(16) StackLayout { struct alignas(16) StackLayout {
std::array<std::array<u64, 2>, SpillCount> spill; std::array<std::array<u64, 2>, SpillCount> spill;
u32 save_host_MXCSR;
}; };
static_assert(sizeof(StackLayout) % 16 == 0); static_assert(sizeof(StackLayout) % 16 == 0);