Index: src/ia32/macro-assembler-ia32.cc |
=================================================================== |
--- src/ia32/macro-assembler-ia32.cc (revision 4427) |
+++ src/ia32/macro-assembler-ia32.cc (working copy) |
@@ -1535,6 +1535,21 @@ |
} |
+void MacroAssembler::CheckStackAlignment() { |
+ int frame_alignment = OS::ActivationFrameAlignment(); |
+ int frame_alignment_mask = frame_alignment - 1; |
+ if (frame_alignment > kPointerSize) { |
+ ASSERT(IsPowerOf2(frame_alignment)); |
+ Label alignment_as_expected; |
+ test(esp, Immediate(frame_alignment_mask)); |
+ j(zero, &alignment_as_expected); |
+ // Abort if stack is not aligned. |
+ int3(); |
+ bind(&alignment_as_expected); |
+ } |
+} |
+ |
+ |
void MacroAssembler::Abort(const char* msg) { |
// We want to pass the msg string like a smi to avoid GC |
// problems, however msg is not guaranteed to be aligned |
@@ -1634,6 +1649,11 @@ |
void MacroAssembler::CallCFunction(Register function, |
int num_arguments) { |
+ // Check stack alignment. |
+ if (FLAG_debug_code) { |
+ CheckStackAlignment(); |
+ } |
+ |
call(Operand(function)); |
if (OS::ActivationFrameAlignment() != 0) { |
mov(esp, Operand(esp, num_arguments * kPointerSize)); |