Index: src/x87/full-codegen-x87.cc |
diff --git a/src/x87/full-codegen-x87.cc b/src/x87/full-codegen-x87.cc |
index dca00d241bb9ce95486a2f6105cb96841b3e2ecd..4640323f7f8641f60e7e73492a86059a39d63dc5 100644 |
--- a/src/x87/full-codegen-x87.cc |
+++ b/src/x87/full-codegen-x87.cc |
@@ -1334,15 +1334,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()); |
@@ -2611,16 +2614,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. |