Index: src/ia32/lithium-codegen-ia32.cc |
diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc |
index 2d469da6ed55867d5a32e0cdd6c22253888fc1da..03f98814e0c96887b458892ddfdcc422229df0da 100644 |
--- a/src/ia32/lithium-codegen-ia32.cc |
+++ b/src/ia32/lithium-codegen-ia32.cc |
@@ -79,6 +79,9 @@ bool LCodeGen::GenerateCode() { |
// the frame (that is done in GeneratePrologue). |
FrameScope frame_scope(masm_, StackFrame::MANUAL); |
+ dynamic_frame_alignment_ = chunk()->num_double_slots() > 2 || |
+ info()->osr_ast_id() != AstNode::kNoNumber; |
+ |
return GeneratePrologue() && |
GenerateBody() && |
GenerateDeferredCode() && |
@@ -153,6 +156,31 @@ bool LCodeGen::GeneratePrologue() { |
__ bind(&ok); |
} |
+ __ mov(edx, Immediate(0)); |
+ |
+ if (dynamic_frame_alignment_) { |
+ Label do_not_pad, align_loop; |
+ STATIC_ASSERT(kDoubleSize == 2 * kPointerSize); |
+ // Align esp to a multiple of 2 * kPointerSize. |
+ __ test(esp, Immediate(kPointerSize)); |
+ __ j(zero, &do_not_pad, Label::kNear); |
+ __ push(Immediate(0)); |
+ __ mov(ebx, esp); |
+ __ mov(edx, Immediate(2)); |
+ // Copy arguments, receiver, and return address. |
+ __ mov(ecx, Immediate(scope()->num_parameters() + 2)); |
+ |
+ __ bind(&align_loop); |
+ __ mov(eax, Operand(ebx, 1 * kPointerSize)); |
+ __ mov(Operand(ebx, 0), eax); |
+ __ add(Operand(ebx), Immediate(kPointerSize)); |
+ __ dec(ecx); |
+ __ j(not_zero, &align_loop, Label::kNear); |
+ __ mov(Operand(ebx, 0), |
+ Immediate(Smi::FromInt(0x12345))); |
+ __ bind(&do_not_pad); |
+ } |
+ |
__ push(ebp); // Caller's frame pointer. |
__ mov(ebp, esp); |
__ push(esi); // Callee's context. |
@@ -160,6 +188,7 @@ bool LCodeGen::GeneratePrologue() { |
// Reserve space for the stack slots needed by the code. |
int slots = GetStackSlotCount(); |
+ CHECK(slots >= 1); |
if (slots > 0) { |
if (FLAG_debug_code) { |
__ mov(Operand(eax), Immediate(slots)); |
@@ -183,6 +212,7 @@ bool LCodeGen::GeneratePrologue() { |
#endif |
} |
} |
+ __ mov(Operand(ebp, JavaScriptFrameConstants::kLocal0Offset), edx); |
// Possibly allocate a local context. |
int heap_slots = scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; |
@@ -2098,8 +2128,21 @@ void LCodeGen::DoReturn(LReturn* instr) { |
__ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
__ CallRuntime(Runtime::kTraceExit, 1); |
} |
+ if (dynamic_frame_alignment_) { |
+ __ mov(edx, Operand(ebp, JavaScriptFrameConstants::kLocal0Offset)); |
+ } |
__ mov(esp, ebp); |
__ pop(ebp); |
+ if (dynamic_frame_alignment_) { |
+ Label aligned; |
+ __ cmp(edx, Immediate(0)); |
+ __ j(equal, &aligned); |
+ __ cmp(Operand(esp, (GetParameterCount() + 2) * kPointerSize), |
+ Immediate(Smi::FromInt(0x12345))); |
+ __ Assert(equal, "expected alignment marker"); |
+ __ Ret((GetParameterCount() + 2) * kPointerSize, ecx); |
+ __ bind(&aligned); |
+ } |
__ Ret((GetParameterCount() + 1) * kPointerSize, ecx); |
} |