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

Side by Side Diff: src/x64/full-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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #if V8_TARGET_ARCH_X64 7 #if V8_TARGET_ARCH_X64
8 8
9 #include "src/code-factory.h" 9 #include "src/code-factory.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 1352 matching lines...) Expand 10 before | Expand all | Expand 10 after
1363 1363
1364 void FullCodeGenerator::EmitGlobalVariableLoad(VariableProxy* proxy, 1364 void FullCodeGenerator::EmitGlobalVariableLoad(VariableProxy* proxy,
1365 TypeofMode typeof_mode) { 1365 TypeofMode typeof_mode) {
1366 Variable* var = proxy->var(); 1366 Variable* var = proxy->var();
1367 DCHECK(var->IsUnallocatedOrGlobalSlot() || 1367 DCHECK(var->IsUnallocatedOrGlobalSlot() ||
1368 (var->IsLookupSlot() && var->mode() == DYNAMIC_GLOBAL)); 1368 (var->IsLookupSlot() && var->mode() == DYNAMIC_GLOBAL));
1369 if (var->IsGlobalSlot()) { 1369 if (var->IsGlobalSlot()) {
1370 DCHECK(var->index() > 0); 1370 DCHECK(var->index() > 0);
1371 DCHECK(var->IsStaticGlobalObjectProperty()); 1371 DCHECK(var->IsStaticGlobalObjectProperty());
1372 // Each var occupies two slots in the context: for reads and writes. 1372 // Each var occupies two slots in the context: for reads and writes.
1373 int slot_index = var->index(); 1373 int const slot = var->index();
1374 int depth = scope()->ContextChainLength(var->scope()); 1374 int const depth = scope()->ContextChainLength(var->scope());
1375 __ Move(LoadGlobalViaContextDescriptor::DepthRegister(), 1375 if (depth <= LoadGlobalViaContextStub::kMaximumDepth) {
1376 Smi::FromInt(depth)); 1376 __ Set(LoadGlobalViaContextDescriptor::SlotRegister(), slot);
1377 __ Move(LoadGlobalViaContextDescriptor::SlotRegister(), 1377 __ Move(LoadGlobalViaContextDescriptor::NameRegister(), var->name());
1378 Smi::FromInt(slot_index)); 1378 LoadGlobalViaContextStub stub(isolate(), depth);
1379 __ Move(LoadGlobalViaContextDescriptor::NameRegister(), var->name()); 1379 __ CallStub(&stub);
1380 LoadGlobalViaContextStub stub(isolate(), depth); 1380 } else {
1381 __ CallStub(&stub); 1381 __ Push(Smi::FromInt(slot));
1382 __ Push(var->name());
1383 __ CallRuntime(Runtime::kLoadGlobalViaContext, 2);
1384 }
1382 1385
1383 } else { 1386 } else {
1384 __ Move(LoadDescriptor::NameRegister(), var->name()); 1387 __ Move(LoadDescriptor::NameRegister(), var->name());
1385 __ movp(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); 1388 __ movp(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand());
1386 __ Move(LoadDescriptor::SlotRegister(), 1389 __ Move(LoadDescriptor::SlotRegister(),
1387 SmiFromSlot(proxy->VariableFeedbackSlot())); 1390 SmiFromSlot(proxy->VariableFeedbackSlot()));
1388 CallLoadIC(typeof_mode); 1391 CallLoadIC(typeof_mode);
1389 } 1392 }
1390 } 1393 }
1391 1394
(...skipping 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after
2608 __ Move(StoreDescriptor::NameRegister(), var->name()); 2611 __ Move(StoreDescriptor::NameRegister(), var->name());
2609 __ movp(StoreDescriptor::ReceiverRegister(), GlobalObjectOperand()); 2612 __ movp(StoreDescriptor::ReceiverRegister(), GlobalObjectOperand());
2610 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot); 2613 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot);
2611 CallStoreIC(); 2614 CallStoreIC();
2612 2615
2613 } else if (var->IsGlobalSlot()) { 2616 } else if (var->IsGlobalSlot()) {
2614 // Global var, const, or let. 2617 // Global var, const, or let.
2615 DCHECK(var->index() > 0); 2618 DCHECK(var->index() > 0);
2616 DCHECK(var->IsStaticGlobalObjectProperty()); 2619 DCHECK(var->IsStaticGlobalObjectProperty());
2617 // Each var occupies two slots in the context: for reads and writes. 2620 // Each var occupies two slots in the context: for reads and writes.
2618 int slot_index = var->index() + 1; 2621 int const slot = var->index() + 1;
2619 int depth = scope()->ContextChainLength(var->scope()); 2622 int const depth = scope()->ContextChainLength(var->scope());
2620 __ Move(StoreGlobalViaContextDescriptor::DepthRegister(), 2623 if (depth <= StoreGlobalViaContextStub::kMaximumDepth) {
2621 Smi::FromInt(depth)); 2624 __ Set(StoreGlobalViaContextDescriptor::SlotRegister(), slot);
2622 __ Move(StoreGlobalViaContextDescriptor::SlotRegister(), 2625 __ Move(StoreGlobalViaContextDescriptor::NameRegister(), var->name());
2623 Smi::FromInt(slot_index)); 2626 DCHECK(StoreGlobalViaContextDescriptor::ValueRegister().is(rax));
2624 __ Move(StoreGlobalViaContextDescriptor::NameRegister(), var->name()); 2627 StoreGlobalViaContextStub stub(isolate(), depth, language_mode());
2625 DCHECK(StoreGlobalViaContextDescriptor::ValueRegister().is(rax)); 2628 __ CallStub(&stub);
2626 StoreGlobalViaContextStub stub(isolate(), depth, language_mode()); 2629 } else {
2627 __ CallStub(&stub); 2630 __ Push(Smi::FromInt(slot));
2631 __ Push(var->name());
2632 __ Push(rax);
2633 __ CallRuntime(is_strict(language_mode())
2634 ? Runtime::kStoreGlobalViaContext_Strict
2635 : Runtime::kStoreGlobalViaContext_Sloppy,
2636 3);
2637 }
2628 2638
2629 } else if (var->mode() == LET && op != Token::INIT_LET) { 2639 } else if (var->mode() == LET && op != Token::INIT_LET) {
2630 // Non-initializing assignment to let variable needs a write barrier. 2640 // Non-initializing assignment to let variable needs a write barrier.
2631 DCHECK(!var->IsLookupSlot()); 2641 DCHECK(!var->IsLookupSlot());
2632 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); 2642 DCHECK(var->IsStackAllocated() || var->IsContextSlot());
2633 Label assign; 2643 Label assign;
2634 MemOperand location = VarOperand(var, rcx); 2644 MemOperand location = VarOperand(var, rcx);
2635 __ movp(rdx, location); 2645 __ movp(rdx, location);
2636 __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex); 2646 __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex);
2637 __ j(not_equal, &assign, Label::kNear); 2647 __ j(not_equal, &assign, Label::kNear);
(...skipping 2718 matching lines...) Expand 10 before | Expand all | Expand 10 after
5356 Assembler::target_address_at(call_target_address, 5366 Assembler::target_address_at(call_target_address,
5357 unoptimized_code)); 5367 unoptimized_code));
5358 return OSR_AFTER_STACK_CHECK; 5368 return OSR_AFTER_STACK_CHECK;
5359 } 5369 }
5360 5370
5361 5371
5362 } // namespace internal 5372 } // namespace internal
5363 } // namespace v8 5373 } // namespace v8
5364 5374
5365 #endif // V8_TARGET_ARCH_X64 5375 #endif // V8_TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698