Index: src/hydrogen.cc |
diff --git a/src/hydrogen.cc b/src/hydrogen.cc |
index 5c6b5cd9b8c47acb482ca28b38869109b9d03433..14046b410d476ecf2173e928a960a51068901317 100644 |
--- a/src/hydrogen.cc |
+++ b/src/hydrogen.cc |
@@ -5327,7 +5327,7 @@ void HOptimizedGraphBuilder::VisitVariableProxy(VariableProxy* expr) { |
Handle<Context> script_context = ScriptContextTable::GetContext( |
script_contexts, lookup.context_index); |
Handle<Object> current_value = |
- FixedArray::get(script_context, lookup.context_index); |
+ FixedArray::get(script_context, lookup.slot_index); |
// If the values is not the hole, it will stay initialized, |
// so no need to generate a check. |
@@ -6488,6 +6488,16 @@ void HOptimizedGraphBuilder::HandleGlobalVariableAssignment( |
} |
Handle<Context> script_context = |
ScriptContextTable::GetContext(script_contexts, lookup.context_index); |
+ |
+ Handle<Object> current_value = |
+ FixedArray::get(script_context, lookup.slot_index); |
+ |
+ // If the values is not the hole, it will stay initialized, |
+ // so no need to generate a check. |
+ if (*current_value == *isolate()->factory()->the_hole_value()) { |
+ return Bailout(kReferenceToUninitializedVariable); |
+ } |
+ |
HStoreNamedField* instr = Add<HStoreNamedField>( |
Add<HConstant>(script_context), |
HObjectAccess::ForContextSlot(lookup.slot_index), value); |