diff --git a/src/xenia/cpu/x64/x64_emitter.cc b/src/xenia/cpu/x64/x64_emitter.cc index ef3e27e3c..b9c6846b5 100644 --- a/src/xenia/cpu/x64/x64_emitter.cc +++ b/src/xenia/cpu/x64/x64_emitter.cc @@ -109,10 +109,16 @@ void X64Emitter::Unlock() { xe_mutex_unlock(lock_); } +#define STACK_ALIGNMENT_CHECK 0 + int X64Emitter::PrepareFunction(FunctionSymbol* symbol) { int result_code = 1; Lock(); +#if STACK_ALIGNMENT_CHECK + Label l(assembler_.newLabel()); +#endif // STACK_ALIGNMENT_CHECK + if (symbol->impl_value) { result_code = 0; XESUCCEED(); @@ -137,6 +143,15 @@ int X64Emitter::PrepareFunction(FunctionSymbol* symbol) { // call [OnDemandCompileTrampoline] // jmp [rax] +#if STACK_ALIGNMENT_CHECK + assembler_.mov(rax, rsp); + assembler_.and_(rax, imm(0xF)); + assembler_.test(rax, rax); + assembler_.jz(l); + assembler_.int3(); + assembler_.bind(l); +#endif // STACK_ALIGNMENT_CHECK + #if defined(ASMJIT_WINDOWS) // Calling convetion: kX86FuncConvX64W // Arguments passed as RCX, RDX, R8, R9