From a1950d1d2f2055f59fc63dd8c47fd933a7c6e81e Mon Sep 17 00:00:00 2001 From: MerryMage Date: Tue, 4 May 2021 14:19:05 +0100 Subject: [PATCH] backend/x64: Move save_host_MXCSR from JitState to stack --- src/backend/x64/a32_jitstate.h | 1 - src/backend/x64/a64_jitstate.h | 1 - src/backend/x64/block_of_code.cpp | 4 ++-- src/backend/x64/jitstate_info.h | 2 -- src/backend/x64/stack_layout.h | 2 ++ 5 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/backend/x64/a32_jitstate.h b/src/backend/x64/a32_jitstate.h index 92271c73..80f2b3ef 100644 --- a/src/backend/x64/a32_jitstate.h +++ b/src/backend/x64/a32_jitstate.h @@ -42,7 +42,6 @@ struct A32JitState { // For internal use (See: BlockOfCode::RunCode) u32 guest_MXCSR = 0x00001f80; u32 asimd_MXCSR = 0x00009fc0; - u32 save_host_MXCSR = 0; s64 cycles_to_run = 0; s64 cycles_remaining = 0; bool halt_requested = false; diff --git a/src/backend/x64/a64_jitstate.h b/src/backend/x64/a64_jitstate.h index e94a88c6..d98dd572 100644 --- a/src/backend/x64/a64_jitstate.h +++ b/src/backend/x64/a64_jitstate.h @@ -45,7 +45,6 @@ struct A64JitState { // For internal use (See: BlockOfCode::RunCode) u32 guest_MXCSR = 0x00001f80; u32 asimd_MXCSR = 0x00009fc0; - u32 save_host_MXCSR = 0; s64 cycles_to_run = 0; s64 cycles_remaining = 0; bool halt_requested = false; diff --git a/src/backend/x64/block_of_code.cpp b/src/backend/x64/block_of_code.cpp index 8a19a7fb..f54d9a3a 100644 --- a/src/backend/x64/block_of_code.cpp +++ b/src/backend/x64/block_of_code.cpp @@ -230,13 +230,13 @@ void BlockOfCode::GenRunCode(std::function rcp) { } 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]); } void BlockOfCode::SwitchMxcsrOnExit() { 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() { diff --git a/src/backend/x64/jitstate_info.h b/src/backend/x64/jitstate_info.h index e629a23c..711a218f 100644 --- a/src/backend/x64/jitstate_info.h +++ b/src/backend/x64/jitstate_info.h @@ -14,7 +14,6 @@ struct JitStateInfo { JitStateInfo(const JitStateType&) : offsetof_cycles_remaining(offsetof(JitStateType, cycles_remaining)) , 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_asimd_MXCSR(offsetof(JitStateType, asimd_MXCSR)) , offsetof_rsb_ptr(offsetof(JitStateType, rsb_ptr)) @@ -28,7 +27,6 @@ struct JitStateInfo { const size_t offsetof_cycles_remaining; const size_t offsetof_cycles_to_run; - const size_t offsetof_save_host_MXCSR; const size_t offsetof_guest_MXCSR; const size_t offsetof_asimd_MXCSR; const size_t offsetof_rsb_ptr; diff --git a/src/backend/x64/stack_layout.h b/src/backend/x64/stack_layout.h index 054fefab..e2a868c2 100644 --- a/src/backend/x64/stack_layout.h +++ b/src/backend/x64/stack_layout.h @@ -15,6 +15,8 @@ constexpr size_t SpillCount = 64; struct alignas(16) StackLayout { std::array, SpillCount> spill; + + u32 save_host_MXCSR; }; static_assert(sizeof(StackLayout) % 16 == 0);