Index: src/ia32/lithium-codegen-ia32.cc |
diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc |
index 46d80506edd887ce2f1b4915a3f6e04e0248fad0..092e5d01d644dcd31cb8d11db0115e02abff6cd7 100644 |
--- a/src/ia32/lithium-codegen-ia32.cc |
+++ b/src/ia32/lithium-codegen-ia32.cc |
@@ -78,6 +78,9 @@ bool LCodeGen::GenerateCode() { |
// the frame (that is done in GeneratePrologue). |
FrameScope frame_scope(masm_, StackFrame::MANUAL); |
+ set_dynamic_frame_alignment(chunk()->num_double_slots() > 2 || |
+ info()->osr_ast_id() != AstNode::kNoNumber); |
+ |
return GeneratePrologue() && |
GenerateBody() && |
GenerateDeferredCode() && |
@@ -152,6 +155,27 @@ bool LCodeGen::GeneratePrologue() { |
__ bind(&ok); |
} |
+ if (dynamic_frame_alignment()) { |
+ Label do_not_pad, align_loop; |
+ __ mov(ebx, esp); |
Kevin Millikin (Chromium)
2011/09/23 09:38:49
Can you test(esp, 4)?
William Hesse
2011/09/23 12:50:11
Done.
|
+ __ and_(ebx, Immediate(0x4)); |
Kevin Millikin (Chromium)
2011/09/23 09:38:49
Is this better (kDoubleSize - 1) or (kDoubleSize >
William Hesse
2011/09/23 12:50:11
Done.
|
+ __ j(zero, &do_not_pad, Label::kNear); |
+ __ mov(ebx, esp); |
Kevin Millikin (Chromium)
2011/09/23 09:38:49
The last move after the loop might be slightly mor
William Hesse
2011/09/23 12:50:11
Done.
|
+ __ push(Immediate(0)); |
+ __ mov(ecx, Immediate(scope()->num_parameters() + 2)); |
Kevin Millikin (Chromium)
2011/09/23 09:38:49
Comment should say 2 is receiver + return address.
William Hesse
2011/09/23 12:50:11
Done.
|
+ |
+ __ bind(&align_loop); |
+ __ mov(eax, Operand(ebx, 0)); |
+ __ mov(Operand(ebx, -1 * kPointerSize), eax); |
+ __ add(Operand(ebx), Immediate(kPointerSize)); |
+ __ dec(ecx); |
+ __ j(not_zero, &align_loop, Label::kNear); |
+ __ mov(Operand(ebx, -1 * kPointerSize), |
+ Immediate(isolate()->factory()->frame_alignment_marker())); |
+ |
+ __ bind(&do_not_pad); |
+ } |
+ |
__ push(ebp); // Caller's frame pointer. |
__ mov(ebp, esp); |
__ push(esi); // Callee's context. |
@@ -2016,6 +2040,16 @@ void LCodeGen::DoReturn(LReturn* instr) { |
__ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
__ CallRuntime(Runtime::kTraceExit, 1); |
} |
+ if (dynamic_frame_alignment()) { |
+ Label aligned; |
+ __ cmp(Operand(ebp, (GetParameterCount() + 3) * kPointerSize), |
Kevin Millikin (Chromium)
2011/09/23 09:38:49
3 ~ caller's fp, return address, receiver.
William Hesse
2011/09/23 12:50:11
Done.
|
+ Immediate(factory()->frame_alignment_marker())); |
+ __ j(not_equal, &aligned); |
+ __ mov(esp, ebp); |
+ __ pop(ebp); |
Kevin Millikin (Chromium)
2011/09/23 09:38:49
Slightly more compact is:
__ mov(esp, ebp);
__ po
William Hesse
2011/09/23 12:50:11
Done.
|
+ __ Ret((GetParameterCount() + 2) * kPointerSize, ecx); |
+ __ bind(&aligned); |
+ } |
__ mov(esp, ebp); |
__ pop(ebp); |
__ Ret((GetParameterCount() + 1) * kPointerSize, ecx); |