Index: src/arm64/full-codegen-arm64.cc |
diff --git a/src/arm64/full-codegen-arm64.cc b/src/arm64/full-codegen-arm64.cc |
index 324bfb8160158e3de1875abbd8da9ffb6d89c41c..633645284948cf6b982bd303483709c0fcc6292f 100644 |
--- a/src/arm64/full-codegen-arm64.cc |
+++ b/src/arm64/full-codegen-arm64.cc |
@@ -1472,13 +1472,30 @@ void FullCodeGenerator::EmitGlobalVariableLoad(VariableProxy* proxy, |
Variable* var = proxy->var(); |
DCHECK(var->IsUnallocatedOrGlobalSlot() || |
(var->IsLookupSlot() && var->mode() == DYNAMIC_GLOBAL)); |
- __ Ldr(LoadDescriptor::ReceiverRegister(), GlobalObjectMemOperand()); |
- __ Mov(LoadDescriptor::NameRegister(), Operand(var->name())); |
- __ Mov(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()); |
+ __ Mov(LoadGlobalViaContextDescriptor::DepthRegister(), |
+ Operand(Smi::FromInt(depth))); |
+ __ Mov(LoadGlobalViaContextDescriptor::SlotRegister(), |
+ Operand(Smi::FromInt(slot_index))); |
+ __ Mov(LoadGlobalViaContextDescriptor::NameRegister(), |
+ Operand(var->name())); |
+ LoadGlobalViaContextStub stub(isolate(), depth); |
+ __ CallStub(&stub); |
+ |
+ } else { |
+ __ Ldr(LoadDescriptor::ReceiverRegister(), GlobalObjectMemOperand()); |
+ __ Mov(LoadDescriptor::NameRegister(), Operand(var->name())); |
+ __ Mov(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); |
+ } |
} |
@@ -2439,13 +2456,30 @@ void FullCodeGenerator::EmitStoreToStackLocalOrContextSlot( |
void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, |
FeedbackVectorICSlot slot) { |
ASM_LOCATION("FullCodeGenerator::EmitVariableAssignment"); |
- if (var->IsUnallocatedOrGlobalSlot()) { |
+ if (var->IsUnallocated()) { |
// Global var, const, or let. |
__ Mov(StoreDescriptor::NameRegister(), Operand(var->name())); |
__ Ldr(StoreDescriptor::ReceiverRegister(), GlobalObjectMemOperand()); |
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()); |
+ __ Mov(StoreGlobalViaContextDescriptor::DepthRegister(), |
+ Operand(Smi::FromInt(depth))); |
+ __ Mov(StoreGlobalViaContextDescriptor::SlotRegister(), |
+ Operand(Smi::FromInt(slot_index))); |
+ __ Mov(StoreGlobalViaContextDescriptor::NameRegister(), |
+ Operand(var->name())); |
+ DCHECK(StoreGlobalViaContextDescriptor::ValueRegister().is(x0)); |
+ 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()); |