diff --git a/src/backend/x64/a32_emit_x64.cpp b/src/backend/x64/a32_emit_x64.cpp index ae5ce68b..1b8759c3 100644 --- a/src/backend/x64/a32_emit_x64.cpp +++ b/src/backend/x64/a32_emit_x64.cpp @@ -22,6 +22,7 @@ #include "backend/x64/emit_x64.h" #include "backend/x64/nzcv_util.h" #include "backend/x64/perf_map.h" +#include "backend/x64/stack_layout.h" #include "common/assert.h" #include "common/bit_util.h" #include "common/common_types.h" @@ -324,7 +325,7 @@ void A32EmitX64::GenTerminalHandlers() { void A32EmitX64::EmitA32SetCheckBit(A32EmitContext& ctx, IR::Inst* inst) { auto args = ctx.reg_alloc.GetArgumentInfo(inst); const Xbyak::Reg8 to_store = ctx.reg_alloc.UseGpr(args[0]).cvt8(); - code.mov(code.byte[r15 + offsetof(A32JitState, check_bit)], to_store); + code.mov(code.byte[rsp + ABI_SHADOW_SPACE + offsetof(StackLayout, check_bit)], to_store); } void A32EmitX64::EmitA32GetRegister(A32EmitContext& ctx, IR::Inst* inst) { @@ -1601,7 +1602,7 @@ void A32EmitX64::EmitTerminalImpl(IR::Term::If terminal, IR::LocationDescriptor void A32EmitX64::EmitTerminalImpl(IR::Term::CheckBit terminal, IR::LocationDescriptor initial_location, bool is_single_step) { Xbyak::Label fail; - code.cmp(code.byte[r15 + offsetof(A32JitState, check_bit)], u8(0)); + code.cmp(code.byte[rsp + ABI_SHADOW_SPACE + offsetof(StackLayout, check_bit)], u8(0)); code.jz(fail); EmitTerminal(terminal.then_, initial_location, is_single_step); code.L(fail); diff --git a/src/backend/x64/a32_jitstate.h b/src/backend/x64/a32_jitstate.h index 80f2b3ef..c83b14bb 100644 --- a/src/backend/x64/a32_jitstate.h +++ b/src/backend/x64/a32_jitstate.h @@ -45,7 +45,6 @@ struct A32JitState { s64 cycles_to_run = 0; s64 cycles_remaining = 0; bool halt_requested = false; - bool check_bit = false; // Exclusive state u32 exclusive_state = 0; diff --git a/src/backend/x64/a64_emit_x64.cpp b/src/backend/x64/a64_emit_x64.cpp index ad5ad03f..9c4eea3c 100644 --- a/src/backend/x64/a64_emit_x64.cpp +++ b/src/backend/x64/a64_emit_x64.cpp @@ -19,6 +19,7 @@ #include "backend/x64/emit_x64.h" #include "backend/x64/nzcv_util.h" #include "backend/x64/perf_map.h" +#include "backend/x64/stack_layout.h" #include "common/assert.h" #include "common/bit_util.h" #include "common/common_types.h" @@ -376,7 +377,7 @@ void A64EmitX64::EmitPushRSB(EmitContext& ctx, IR::Inst* inst) { void A64EmitX64::EmitA64SetCheckBit(A64EmitContext& ctx, IR::Inst* inst) { auto args = ctx.reg_alloc.GetArgumentInfo(inst); const Xbyak::Reg8 to_store = ctx.reg_alloc.UseGpr(args[0]).cvt8(); - code.mov(code.byte[r15 + offsetof(A64JitState, check_bit)], to_store); + code.mov(code.byte[rsp + ABI_SHADOW_SPACE + offsetof(StackLayout, check_bit)], to_store); } void A64EmitX64::EmitA64GetCFlag(A64EmitContext& ctx, IR::Inst* inst) { @@ -1299,7 +1300,7 @@ void A64EmitX64::EmitTerminalImpl(IR::Term::If terminal, IR::LocationDescriptor void A64EmitX64::EmitTerminalImpl(IR::Term::CheckBit terminal, IR::LocationDescriptor initial_location, bool is_single_step) { Xbyak::Label fail; - code.cmp(code.byte[r15 + offsetof(A64JitState, check_bit)], u8(0)); + code.cmp(code.byte[rsp + ABI_SHADOW_SPACE + offsetof(StackLayout, check_bit)], u8(0)); code.jz(fail); EmitTerminal(terminal.then_, initial_location, is_single_step); code.L(fail); diff --git a/src/backend/x64/a64_jitstate.h b/src/backend/x64/a64_jitstate.h index d98dd572..8bc9b64e 100644 --- a/src/backend/x64/a64_jitstate.h +++ b/src/backend/x64/a64_jitstate.h @@ -48,7 +48,6 @@ struct A64JitState { s64 cycles_to_run = 0; s64 cycles_remaining = 0; bool halt_requested = false; - bool check_bit = false; // Exclusive state static constexpr u64 RESERVATION_GRANULE_MASK = 0xFFFF'FFFF'FFFF'FFF0ull; diff --git a/src/backend/x64/stack_layout.h b/src/backend/x64/stack_layout.h index e2a868c2..f7d00401 100644 --- a/src/backend/x64/stack_layout.h +++ b/src/backend/x64/stack_layout.h @@ -17,6 +17,8 @@ struct alignas(16) StackLayout { std::array, SpillCount> spill; u32 save_host_MXCSR; + + bool check_bit; }; static_assert(sizeof(StackLayout) % 16 == 0);