| Index: src/hydrogen.cc
|
| diff --git a/src/hydrogen.cc b/src/hydrogen.cc
|
| index 519b4b84ba47b52bcc1a70257d1ed2ae140fddd4..f0c16fe589baffc4202cce242d79e56869967073 100644
|
| --- a/src/hydrogen.cc
|
| +++ b/src/hydrogen.cc
|
| @@ -3288,12 +3288,12 @@ 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");
|
| - }
|
| HValue* context = BuildContextChainWalk(variable);
|
| HLoadContextSlot* instr =
|
| new(zone()) HLoadContextSlot(context, variable->index());
|
| + if (variable->mode() == CONST) {
|
| + instr->ForceIsHoleCheck();
|
| + }
|
| return ast_context()->ReturnInstruction(instr, expr->id());
|
| }
|
|
|
| @@ -3956,20 +3956,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 +3976,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 +4014,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 +4032,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->mode() == CONST) {
|
| + instr->ForceIsHoleCheck();
|
| + }
|
| +
|
| AddInstruction(instr);
|
| if (instr->HasObservableSideEffects()) {
|
| AddSimulate(expr->AssignmentId());
|
|
|