Chromium Code Reviews| Index: src/ia32/full-codegen-ia32.cc |
| diff --git a/src/ia32/full-codegen-ia32.cc b/src/ia32/full-codegen-ia32.cc |
| index 6060b3616efe778e4742678675f3669894911d10..dd6db17956db9de6f563c4560f2377afd637bb2a 100644 |
| --- a/src/ia32/full-codegen-ia32.cc |
| +++ b/src/ia32/full-codegen-ia32.cc |
| @@ -1408,15 +1408,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)); |
|
jbramley
2015/07/21 10:25:31
Is it safe to pass raw (non-smi) integers to stubs
|
| + __ 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()); |
| @@ -2687,16 +2690,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; |
|
jbramley
2015/07/21 10:25:31
`slot` shadows a function argument.
|
| + int const depth = scope()->ContextChainLength(var->scope()); |
|
jbramley
2015/07/21 10:25:31
Also, isn't the preferred style "const int" in Goo
|
| + 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. |