Index: src/hydrogen.cc |
diff --git a/src/hydrogen.cc b/src/hydrogen.cc |
index 519b4b84ba47b52bcc1a70257d1ed2ae140fddd4..0dca258239a0b6c8c22e00de8bada4675a3d9052 100644 |
--- a/src/hydrogen.cc |
+++ b/src/hydrogen.cc |
@@ -3288,9 +3288,6 @@ void HGraphBuilder::VisitVariableProxy(VariableProxy* expr) { |
if (variable->mode() == LET || variable->mode() == CONST_HARMONY) { |
return Bailout("reference to harmony declared context slot"); |
} |
- if (variable->mode() == CONST) { |
- return Bailout("reference to const context slot"); |
fschneider
2011/12/09 09:37:54
In order to get rid of this bailout we also additi
|
- } |
HValue* context = BuildContextChainWalk(variable); |
HLoadContextSlot* instr = |
new(zone()) HLoadContextSlot(context, variable->index()); |
@@ -3956,20 +3953,18 @@ void HGraphBuilder::VisitAssignment(Assignment* expr) { |
HandlePropertyAssignment(expr); |
} else if (proxy != NULL) { |
Variable* var = proxy->var(); |
+ |
if (var->mode() == CONST) { |
if (expr->op() != Token::INIT_CONST) { |
- return Bailout("non-initializer assignment to const"); |
- } |
- if (!var->IsStackAllocated()) { |
- return Bailout("assignment to const context slot"); |
+ CHECK_ALIVE(VisitForValue(expr->value())); |
+ return ast_context()->ReturnValue(Pop()); |
} |
- // We insert a use of the old value to detect unsupported uses of const |
- // variables (e.g. initialization inside a loop). |
- HValue* old_value = environment()->Lookup(var); |
- AddInstruction(new HUseConst(old_value)); |
- } else if (var->mode() == LET) { |
- if (!var->IsStackAllocated()) { |
- return Bailout("assignment to let context slot"); |
+ |
+ if (var->IsStackAllocated()) { |
+ // We insert a use of the old value to detect unsupported uses of const |
+ // variables (e.g. initialization inside a loop). |
+ HValue* old_value = environment()->Lookup(var); |
+ AddInstruction(new HUseConst(old_value)); |
} |
} else if (var->mode() == CONST_HARMONY) { |
if (expr->op() != Token::INIT_CONST_HARMONY) { |
@@ -3978,6 +3973,10 @@ void HGraphBuilder::VisitAssignment(Assignment* expr) { |
if (!var->IsStackAllocated()) { |
return Bailout("assignment to const context slot"); |
} |
+ } else if (var->mode() == LET) { |
+ if (!var->IsStackAllocated()) { |
+ return Bailout("assignment to let context slot"); |
+ } |
} |
if (proxy->IsArguments()) return Bailout("assignment to arguments"); |
@@ -4012,7 +4011,6 @@ void HGraphBuilder::VisitAssignment(Assignment* expr) { |
} |
case Variable::CONTEXT: { |
- ASSERT(var->mode() != CONST); |
// Bail out if we try to mutate a parameter value in a function using |
// the arguments object. We do not (yet) correctly handle the |
// arguments property of the function. |
@@ -4031,6 +4029,12 @@ void HGraphBuilder::VisitAssignment(Assignment* expr) { |
HValue* context = BuildContextChainWalk(var); |
HStoreContextSlot* instr = |
new(zone()) HStoreContextSlot(context, var->index(), Top()); |
+ |
+ // Ensure that const variable's value will be set only once |
+ if (var->is_const_mode()) { |
fschneider
2011/12/09 09:37:54
Here I would write
if (var->mode() == CONST)
to
|
+ instr->ForceIsHoleCheck(); |
+ } |
+ |
AddInstruction(instr); |
if (instr->HasObservableSideEffects()) { |
AddSimulate(expr->AssignmentId()); |