Index: src/hydrogen-osr.cc |
diff --git a/src/hydrogen-osr.cc b/src/hydrogen-osr.cc |
index bf6233bb41d91cda9f3f8cf38629b3c78aa1c4a7..6b1df1e7a5b102106ab8f6a083503db1e28bcbc4 100644 |
--- a/src/hydrogen-osr.cc |
+++ b/src/hydrogen-osr.cc |
@@ -80,7 +80,8 @@ HBasicBlock* HOsrBuilder::BuildPossibleOsrLoopEntry( |
osr_values_ = new(zone) ZoneList<HUnknownOSRValue*>(length, zone); |
for (int i = 0; i < first_expression_index; ++i) { |
- HUnknownOSRValue* osr_value = builder_->Add<HUnknownOSRValue>(); |
+ HUnknownOSRValue* osr_value |
+ = builder_->Add<HUnknownOSRValue>(environment, i); |
environment->Bind(i, osr_value); |
osr_values_->Add(osr_value, zone); |
} |
@@ -88,12 +89,21 @@ HBasicBlock* HOsrBuilder::BuildPossibleOsrLoopEntry( |
if (first_expression_index != length) { |
environment->Drop(length - first_expression_index); |
for (int i = first_expression_index; i < length; ++i) { |
- HUnknownOSRValue* osr_value = builder_->Add<HUnknownOSRValue>(); |
+ HUnknownOSRValue* osr_value |
+ = builder_->Add<HUnknownOSRValue>(environment, i); |
environment->Push(osr_value); |
osr_values_->Add(osr_value, zone); |
} |
} |
+ unoptimized_frame_slots_ = |
+ environment->local_count() + environment->push_count(); |
+ |
+ // Keep a copy of the old environment, since the OSR values need it |
+ // to figure out where exactly they are located in the unoptimized frame. |
+ environment = environment->Copy(); |
+ builder_->current_block()->UpdateEnvironment(environment); |
+ |
builder_->Add<HSimulate>(osr_entry_id); |
builder_->Add<HOsrEntry>(osr_entry_id); |
HContext* context = builder_->Add<HContext>(); |