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

Unified Diff: src/x64/lithium-codegen-x64.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/x64/lithium-codegen-x64.cc
diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc
index 92688ce4992ed4b7089963b80af0a22babe70cb7..a4c36b893fc906a10ee698ba17d0a82873dd6d27 100644
--- a/src/x64/lithium-codegen-x64.cc
+++ b/src/x64/lithium-codegen-x64.cc
@@ -2898,16 +2898,19 @@ void LCodeGen::DoLoadGlobalGeneric(LLoadGlobalGeneric* instr) {
void LCodeGen::DoLoadGlobalViaContext(LLoadGlobalViaContext* instr) {
DCHECK(ToRegister(instr->context()).is(rsi));
DCHECK(ToRegister(instr->result()).is(rax));
-
- __ Move(LoadGlobalViaContextDescriptor::DepthRegister(),
- Smi::FromInt(instr->depth()));
- __ Move(LoadGlobalViaContextDescriptor::SlotRegister(),
- Smi::FromInt(instr->slot_index()));
- __ Move(LoadGlobalViaContextDescriptor::NameRegister(), instr->name());
-
- Handle<Code> stub =
- CodeFactory::LoadGlobalViaContext(isolate(), instr->depth()).code();
- CallCode(stub, RelocInfo::CODE_TARGET, instr);
+ int const slot = instr->slot_index();
+ int const depth = instr->depth();
+ if (depth <= LoadGlobalViaContextStub::kMaximumDepth) {
+ __ Set(LoadGlobalViaContextDescriptor::SlotRegister(), slot);
+ __ Move(LoadGlobalViaContextDescriptor::NameRegister(), instr->name());
+ Handle<Code> stub =
+ CodeFactory::LoadGlobalViaContext(isolate(), depth).code();
+ CallCode(stub, RelocInfo::CODE_TARGET, instr);
+ } else {
+ __ Push(Smi::FromInt(slot));
+ __ Push(instr->name());
+ __ CallRuntime(Runtime::kLoadGlobalViaContext, 2);
+ }
}
@@ -4272,17 +4275,24 @@ void LCodeGen::DoStoreGlobalViaContext(LStoreGlobalViaContext* instr) {
DCHECK(ToRegister(instr->context()).is(rsi));
DCHECK(ToRegister(instr->value())
.is(StoreGlobalViaContextDescriptor::ValueRegister()));
-
- __ Move(StoreGlobalViaContextDescriptor::DepthRegister(),
- Smi::FromInt(instr->depth()));
- __ Move(StoreGlobalViaContextDescriptor::SlotRegister(),
- Smi::FromInt(instr->slot_index()));
- __ Move(StoreGlobalViaContextDescriptor::NameRegister(), instr->name());
-
- Handle<Code> stub =
- CodeFactory::StoreGlobalViaContext(isolate(), instr->depth(),
- instr->language_mode()).code();
- CallCode(stub, RelocInfo::CODE_TARGET, instr);
+ int const slot = instr->slot_index();
+ int const depth = instr->depth();
+ if (depth <= StoreGlobalViaContextStub::kMaximumDepth) {
+ __ Set(StoreGlobalViaContextDescriptor::SlotRegister(), slot);
+ __ Move(StoreGlobalViaContextDescriptor::NameRegister(), instr->name());
+ Handle<Code> stub = CodeFactory::StoreGlobalViaContext(
+ isolate(), depth, instr->language_mode())
+ .code();
+ CallCode(stub, RelocInfo::CODE_TARGET, instr);
+ } else {
+ __ Push(Smi::FromInt(slot));
+ __ Push(instr->name());
+ __ Push(StoreGlobalViaContextDescriptor::ValueRegister());
+ __ CallRuntime(is_strict(instr->language_mode())
+ ? Runtime::kStoreGlobalViaContext_Strict
+ : Runtime::kStoreGlobalViaContext_Sloppy,
+ 3);
+ }
}

Powered by Google App Engine
This is Rietveld 408576698