Index: src/ia32/full-codegen-ia32.cc |
diff --git a/src/ia32/full-codegen-ia32.cc b/src/ia32/full-codegen-ia32.cc |
index 588b04e2b5b282f37c5eb90028e3699d8d98b2fa..3fc4020a1b508477941ee5c92df5d3561314f7fb 100644 |
--- a/src/ia32/full-codegen-ia32.cc |
+++ b/src/ia32/full-codegen-ia32.cc |
@@ -1341,15 +1341,18 @@ void FullCodeGenerator::EmitGlobalVariableLoad(VariableProxy* proxy, |
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(), |
- Immediate(Smi::FromInt(depth))); |
- __ mov(LoadGlobalViaContextDescriptor::SlotRegister(), |
- Immediate(Smi::FromInt(slot_index))); |
- __ mov(LoadGlobalViaContextDescriptor::NameRegister(), var->name()); |
- LoadGlobalViaContextStub stub(isolate(), depth); |
- __ CallStub(&stub); |
+ int const slot = var->index(); |
+ int const depth = scope()->ContextChainLength(var->scope()); |
+ if (depth <= LoadGlobalViaContextStub::kMaximumDepth) { |
+ __ Move(LoadGlobalViaContextDescriptor::SlotRegister(), Immediate(slot)); |
+ __ mov(LoadGlobalViaContextDescriptor::NameRegister(), var->name()); |
+ LoadGlobalViaContextStub stub(isolate(), depth); |
+ __ CallStub(&stub); |
+ } else { |
+ __ Push(Smi::FromInt(slot)); |
+ __ Push(var->name()); |
+ __ CallRuntime(Runtime::kLoadGlobalViaContext, 2); |
+ } |
} else { |
__ mov(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); |
@@ -2620,16 +2623,23 @@ void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, |
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(), |
- Immediate(Smi::FromInt(depth))); |
- __ mov(StoreGlobalViaContextDescriptor::SlotRegister(), |
- Immediate(Smi::FromInt(slot_index))); |
- __ mov(StoreGlobalViaContextDescriptor::NameRegister(), var->name()); |
- DCHECK(StoreGlobalViaContextDescriptor::ValueRegister().is(eax)); |
- StoreGlobalViaContextStub stub(isolate(), depth, language_mode()); |
- __ CallStub(&stub); |
+ int const slot = var->index() + 1; |
+ int const depth = scope()->ContextChainLength(var->scope()); |
+ if (depth <= StoreGlobalViaContextStub::kMaximumDepth) { |
+ __ Move(StoreGlobalViaContextDescriptor::SlotRegister(), Immediate(slot)); |
+ __ mov(StoreGlobalViaContextDescriptor::NameRegister(), var->name()); |
+ DCHECK(StoreGlobalViaContextDescriptor::ValueRegister().is(eax)); |
+ StoreGlobalViaContextStub stub(isolate(), depth, language_mode()); |
+ __ CallStub(&stub); |
+ } else { |
+ __ Push(Smi::FromInt(slot)); |
+ __ Push(var->name()); |
+ __ Push(eax); |
+ __ CallRuntime(is_strict(language_mode()) |
+ ? Runtime::kStoreGlobalViaContext_Strict |
+ : Runtime::kStoreGlobalViaContext_Sloppy, |
+ 3); |
+ } |
} else if (var->mode() == LET && op != Token::INIT_LET) { |
// Non-initializing assignment to let variable needs a write barrier. |