Index: src/x64/full-codegen-x64.cc |
diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc |
index ef8c15087fe292930e5322509eccd9be17b7b4cd..843abb843281fc4e65393099b6cddb2ba99dd709 100644 |
--- a/src/x64/full-codegen-x64.cc |
+++ b/src/x64/full-codegen-x64.cc |
@@ -1454,13 +1454,29 @@ void FullCodeGenerator::EmitGlobalVariableLoad(VariableProxy* proxy, |
Variable* var = proxy->var(); |
DCHECK(var->IsUnallocatedOrGlobalSlot() || |
(var->IsLookupSlot() && var->mode() == DYNAMIC_GLOBAL)); |
- __ Move(LoadDescriptor::NameRegister(), var->name()); |
- __ movp(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); |
- __ Move(LoadDescriptor::SlotRegister(), |
- SmiFromSlot(proxy->VariableFeedbackSlot())); |
- // Inside typeof use a regular load, not a contextual load, to avoid |
- // a reference error. |
- CallLoadIC(typeof_state == NOT_INSIDE_TYPEOF ? CONTEXTUAL : NOT_CONTEXTUAL); |
+ if (var->IsGlobalSlot()) { |
+ DCHECK(var->index() > 0); |
+ DCHECK(var->IsStaticGlobalObjectProperty()); |
+ // Each var occupies two slots in the context: for reads and writes. |
+ int slot_index = var->index(); |
+ int depth = scope()->ContextChainLength(var->scope()); |
+ __ Move(LoadGlobalViaContextDescriptor::DepthRegister(), |
+ Smi::FromInt(depth)); |
+ __ Move(LoadGlobalViaContextDescriptor::SlotRegister(), |
+ Smi::FromInt(slot_index)); |
+ __ Move(LoadGlobalViaContextDescriptor::NameRegister(), var->name()); |
+ LoadGlobalViaContextStub stub(isolate(), depth); |
+ __ CallStub(&stub); |
+ |
+ } else { |
+ __ Move(LoadDescriptor::NameRegister(), var->name()); |
+ __ movp(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); |
+ __ Move(LoadDescriptor::SlotRegister(), |
+ SmiFromSlot(proxy->VariableFeedbackSlot())); |
+ // Inside typeof use a regular load, not a contextual load, to avoid |
+ // a reference error. |
+ CallLoadIC(typeof_state == NOT_INSIDE_TYPEOF ? CONTEXTUAL : NOT_CONTEXTUAL); |
+ } |
} |
@@ -2659,13 +2675,29 @@ void FullCodeGenerator::EmitStoreToStackLocalOrContextSlot( |
void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, |
FeedbackVectorICSlot slot) { |
- if (var->IsUnallocatedOrGlobalSlot()) { |
+ if (var->IsUnallocated()) { |
// Global var, const, or let. |
__ Move(StoreDescriptor::NameRegister(), var->name()); |
__ movp(StoreDescriptor::ReceiverRegister(), GlobalObjectOperand()); |
if (FLAG_vector_stores) EmitLoadStoreICSlot(slot); |
CallStoreIC(); |
+ } else if (var->IsGlobalSlot()) { |
+ // Global var, const, or let. |
+ DCHECK(var->index() > 0); |
+ DCHECK(var->IsStaticGlobalObjectProperty()); |
+ // Each var occupies two slots in the context: for reads and writes. |
+ int slot_index = var->index() + 1; |
+ int depth = scope()->ContextChainLength(var->scope()); |
+ __ Move(StoreGlobalViaContextDescriptor::DepthRegister(), |
+ Smi::FromInt(depth)); |
+ __ Move(StoreGlobalViaContextDescriptor::SlotRegister(), |
+ Smi::FromInt(slot_index)); |
+ __ Move(StoreGlobalViaContextDescriptor::NameRegister(), var->name()); |
+ DCHECK(StoreGlobalViaContextDescriptor::ValueRegister().is(rax)); |
+ StoreGlobalViaContextStub stub(isolate(), depth, language_mode()); |
+ __ CallStub(&stub); |
+ |
} else if (var->mode() == LET && op != Token::INIT_LET) { |
// Non-initializing assignment to let variable needs a write barrier. |
DCHECK(!var->IsLookupSlot()); |