OLD | NEW |
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 1418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1429 | 1429 |
1430 void FullCodeGenerator::EmitGlobalVariableLoad(VariableProxy* proxy, | 1430 void FullCodeGenerator::EmitGlobalVariableLoad(VariableProxy* proxy, |
1431 TypeofMode typeof_mode) { | 1431 TypeofMode typeof_mode) { |
1432 Variable* var = proxy->var(); | 1432 Variable* var = proxy->var(); |
1433 DCHECK(var->IsUnallocatedOrGlobalSlot() || | 1433 DCHECK(var->IsUnallocatedOrGlobalSlot() || |
1434 (var->IsLookupSlot() && var->mode() == DYNAMIC_GLOBAL)); | 1434 (var->IsLookupSlot() && var->mode() == DYNAMIC_GLOBAL)); |
1435 if (var->IsGlobalSlot()) { | 1435 if (var->IsGlobalSlot()) { |
1436 DCHECK(var->index() > 0); | 1436 DCHECK(var->index() > 0); |
1437 DCHECK(var->IsStaticGlobalObjectProperty()); | 1437 DCHECK(var->IsStaticGlobalObjectProperty()); |
1438 // Each var occupies two slots in the context: for reads and writes. | 1438 // Each var occupies two slots in the context: for reads and writes. |
1439 int slot_index = var->index(); | 1439 int const slot = var->index(); |
1440 int depth = scope()->ContextChainLength(var->scope()); | 1440 int const depth = scope()->ContextChainLength(var->scope()); |
1441 __ Move(LoadGlobalViaContextDescriptor::DepthRegister(), | 1441 if (depth <= LoadGlobalViaContextStub::kMaximumDepth) { |
1442 Smi::FromInt(depth)); | 1442 __ Set(LoadGlobalViaContextDescriptor::SlotRegister(), slot); |
1443 __ Move(LoadGlobalViaContextDescriptor::SlotRegister(), | 1443 __ Move(LoadGlobalViaContextDescriptor::NameRegister(), var->name()); |
1444 Smi::FromInt(slot_index)); | 1444 LoadGlobalViaContextStub stub(isolate(), depth); |
1445 __ Move(LoadGlobalViaContextDescriptor::NameRegister(), var->name()); | 1445 __ CallStub(&stub); |
1446 LoadGlobalViaContextStub stub(isolate(), depth); | 1446 } else { |
1447 __ CallStub(&stub); | 1447 __ Push(Smi::FromInt(slot)); |
| 1448 __ Push(var->name()); |
| 1449 __ CallRuntime(Runtime::kLoadGlobalViaContext, 2); |
| 1450 } |
1448 | 1451 |
1449 } else { | 1452 } else { |
1450 __ Move(LoadDescriptor::NameRegister(), var->name()); | 1453 __ Move(LoadDescriptor::NameRegister(), var->name()); |
1451 __ movp(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); | 1454 __ movp(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); |
1452 __ Move(LoadDescriptor::SlotRegister(), | 1455 __ Move(LoadDescriptor::SlotRegister(), |
1453 SmiFromSlot(proxy->VariableFeedbackSlot())); | 1456 SmiFromSlot(proxy->VariableFeedbackSlot())); |
1454 CallLoadIC(typeof_mode); | 1457 CallLoadIC(typeof_mode); |
1455 } | 1458 } |
1456 } | 1459 } |
1457 | 1460 |
(...skipping 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2674 __ Move(StoreDescriptor::NameRegister(), var->name()); | 2677 __ Move(StoreDescriptor::NameRegister(), var->name()); |
2675 __ movp(StoreDescriptor::ReceiverRegister(), GlobalObjectOperand()); | 2678 __ movp(StoreDescriptor::ReceiverRegister(), GlobalObjectOperand()); |
2676 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot); | 2679 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot); |
2677 CallStoreIC(); | 2680 CallStoreIC(); |
2678 | 2681 |
2679 } else if (var->IsGlobalSlot()) { | 2682 } else if (var->IsGlobalSlot()) { |
2680 // Global var, const, or let. | 2683 // Global var, const, or let. |
2681 DCHECK(var->index() > 0); | 2684 DCHECK(var->index() > 0); |
2682 DCHECK(var->IsStaticGlobalObjectProperty()); | 2685 DCHECK(var->IsStaticGlobalObjectProperty()); |
2683 // Each var occupies two slots in the context: for reads and writes. | 2686 // Each var occupies two slots in the context: for reads and writes. |
2684 int slot_index = var->index() + 1; | 2687 int const slot = var->index() + 1; |
2685 int depth = scope()->ContextChainLength(var->scope()); | 2688 int const depth = scope()->ContextChainLength(var->scope()); |
2686 __ Move(StoreGlobalViaContextDescriptor::DepthRegister(), | 2689 if (depth <= StoreGlobalViaContextStub::kMaximumDepth) { |
2687 Smi::FromInt(depth)); | 2690 __ Set(StoreGlobalViaContextDescriptor::SlotRegister(), slot); |
2688 __ Move(StoreGlobalViaContextDescriptor::SlotRegister(), | 2691 __ Move(StoreGlobalViaContextDescriptor::NameRegister(), var->name()); |
2689 Smi::FromInt(slot_index)); | 2692 DCHECK(StoreGlobalViaContextDescriptor::ValueRegister().is(rax)); |
2690 __ Move(StoreGlobalViaContextDescriptor::NameRegister(), var->name()); | 2693 StoreGlobalViaContextStub stub(isolate(), depth, language_mode()); |
2691 DCHECK(StoreGlobalViaContextDescriptor::ValueRegister().is(rax)); | 2694 __ CallStub(&stub); |
2692 StoreGlobalViaContextStub stub(isolate(), depth, language_mode()); | 2695 } else { |
2693 __ CallStub(&stub); | 2696 __ Push(Smi::FromInt(slot)); |
| 2697 __ Push(var->name()); |
| 2698 __ Push(rax); |
| 2699 __ CallRuntime(is_strict(language_mode()) |
| 2700 ? Runtime::kStoreGlobalViaContext_Strict |
| 2701 : Runtime::kStoreGlobalViaContext_Sloppy, |
| 2702 3); |
| 2703 } |
2694 | 2704 |
2695 } else if (var->mode() == LET && op != Token::INIT_LET) { | 2705 } else if (var->mode() == LET && op != Token::INIT_LET) { |
2696 // Non-initializing assignment to let variable needs a write barrier. | 2706 // Non-initializing assignment to let variable needs a write barrier. |
2697 DCHECK(!var->IsLookupSlot()); | 2707 DCHECK(!var->IsLookupSlot()); |
2698 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); | 2708 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); |
2699 Label assign; | 2709 Label assign; |
2700 MemOperand location = VarOperand(var, rcx); | 2710 MemOperand location = VarOperand(var, rcx); |
2701 __ movp(rdx, location); | 2711 __ movp(rdx, location); |
2702 __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex); | 2712 __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex); |
2703 __ j(not_equal, &assign, Label::kNear); | 2713 __ j(not_equal, &assign, Label::kNear); |
(...skipping 2770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5474 Assembler::target_address_at(call_target_address, | 5484 Assembler::target_address_at(call_target_address, |
5475 unoptimized_code)); | 5485 unoptimized_code)); |
5476 return OSR_AFTER_STACK_CHECK; | 5486 return OSR_AFTER_STACK_CHECK; |
5477 } | 5487 } |
5478 | 5488 |
5479 | 5489 |
5480 } // namespace internal | 5490 } // namespace internal |
5481 } // namespace v8 | 5491 } // namespace v8 |
5482 | 5492 |
5483 #endif // V8_TARGET_ARCH_X64 | 5493 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |