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_X87 | 7 #if V8_TARGET_ARCH_X87 |
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 1316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1327 | 1327 |
1328 void FullCodeGenerator::EmitGlobalVariableLoad(VariableProxy* proxy, | 1328 void FullCodeGenerator::EmitGlobalVariableLoad(VariableProxy* proxy, |
1329 TypeofMode typeof_mode) { | 1329 TypeofMode typeof_mode) { |
1330 Variable* var = proxy->var(); | 1330 Variable* var = proxy->var(); |
1331 DCHECK(var->IsUnallocatedOrGlobalSlot() || | 1331 DCHECK(var->IsUnallocatedOrGlobalSlot() || |
1332 (var->IsLookupSlot() && var->mode() == DYNAMIC_GLOBAL)); | 1332 (var->IsLookupSlot() && var->mode() == DYNAMIC_GLOBAL)); |
1333 if (var->IsGlobalSlot()) { | 1333 if (var->IsGlobalSlot()) { |
1334 DCHECK(var->index() > 0); | 1334 DCHECK(var->index() > 0); |
1335 DCHECK(var->IsStaticGlobalObjectProperty()); | 1335 DCHECK(var->IsStaticGlobalObjectProperty()); |
1336 // Each var occupies two slots in the context: for reads and writes. | 1336 // Each var occupies two slots in the context: for reads and writes. |
1337 int slot_index = var->index(); | 1337 int const slot = var->index(); |
1338 int depth = scope()->ContextChainLength(var->scope()); | 1338 int const depth = scope()->ContextChainLength(var->scope()); |
1339 __ mov(LoadGlobalViaContextDescriptor::DepthRegister(), | 1339 if (depth <= LoadGlobalViaContextStub::kMaximumDepth) { |
1340 Immediate(Smi::FromInt(depth))); | 1340 __ Move(LoadGlobalViaContextDescriptor::SlotRegister(), Immediate(slot)); |
1341 __ mov(LoadGlobalViaContextDescriptor::SlotRegister(), | 1341 __ mov(LoadGlobalViaContextDescriptor::NameRegister(), var->name()); |
1342 Immediate(Smi::FromInt(slot_index))); | 1342 LoadGlobalViaContextStub stub(isolate(), depth); |
1343 __ mov(LoadGlobalViaContextDescriptor::NameRegister(), var->name()); | 1343 __ CallStub(&stub); |
1344 LoadGlobalViaContextStub stub(isolate(), depth); | 1344 } else { |
1345 __ CallStub(&stub); | 1345 __ Push(Smi::FromInt(slot)); |
| 1346 __ Push(var->name()); |
| 1347 __ CallRuntime(Runtime::kLoadGlobalViaContext, 2); |
| 1348 } |
1346 | 1349 |
1347 } else { | 1350 } else { |
1348 __ mov(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); | 1351 __ mov(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); |
1349 __ mov(LoadDescriptor::NameRegister(), var->name()); | 1352 __ mov(LoadDescriptor::NameRegister(), var->name()); |
1350 __ mov(LoadDescriptor::SlotRegister(), | 1353 __ mov(LoadDescriptor::SlotRegister(), |
1351 Immediate(SmiFromSlot(proxy->VariableFeedbackSlot()))); | 1354 Immediate(SmiFromSlot(proxy->VariableFeedbackSlot()))); |
1352 CallLoadIC(typeof_mode); | 1355 CallLoadIC(typeof_mode); |
1353 } | 1356 } |
1354 } | 1357 } |
1355 | 1358 |
(...skipping 1248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2604 __ mov(StoreDescriptor::NameRegister(), var->name()); | 2607 __ mov(StoreDescriptor::NameRegister(), var->name()); |
2605 __ mov(StoreDescriptor::ReceiverRegister(), GlobalObjectOperand()); | 2608 __ mov(StoreDescriptor::ReceiverRegister(), GlobalObjectOperand()); |
2606 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot); | 2609 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot); |
2607 CallStoreIC(); | 2610 CallStoreIC(); |
2608 | 2611 |
2609 } else if (var->IsGlobalSlot()) { | 2612 } else if (var->IsGlobalSlot()) { |
2610 // Global var, const, or let. | 2613 // Global var, const, or let. |
2611 DCHECK(var->index() > 0); | 2614 DCHECK(var->index() > 0); |
2612 DCHECK(var->IsStaticGlobalObjectProperty()); | 2615 DCHECK(var->IsStaticGlobalObjectProperty()); |
2613 // Each var occupies two slots in the context: for reads and writes. | 2616 // Each var occupies two slots in the context: for reads and writes. |
2614 int slot_index = var->index() + 1; | 2617 int const slot = var->index() + 1; |
2615 int depth = scope()->ContextChainLength(var->scope()); | 2618 int const depth = scope()->ContextChainLength(var->scope()); |
2616 __ mov(StoreGlobalViaContextDescriptor::DepthRegister(), | 2619 if (depth <= StoreGlobalViaContextStub::kMaximumDepth) { |
2617 Immediate(Smi::FromInt(depth))); | 2620 __ Move(StoreGlobalViaContextDescriptor::SlotRegister(), Immediate(slot)); |
2618 __ mov(StoreGlobalViaContextDescriptor::SlotRegister(), | 2621 __ mov(StoreGlobalViaContextDescriptor::NameRegister(), var->name()); |
2619 Immediate(Smi::FromInt(slot_index))); | 2622 DCHECK(StoreGlobalViaContextDescriptor::ValueRegister().is(eax)); |
2620 __ mov(StoreGlobalViaContextDescriptor::NameRegister(), var->name()); | 2623 StoreGlobalViaContextStub stub(isolate(), depth, language_mode()); |
2621 DCHECK(StoreGlobalViaContextDescriptor::ValueRegister().is(eax)); | 2624 __ CallStub(&stub); |
2622 StoreGlobalViaContextStub stub(isolate(), depth, language_mode()); | 2625 } else { |
2623 __ CallStub(&stub); | 2626 __ Push(Smi::FromInt(slot)); |
| 2627 __ Push(var->name()); |
| 2628 __ Push(eax); |
| 2629 __ CallRuntime(is_strict(language_mode()) |
| 2630 ? Runtime::kStoreGlobalViaContext_Strict |
| 2631 : Runtime::kStoreGlobalViaContext_Sloppy, |
| 2632 3); |
| 2633 } |
2624 | 2634 |
2625 } else if (var->mode() == LET && op != Token::INIT_LET) { | 2635 } else if (var->mode() == LET && op != Token::INIT_LET) { |
2626 // Non-initializing assignment to let variable needs a write barrier. | 2636 // Non-initializing assignment to let variable needs a write barrier. |
2627 DCHECK(!var->IsLookupSlot()); | 2637 DCHECK(!var->IsLookupSlot()); |
2628 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); | 2638 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); |
2629 Label assign; | 2639 Label assign; |
2630 MemOperand location = VarOperand(var, ecx); | 2640 MemOperand location = VarOperand(var, ecx); |
2631 __ mov(edx, location); | 2641 __ mov(edx, location); |
2632 __ cmp(edx, isolate()->factory()->the_hole_value()); | 2642 __ cmp(edx, isolate()->factory()->the_hole_value()); |
2633 __ j(not_equal, &assign, Label::kNear); | 2643 __ j(not_equal, &assign, Label::kNear); |
(...skipping 2694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5328 Assembler::target_address_at(call_target_address, | 5338 Assembler::target_address_at(call_target_address, |
5329 unoptimized_code)); | 5339 unoptimized_code)); |
5330 return OSR_AFTER_STACK_CHECK; | 5340 return OSR_AFTER_STACK_CHECK; |
5331 } | 5341 } |
5332 | 5342 |
5333 | 5343 |
5334 } // namespace internal | 5344 } // namespace internal |
5335 } // namespace v8 | 5345 } // namespace v8 |
5336 | 5346 |
5337 #endif // V8_TARGET_ARCH_X87 | 5347 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |