| Index: src/hydrogen.cc
 | 
| diff --git a/src/hydrogen.cc b/src/hydrogen.cc
 | 
| index 03bd971a825ce7ceee500e4122265eb8fa70ed5b..39b2114c61de3487faad623813a3da063cea52b2 100644
 | 
| --- a/src/hydrogen.cc
 | 
| +++ b/src/hydrogen.cc
 | 
| @@ -4496,26 +4496,29 @@ void HOptimizedGraphBuilder::VisitBlock(Block* stmt) {
 | 
|  
 | 
|    { BreakAndContinueScope push(&break_info, this);
 | 
|      if (scope != NULL) {
 | 
| -      // Load the function object.
 | 
| -      Scope* declaration_scope = scope->DeclarationScope();
 | 
| -      HInstruction* function;
 | 
| -      HValue* outer_context = environment()->context();
 | 
| -      if (declaration_scope->is_script_scope() ||
 | 
| -          declaration_scope->is_eval_scope()) {
 | 
| -        function = new(zone()) HLoadContextSlot(
 | 
| -            outer_context, Context::CLOSURE_INDEX, HLoadContextSlot::kNoCheck);
 | 
| -      } else {
 | 
| -        function = New<HThisFunction>();
 | 
| -      }
 | 
| -      AddInstruction(function);
 | 
| -      // Allocate a block context and store it to the stack frame.
 | 
| -      HInstruction* inner_context = Add<HAllocateBlockContext>(
 | 
| -          outer_context, function, scope->GetScopeInfo(isolate()));
 | 
| -      HInstruction* instr = Add<HStoreFrameContext>(inner_context);
 | 
| -      set_scope(scope);
 | 
| -      environment()->BindContext(inner_context);
 | 
| -      if (instr->HasObservableSideEffects()) {
 | 
| -        AddSimulate(stmt->EntryId(), REMOVABLE_SIMULATE);
 | 
| +      if (scope->ContextLocalCount() > 0) {
 | 
| +        // Load the function object.
 | 
| +        Scope* declaration_scope = scope->DeclarationScope();
 | 
| +        HInstruction* function;
 | 
| +        HValue* outer_context = environment()->context();
 | 
| +        if (declaration_scope->is_script_scope() ||
 | 
| +            declaration_scope->is_eval_scope()) {
 | 
| +          function = new (zone())
 | 
| +              HLoadContextSlot(outer_context, Context::CLOSURE_INDEX,
 | 
| +                               HLoadContextSlot::kNoCheck);
 | 
| +        } else {
 | 
| +          function = New<HThisFunction>();
 | 
| +        }
 | 
| +        AddInstruction(function);
 | 
| +        // Allocate a block context and store it to the stack frame.
 | 
| +        HInstruction* inner_context = Add<HAllocateBlockContext>(
 | 
| +            outer_context, function, scope->GetScopeInfo(isolate()));
 | 
| +        HInstruction* instr = Add<HStoreFrameContext>(inner_context);
 | 
| +        set_scope(scope);
 | 
| +        environment()->BindContext(inner_context);
 | 
| +        if (instr->HasObservableSideEffects()) {
 | 
| +          AddSimulate(stmt->EntryId(), REMOVABLE_SIMULATE);
 | 
| +        }
 | 
|        }
 | 
|        VisitDeclarations(scope->declarations());
 | 
|        AddSimulate(stmt->DeclsId(), REMOVABLE_SIMULATE);
 | 
| @@ -4523,7 +4526,8 @@ void HOptimizedGraphBuilder::VisitBlock(Block* stmt) {
 | 
|      CHECK_BAILOUT(VisitStatements(stmt->statements()));
 | 
|    }
 | 
|    set_scope(outer_scope);
 | 
| -  if (scope != NULL && current_block() != NULL) {
 | 
| +  if (scope != NULL && current_block() != NULL &&
 | 
| +      scope->ContextLocalCount() > 0) {
 | 
|      HValue* inner_context = environment()->context();
 | 
|      HValue* outer_context = Add<HLoadNamedField>(
 | 
|          inner_context, nullptr,
 | 
| 
 |