Index: src/mips/lithium-mips.cc |
diff --git a/src/mips/lithium-mips.cc b/src/mips/lithium-mips.cc |
index 5cfca0001004e7140e4fd47dbdd8fc7732053deb..a59286abc5f381f25d4ede6400ef8e44c0b16461 100644 |
--- a/src/mips/lithium-mips.cc |
+++ b/src/mips/lithium-mips.cc |
@@ -30,6 +30,7 @@ |
#include "lithium-allocator-inl.h" |
#include "mips/lithium-mips.h" |
#include "mips/lithium-codegen-mips.h" |
+#include "hydrogen-osr.h" |
namespace v8 { |
namespace internal { |
@@ -448,6 +449,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; |
@@ -2394,10 +2404,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("Too many spill slots needed for OSR"); |
- 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("Too many spill slots needed for OSR"); |
+ spill_index = 0; |
+ } |
} |
return DefineAsSpilled(new(zone()) LUnknownOSRValue, spill_index); |
} |