Adding stack alignment check. We aren't 16b aligned right now. Fuck.

This commit is contained in:
Ben Vanik 2013-10-19 14:16:34 -07:00
parent 007f7e371d
commit 5df538cd44
1 changed files with 15 additions and 0 deletions

View File

@ -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