| Index: src/hydrogen.cc | 
| diff --git a/src/hydrogen.cc b/src/hydrogen.cc | 
| index 46f0bfe04370879dd148a56b9071d27640d6ea67..da904736c33c9ff2e28e8e00ee9b6352c8c11632 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, | 
|  |