Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Unified Diff: src/ia32/full-codegen-ia32.cc

Issue 1238143002: [stubs] Optimize LoadGlobalViaContextStub and StoreGlobalViaContextStub. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix ARM typo. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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.

Powered by Google App Engine
This is Rietveld 408576698