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 1323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1334 | 1334 |
1335 void FullCodeGenerator::EmitGlobalVariableLoad(VariableProxy* proxy, | 1335 void FullCodeGenerator::EmitGlobalVariableLoad(VariableProxy* proxy, |
1336 TypeofMode typeof_mode) { | 1336 TypeofMode typeof_mode) { |
1337 Variable* var = proxy->var(); | 1337 Variable* var = proxy->var(); |
1338 DCHECK(var->IsUnallocatedOrGlobalSlot() || | 1338 DCHECK(var->IsUnallocatedOrGlobalSlot() || |
1339 (var->IsLookupSlot() && var->mode() == DYNAMIC_GLOBAL)); | 1339 (var->IsLookupSlot() && var->mode() == DYNAMIC_GLOBAL)); |
1340 if (var->IsGlobalSlot()) { | 1340 if (var->IsGlobalSlot()) { |
1341 DCHECK(var->index() > 0); | 1341 DCHECK(var->index() > 0); |
1342 DCHECK(var->IsStaticGlobalObjectProperty()); | 1342 DCHECK(var->IsStaticGlobalObjectProperty()); |
1343 // Each var occupies two slots in the context: for reads and writes. | 1343 // Each var occupies two slots in the context: for reads and writes. |
1344 int slot_index = var->index(); | 1344 int const slot = var->index(); |
1345 int depth = scope()->ContextChainLength(var->scope()); | 1345 int const depth = scope()->ContextChainLength(var->scope()); |
1346 __ mov(LoadGlobalViaContextDescriptor::DepthRegister(), | 1346 if (depth <= LoadGlobalViaContextStub::kMaximumDepth) { |
1347 Immediate(Smi::FromInt(depth))); | 1347 __ Move(LoadGlobalViaContextDescriptor::SlotRegister(), Immediate(slot)); |
1348 __ mov(LoadGlobalViaContextDescriptor::SlotRegister(), | 1348 __ mov(LoadGlobalViaContextDescriptor::NameRegister(), var->name()); |
1349 Immediate(Smi::FromInt(slot_index))); | 1349 LoadGlobalViaContextStub stub(isolate(), depth); |
1350 __ mov(LoadGlobalViaContextDescriptor::NameRegister(), var->name()); | 1350 __ CallStub(&stub); |
1351 LoadGlobalViaContextStub stub(isolate(), depth); | 1351 } else { |
1352 __ CallStub(&stub); | 1352 __ Push(Smi::FromInt(slot)); |
| 1353 __ Push(var->name()); |
| 1354 __ CallRuntime(Runtime::kLoadGlobalViaContext, 2); |
| 1355 } |
1353 | 1356 |
1354 } else { | 1357 } else { |
1355 __ mov(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); | 1358 __ mov(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); |
1356 __ mov(LoadDescriptor::NameRegister(), var->name()); | 1359 __ mov(LoadDescriptor::NameRegister(), var->name()); |
1357 __ mov(LoadDescriptor::SlotRegister(), | 1360 __ mov(LoadDescriptor::SlotRegister(), |
1358 Immediate(SmiFromSlot(proxy->VariableFeedbackSlot()))); | 1361 Immediate(SmiFromSlot(proxy->VariableFeedbackSlot()))); |
1359 CallLoadIC(typeof_mode); | 1362 CallLoadIC(typeof_mode); |
1360 } | 1363 } |
1361 } | 1364 } |
1362 | 1365 |
(...skipping 1250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2613 __ mov(StoreDescriptor::NameRegister(), var->name()); | 2616 __ mov(StoreDescriptor::NameRegister(), var->name()); |
2614 __ mov(StoreDescriptor::ReceiverRegister(), GlobalObjectOperand()); | 2617 __ mov(StoreDescriptor::ReceiverRegister(), GlobalObjectOperand()); |
2615 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot); | 2618 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot); |
2616 CallStoreIC(); | 2619 CallStoreIC(); |
2617 | 2620 |
2618 } else if (var->IsGlobalSlot()) { | 2621 } else if (var->IsGlobalSlot()) { |
2619 // Global var, const, or let. | 2622 // Global var, const, or let. |
2620 DCHECK(var->index() > 0); | 2623 DCHECK(var->index() > 0); |
2621 DCHECK(var->IsStaticGlobalObjectProperty()); | 2624 DCHECK(var->IsStaticGlobalObjectProperty()); |
2622 // Each var occupies two slots in the context: for reads and writes. | 2625 // Each var occupies two slots in the context: for reads and writes. |
2623 int slot_index = var->index() + 1; | 2626 int const slot = var->index() + 1; |
2624 int depth = scope()->ContextChainLength(var->scope()); | 2627 int const depth = scope()->ContextChainLength(var->scope()); |
2625 __ mov(StoreGlobalViaContextDescriptor::DepthRegister(), | 2628 if (depth <= StoreGlobalViaContextStub::kMaximumDepth) { |
2626 Immediate(Smi::FromInt(depth))); | 2629 __ Move(StoreGlobalViaContextDescriptor::SlotRegister(), Immediate(slot)); |
2627 __ mov(StoreGlobalViaContextDescriptor::SlotRegister(), | 2630 __ mov(StoreGlobalViaContextDescriptor::NameRegister(), var->name()); |
2628 Immediate(Smi::FromInt(slot_index))); | 2631 DCHECK(StoreGlobalViaContextDescriptor::ValueRegister().is(eax)); |
2629 __ mov(StoreGlobalViaContextDescriptor::NameRegister(), var->name()); | 2632 StoreGlobalViaContextStub stub(isolate(), depth, language_mode()); |
2630 DCHECK(StoreGlobalViaContextDescriptor::ValueRegister().is(eax)); | 2633 __ CallStub(&stub); |
2631 StoreGlobalViaContextStub stub(isolate(), depth, language_mode()); | 2634 } else { |
2632 __ CallStub(&stub); | 2635 __ Push(Smi::FromInt(slot)); |
| 2636 __ Push(var->name()); |
| 2637 __ Push(eax); |
| 2638 __ CallRuntime(is_strict(language_mode()) |
| 2639 ? Runtime::kStoreGlobalViaContext_Strict |
| 2640 : Runtime::kStoreGlobalViaContext_Sloppy, |
| 2641 3); |
| 2642 } |
2633 | 2643 |
2634 } else if (var->mode() == LET && op != Token::INIT_LET) { | 2644 } else if (var->mode() == LET && op != Token::INIT_LET) { |
2635 // Non-initializing assignment to let variable needs a write barrier. | 2645 // Non-initializing assignment to let variable needs a write barrier. |
2636 DCHECK(!var->IsLookupSlot()); | 2646 DCHECK(!var->IsLookupSlot()); |
2637 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); | 2647 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); |
2638 Label assign; | 2648 Label assign; |
2639 MemOperand location = VarOperand(var, ecx); | 2649 MemOperand location = VarOperand(var, ecx); |
2640 __ mov(edx, location); | 2650 __ mov(edx, location); |
2641 __ cmp(edx, isolate()->factory()->the_hole_value()); | 2651 __ cmp(edx, isolate()->factory()->the_hole_value()); |
2642 __ j(not_equal, &assign, Label::kNear); | 2652 __ j(not_equal, &assign, Label::kNear); |
(...skipping 2694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5337 Assembler::target_address_at(call_target_address, | 5347 Assembler::target_address_at(call_target_address, |
5338 unoptimized_code)); | 5348 unoptimized_code)); |
5339 return OSR_AFTER_STACK_CHECK; | 5349 return OSR_AFTER_STACK_CHECK; |
5340 } | 5350 } |
5341 | 5351 |
5342 | 5352 |
5343 } // namespace internal | 5353 } // namespace internal |
5344 } // namespace v8 | 5354 } // namespace v8 |
5345 | 5355 |
5346 #endif // V8_TARGET_ARCH_IA32 | 5356 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |