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

Unified Diff: src/arm/full-codegen-arm.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/arm/full-codegen-arm.cc
diff --git a/src/arm/full-codegen-arm.cc b/src/arm/full-codegen-arm.cc
index 34ac1a54265f4c22079a63a29c1ad1d223b836ac..67840ee675cebc3bc2fdb08c86c8c5bb4360c4e8 100644
--- a/src/arm/full-codegen-arm.cc
+++ b/src/arm/full-codegen-arm.cc
@@ -1415,17 +1415,19 @@ 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(),
- Operand(Smi::FromInt(depth)));
- __ mov(LoadGlobalViaContextDescriptor::SlotRegister(),
- Operand(Smi::FromInt(slot_index)));
- __ mov(LoadGlobalViaContextDescriptor::NameRegister(),
- Operand(var->name()));
- LoadGlobalViaContextStub stub(isolate(), depth);
- __ CallStub(&stub);
-
+ const int slot = var->index();
+ const int depth = scope()->ContextChainLength(var->scope());
+ if (depth <= LoadGlobalViaContextStub::kMaximumDepth) {
+ __ mov(LoadGlobalViaContextDescriptor::SlotRegister(), Operand(slot));
+ __ mov(LoadGlobalViaContextDescriptor::NameRegister(),
+ Operand(var->name()));
+ LoadGlobalViaContextStub stub(isolate(), depth);
+ __ CallStub(&stub);
+ } else {
+ __ Push(Smi::FromInt(slot));
+ __ Push(var->name());
+ __ CallRuntime(Runtime::kLoadGlobalViaContext, 2);
+ }
} else {
__ ldr(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand());
__ mov(LoadDescriptor::NameRegister(), Operand(var->name()));
@@ -2715,18 +2717,24 @@ 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(),
- Operand(Smi::FromInt(depth)));
- __ mov(StoreGlobalViaContextDescriptor::SlotRegister(),
- Operand(Smi::FromInt(slot_index)));
- __ mov(StoreGlobalViaContextDescriptor::NameRegister(),
- Operand(var->name()));
- DCHECK(StoreGlobalViaContextDescriptor::ValueRegister().is(r0));
- StoreGlobalViaContextStub stub(isolate(), depth, language_mode());
- __ CallStub(&stub);
-
+ const int slot = var->index() + 1;
+ const int depth = scope()->ContextChainLength(var->scope());
+ if (depth <= StoreGlobalViaContextStub::kMaximumDepth) {
+ __ mov(StoreGlobalViaContextDescriptor::SlotRegister(), Operand(slot));
+ __ mov(StoreGlobalViaContextDescriptor::NameRegister(),
+ Operand(var->name()));
+ DCHECK(StoreGlobalViaContextDescriptor::ValueRegister().is(r0));
+ StoreGlobalViaContextStub stub(isolate(), depth, language_mode());
+ __ CallStub(&stub);
+ } else {
+ __ Push(Smi::FromInt(slot));
+ __ Push(var->name());
+ __ push(r0);
+ __ 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.
DCHECK(!var->IsLookupSlot());

Powered by Google App Engine
This is Rietveld 408576698