Index: src/ia32/lithium-codegen-ia32.cc |
diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc |
index 75525ed5be95ee7723968a0084687de7c440c3c7..cce56ccc2619c81a20892542a6e740f4280512c3 100644 |
--- a/src/ia32/lithium-codegen-ia32.cc |
+++ b/src/ia32/lithium-codegen-ia32.cc |
@@ -35,6 +35,7 @@ |
#include "deoptimizer.h" |
#include "stub-cache.h" |
#include "codegen.h" |
+#include "hydrogen-osr.h" |
namespace v8 { |
namespace internal { |
@@ -332,6 +333,28 @@ bool LCodeGen::GeneratePrologue() { |
} |
+void LCodeGen::GenerateOsrPrologue() { |
+ // Generate the OSR entry prologue at the first unknown OSR value, or if there |
+ // are none, at the OSR entrypoint instruction. |
+ if (osr_pc_offset_ >= 0) return; |
+ |
+ osr_pc_offset_ = masm()->pc_offset(); |
+ |
+ // Save the first local, which is overwritten by the alignment state. |
+ Operand alignment_loc = MemOperand(ebp, -3 * kPointerSize); |
+ __ push(alignment_loc); |
+ |
+ // Set the dynamic frame alignment state to "not aligned". |
+ __ mov(alignment_loc, Immediate(kNoAlignmentPadding)); |
+ |
+ // Adjust the frame size, subsuming the unoptimized frame into the |
+ // optimized frame. |
+ int slots = GetStackSlotCount() - graph()->osr()->UnoptimizedFrameSlots(); |
+ ASSERT(slots >= 1); |
+ __ sub(esp, Immediate((slots - 1) * kPointerSize)); |
+} |
+ |
+ |
bool LCodeGen::GenerateBody() { |
ASSERT(is_generating()); |
bool emit_instructions = true; |
@@ -1317,8 +1340,7 @@ void LCodeGen::DoCallStub(LCallStub* instr) { |
void LCodeGen::DoUnknownOSRValue(LUnknownOSRValue* instr) { |
- // Record the address of the first unknown OSR value as the place to enter. |
- if (osr_pc_offset_ == -1) osr_pc_offset_ = masm()->pc_offset(); |
+ GenerateOsrPrologue(); |
} |
@@ -6214,9 +6236,7 @@ void LCodeGen::DoOsrEntry(LOsrEntry* instr) { |
ASSERT(!environment->HasBeenRegistered()); |
RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); |
- // Normally we record the first unknown OSR value as the entrypoint to the OSR |
- // code, but if there were none, record the entrypoint here. |
- if (osr_pc_offset_ == -1) osr_pc_offset_ = masm()->pc_offset(); |
+ GenerateOsrPrologue(); |
} |