Index: src/x64/lithium-x64.cc |
diff --git a/src/x64/lithium-x64.cc b/src/x64/lithium-x64.cc |
index 1b4332af87acaffd2f9d54b5cc6ec80abf031d88..ac48b09af9c23219295064906f76b785f0bcf113 100644 |
--- a/src/x64/lithium-x64.cc |
+++ b/src/x64/lithium-x64.cc |
@@ -32,6 +32,7 @@ |
#include "lithium-allocator-inl.h" |
#include "x64/lithium-x64.h" |
#include "x64/lithium-codegen-x64.h" |
+#include "hydrogen-osr.h" |
namespace v8 { |
namespace internal { |
@@ -439,6 +440,15 @@ LPlatformChunk* LChunkBuilder::Build() { |
chunk_ = new(zone()) LPlatformChunk(info(), graph()); |
LPhase phase("L_Building chunk", chunk_); |
status_ = BUILDING; |
+ |
+ // If compiling for OSR, reserve space for the unoptimized frame, |
+ // which will be subsumed into this frame. |
+ if (graph()->has_osr()) { |
+ for (int i = graph()->osr()->UnoptimizedFrameSlots(); i > 0; i--) { |
+ chunk_->GetNextSpillIndex(false); |
+ } |
+ } |
+ |
const ZoneList<HBasicBlock*>* blocks = graph()->blocks(); |
for (int i = 0; i < blocks->length(); i++) { |
HBasicBlock* next = NULL; |
@@ -2359,10 +2369,18 @@ LInstruction* LChunkBuilder::DoParameter(HParameter* instr) { |
LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) { |
- int spill_index = chunk()->GetNextSpillIndex(false); // Not double-width. |
- if (spill_index > LUnallocated::kMaxFixedSlotIndex) { |
- Abort(kTooManySpillSlotsNeededForOSR); |
- spill_index = 0; |
+ // Use an index that corresponds to the location in the unoptimized frame, |
+ // which the optimized frame will subsume. |
+ int env_index = instr->index(); |
+ int spill_index = 0; |
+ if (instr->environment()->is_parameter_index(env_index)) { |
+ spill_index = chunk()->GetParameterStackSlot(env_index); |
+ } else { |
+ spill_index = env_index - instr->environment()->first_local_index(); |
+ if (spill_index > LUnallocated::kMaxFixedSlotIndex) { |
+ Abort(kTooManySpillSlotsNeededForOSR); |
+ spill_index = 0; |
+ } |
} |
return DefineAsSpilled(new(zone()) LUnknownOSRValue, spill_index); |
} |