| Index: src/compiler/js-generic-lowering.cc
 | 
| diff --git a/src/compiler/js-generic-lowering.cc b/src/compiler/js-generic-lowering.cc
 | 
| index da42aba523c3f635bf22e3caedf2b5c17497410b..1dbe382cfd29b26f4550d9ee3e6fd864a774f18f 100644
 | 
| --- a/src/compiler/js-generic-lowering.cc
 | 
| +++ b/src/compiler/js-generic-lowering.cc
 | 
| @@ -334,12 +334,24 @@ void JSGenericLowering::LowerJSLoadNamed(Node* node) {
 | 
|  
 | 
|  void JSGenericLowering::LowerJSLoadGlobal(Node* node) {
 | 
|    CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
 | 
| -  const LoadNamedParameters& p = LoadGlobalParametersOf(node->op());
 | 
| -  Callable callable = CodeFactory::LoadICInOptimizedCode(
 | 
| -      isolate(), p.contextual_mode(), SLOPPY, UNINITIALIZED);
 | 
| -  node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name()));
 | 
| -  node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index()));
 | 
| -  ReplaceWithStubCall(node, callable, flags);
 | 
| +  const LoadGlobalParameters& p = LoadGlobalParametersOf(node->op());
 | 
| +  if (p.slot_index() >= 0) {
 | 
| +    Callable callable = CodeFactory::LoadGlobalViaContext(isolate(), 0);
 | 
| +    Node* script_context = node->InputAt(0);
 | 
| +    node->ReplaceInput(0, jsgraph()->SmiConstant(0));
 | 
| +    node->ReplaceInput(1, jsgraph()->SmiConstant(p.slot_index()));
 | 
| +    node->ReplaceInput(2, jsgraph()->HeapConstant(p.name()));
 | 
| +    node->ReplaceInput(3, script_context);  // Replace old context.
 | 
| +    ReplaceWithStubCall(node, callable, flags);
 | 
| +
 | 
| +  } else {
 | 
| +    Callable callable = CodeFactory::LoadICInOptimizedCode(
 | 
| +        isolate(), p.contextual_mode(), SLOPPY, UNINITIALIZED);
 | 
| +    node->RemoveInput(0);  // script context
 | 
| +    node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name()));
 | 
| +    node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index()));
 | 
| +    ReplaceWithStubCall(node, callable, flags);
 | 
| +  }
 | 
|  }
 | 
|  
 | 
|  
 | 
| @@ -379,17 +391,33 @@ void JSGenericLowering::LowerJSStoreNamed(Node* node) {
 | 
|  
 | 
|  void JSGenericLowering::LowerJSStoreGlobal(Node* node) {
 | 
|    CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
 | 
| -  const StoreNamedParameters& p = StoreGlobalParametersOf(node->op());
 | 
| -  Callable callable = CodeFactory::StoreIC(isolate(), p.language_mode());
 | 
| -  node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name()));
 | 
| -  if (FLAG_vector_stores) {
 | 
| -    DCHECK(p.feedback().index() != -1);
 | 
| -    node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.feedback().index()));
 | 
| +  const StoreGlobalParameters& p = StoreGlobalParametersOf(node->op());
 | 
| +  if (p.slot_index() >= 0) {
 | 
| +    Callable callable =
 | 
| +        CodeFactory::StoreGlobalViaContext(isolate(), 0, p.language_mode());
 | 
| +    Node* script_context = node->InputAt(0);
 | 
| +    Node* value = node->InputAt(2);
 | 
| +    node->ReplaceInput(0, jsgraph()->SmiConstant(0));
 | 
| +    node->ReplaceInput(1, jsgraph()->SmiConstant(p.slot_index()));
 | 
| +    node->ReplaceInput(2, jsgraph()->HeapConstant(p.name()));
 | 
| +    node->ReplaceInput(3, value);
 | 
| +    node->ReplaceInput(4, script_context);  // Replace old context.
 | 
| +    ReplaceWithStubCall(node, callable, flags);
 | 
| +
 | 
|    } else {
 | 
| -    node->RemoveInput(3);
 | 
| +    Callable callable = CodeFactory::StoreIC(isolate(), p.language_mode());
 | 
| +    node->RemoveInput(0);  // script context
 | 
| +    node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name()));
 | 
| +    if (FLAG_vector_stores) {
 | 
| +      DCHECK(p.feedback().index() != -1);
 | 
| +      node->InsertInput(zone(), 3,
 | 
| +                        jsgraph()->SmiConstant(p.feedback().index()));
 | 
| +    } else {
 | 
| +      node->RemoveInput(3);
 | 
| +    }
 | 
| +    ReplaceWithStubCall(node, callable,
 | 
| +                        CallDescriptor::kPatchableCallSite | flags);
 | 
|    }
 | 
| -  ReplaceWithStubCall(node, callable,
 | 
| -                      CallDescriptor::kPatchableCallSite | flags);
 | 
|  }
 | 
|  
 | 
|  
 | 
| 
 |