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_IA32 | 7 #if V8_TARGET_ARCH_IA32 |
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 1390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1401 | 1401 |
1402 void FullCodeGenerator::EmitGlobalVariableLoad(VariableProxy* proxy, | 1402 void FullCodeGenerator::EmitGlobalVariableLoad(VariableProxy* proxy, |
1403 TypeofMode typeof_mode) { | 1403 TypeofMode typeof_mode) { |
1404 Variable* var = proxy->var(); | 1404 Variable* var = proxy->var(); |
1405 DCHECK(var->IsUnallocatedOrGlobalSlot() || | 1405 DCHECK(var->IsUnallocatedOrGlobalSlot() || |
1406 (var->IsLookupSlot() && var->mode() == DYNAMIC_GLOBAL)); | 1406 (var->IsLookupSlot() && var->mode() == DYNAMIC_GLOBAL)); |
1407 if (var->IsGlobalSlot()) { | 1407 if (var->IsGlobalSlot()) { |
1408 DCHECK(var->index() > 0); | 1408 DCHECK(var->index() > 0); |
1409 DCHECK(var->IsStaticGlobalObjectProperty()); | 1409 DCHECK(var->IsStaticGlobalObjectProperty()); |
1410 // Each var occupies two slots in the context: for reads and writes. | 1410 // Each var occupies two slots in the context: for reads and writes. |
1411 int slot_index = var->index(); | 1411 int const slot = var->index(); |
1412 int depth = scope()->ContextChainLength(var->scope()); | 1412 int const depth = scope()->ContextChainLength(var->scope()); |
1413 __ mov(LoadGlobalViaContextDescriptor::DepthRegister(), | 1413 if (depth <= LoadGlobalViaContextStub::kMaximumDepth) { |
1414 Immediate(Smi::FromInt(depth))); | 1414 __ Move(LoadGlobalViaContextDescriptor::SlotRegister(), Immediate(slot)); |
jbramley
2015/07/21 10:25:31
Is it safe to pass raw (non-smi) integers to stubs
| |
1415 __ mov(LoadGlobalViaContextDescriptor::SlotRegister(), | 1415 __ mov(LoadGlobalViaContextDescriptor::NameRegister(), var->name()); |
1416 Immediate(Smi::FromInt(slot_index))); | 1416 LoadGlobalViaContextStub stub(isolate(), depth); |
1417 __ mov(LoadGlobalViaContextDescriptor::NameRegister(), var->name()); | 1417 __ CallStub(&stub); |
1418 LoadGlobalViaContextStub stub(isolate(), depth); | 1418 } else { |
1419 __ CallStub(&stub); | 1419 __ Push(Smi::FromInt(slot)); |
1420 __ Push(var->name()); | |
1421 __ CallRuntime(Runtime::kLoadGlobalViaContext, 2); | |
1422 } | |
1420 | 1423 |
1421 } else { | 1424 } else { |
1422 __ mov(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); | 1425 __ mov(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); |
1423 __ mov(LoadDescriptor::NameRegister(), var->name()); | 1426 __ mov(LoadDescriptor::NameRegister(), var->name()); |
1424 __ mov(LoadDescriptor::SlotRegister(), | 1427 __ mov(LoadDescriptor::SlotRegister(), |
1425 Immediate(SmiFromSlot(proxy->VariableFeedbackSlot()))); | 1428 Immediate(SmiFromSlot(proxy->VariableFeedbackSlot()))); |
1426 CallLoadIC(typeof_mode); | 1429 CallLoadIC(typeof_mode); |
1427 } | 1430 } |
1428 } | 1431 } |
1429 | 1432 |
(...skipping 1250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2680 __ mov(StoreDescriptor::NameRegister(), var->name()); | 2683 __ mov(StoreDescriptor::NameRegister(), var->name()); |
2681 __ mov(StoreDescriptor::ReceiverRegister(), GlobalObjectOperand()); | 2684 __ mov(StoreDescriptor::ReceiverRegister(), GlobalObjectOperand()); |
2682 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot); | 2685 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot); |
2683 CallStoreIC(); | 2686 CallStoreIC(); |
2684 | 2687 |
2685 } else if (var->IsGlobalSlot()) { | 2688 } else if (var->IsGlobalSlot()) { |
2686 // Global var, const, or let. | 2689 // Global var, const, or let. |
2687 DCHECK(var->index() > 0); | 2690 DCHECK(var->index() > 0); |
2688 DCHECK(var->IsStaticGlobalObjectProperty()); | 2691 DCHECK(var->IsStaticGlobalObjectProperty()); |
2689 // Each var occupies two slots in the context: for reads and writes. | 2692 // Each var occupies two slots in the context: for reads and writes. |
2690 int slot_index = var->index() + 1; | 2693 int const slot = var->index() + 1; |
jbramley
2015/07/21 10:25:31
`slot` shadows a function argument.
| |
2691 int depth = scope()->ContextChainLength(var->scope()); | 2694 int const depth = scope()->ContextChainLength(var->scope()); |
jbramley
2015/07/21 10:25:31
Also, isn't the preferred style "const int" in Goo
| |
2692 __ mov(StoreGlobalViaContextDescriptor::DepthRegister(), | 2695 if (depth <= StoreGlobalViaContextStub::kMaximumDepth) { |
2693 Immediate(Smi::FromInt(depth))); | 2696 __ Move(StoreGlobalViaContextDescriptor::SlotRegister(), Immediate(slot)); |
2694 __ mov(StoreGlobalViaContextDescriptor::SlotRegister(), | 2697 __ mov(StoreGlobalViaContextDescriptor::NameRegister(), var->name()); |
2695 Immediate(Smi::FromInt(slot_index))); | 2698 DCHECK(StoreGlobalViaContextDescriptor::ValueRegister().is(eax)); |
2696 __ mov(StoreGlobalViaContextDescriptor::NameRegister(), var->name()); | 2699 StoreGlobalViaContextStub stub(isolate(), depth, language_mode()); |
2697 DCHECK(StoreGlobalViaContextDescriptor::ValueRegister().is(eax)); | 2700 __ CallStub(&stub); |
2698 StoreGlobalViaContextStub stub(isolate(), depth, language_mode()); | 2701 } else { |
2699 __ CallStub(&stub); | 2702 __ Push(Smi::FromInt(slot)); |
2703 __ Push(var->name()); | |
2704 __ Push(eax); | |
2705 __ CallRuntime(is_strict(language_mode()) | |
2706 ? Runtime::kStoreGlobalViaContext_Strict | |
2707 : Runtime::kStoreGlobalViaContext_Sloppy, | |
2708 3); | |
2709 } | |
2700 | 2710 |
2701 } else if (var->mode() == LET && op != Token::INIT_LET) { | 2711 } else if (var->mode() == LET && op != Token::INIT_LET) { |
2702 // Non-initializing assignment to let variable needs a write barrier. | 2712 // Non-initializing assignment to let variable needs a write barrier. |
2703 DCHECK(!var->IsLookupSlot()); | 2713 DCHECK(!var->IsLookupSlot()); |
2704 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); | 2714 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); |
2705 Label assign; | 2715 Label assign; |
2706 MemOperand location = VarOperand(var, ecx); | 2716 MemOperand location = VarOperand(var, ecx); |
2707 __ mov(edx, location); | 2717 __ mov(edx, location); |
2708 __ cmp(edx, isolate()->factory()->the_hole_value()); | 2718 __ cmp(edx, isolate()->factory()->the_hole_value()); |
2709 __ j(not_equal, &assign, Label::kNear); | 2719 __ j(not_equal, &assign, Label::kNear); |
(...skipping 2747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5457 Assembler::target_address_at(call_target_address, | 5467 Assembler::target_address_at(call_target_address, |
5458 unoptimized_code)); | 5468 unoptimized_code)); |
5459 return OSR_AFTER_STACK_CHECK; | 5469 return OSR_AFTER_STACK_CHECK; |
5460 } | 5470 } |
5461 | 5471 |
5462 | 5472 |
5463 } // namespace internal | 5473 } // namespace internal |
5464 } // namespace v8 | 5474 } // namespace v8 |
5465 | 5475 |
5466 #endif // V8_TARGET_ARCH_IA32 | 5476 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |