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 1399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1410 __ jmp(done); | 1410 __ jmp(done); |
1411 } | 1411 } |
1412 } | 1412 } |
1413 | 1413 |
1414 | 1414 |
1415 void FullCodeGenerator::EmitGlobalVariableLoad(VariableProxy* proxy, | 1415 void FullCodeGenerator::EmitGlobalVariableLoad(VariableProxy* proxy, |
1416 TypeofState typeof_state) { | 1416 TypeofState typeof_state) { |
1417 Variable* var = proxy->var(); | 1417 Variable* var = proxy->var(); |
1418 DCHECK(var->IsUnallocatedOrGlobalSlot() || | 1418 DCHECK(var->IsUnallocatedOrGlobalSlot() || |
1419 (var->IsLookupSlot() && var->mode() == DYNAMIC_GLOBAL)); | 1419 (var->IsLookupSlot() && var->mode() == DYNAMIC_GLOBAL)); |
1420 __ mov(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); | 1420 if (var->IsGlobalSlot()) { |
1421 __ mov(LoadDescriptor::NameRegister(), var->name()); | 1421 DCHECK(var->index() > 0); |
1422 __ mov(LoadDescriptor::SlotRegister(), | 1422 DCHECK(var->IsStaticGlobalObjectProperty()); |
1423 Immediate(SmiFromSlot(proxy->VariableFeedbackSlot()))); | 1423 // Each var occupies two slots in the context: for reads and writes. |
1424 // Inside typeof use a regular load, not a contextual load, to avoid | 1424 int slot_index = var->index(); |
1425 // a reference error. | 1425 int depth = scope()->ContextChainLength(var->scope()); |
1426 CallLoadIC(typeof_state == NOT_INSIDE_TYPEOF ? CONTEXTUAL : NOT_CONTEXTUAL); | 1426 __ mov(LoadGlobalViaContextDescriptor::DepthRegister(), |
| 1427 Immediate(Smi::FromInt(depth))); |
| 1428 __ mov(LoadGlobalViaContextDescriptor::SlotRegister(), |
| 1429 Immediate(Smi::FromInt(slot_index))); |
| 1430 __ mov(LoadGlobalViaContextDescriptor::NameRegister(), var->name()); |
| 1431 LoadGlobalViaContextStub stub(isolate(), depth); |
| 1432 __ CallStub(&stub); |
| 1433 |
| 1434 } else { |
| 1435 __ mov(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); |
| 1436 __ mov(LoadDescriptor::NameRegister(), var->name()); |
| 1437 __ mov(LoadDescriptor::SlotRegister(), |
| 1438 Immediate(SmiFromSlot(proxy->VariableFeedbackSlot()))); |
| 1439 // Inside typeof use a regular load, not a contextual load, to avoid |
| 1440 // a reference error. |
| 1441 CallLoadIC(typeof_state == NOT_INSIDE_TYPEOF ? CONTEXTUAL : NOT_CONTEXTUAL); |
| 1442 } |
1427 } | 1443 } |
1428 | 1444 |
1429 | 1445 |
1430 void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy, | 1446 void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy, |
1431 TypeofState typeof_state) { | 1447 TypeofState typeof_state) { |
1432 SetExpressionPosition(proxy); | 1448 SetExpressionPosition(proxy); |
1433 PrepareForBailoutForId(proxy->BeforeId(), NO_REGISTERS); | 1449 PrepareForBailoutForId(proxy->BeforeId(), NO_REGISTERS); |
1434 Variable* var = proxy->var(); | 1450 Variable* var = proxy->var(); |
1435 | 1451 |
1436 // Three cases: global variables, lookup variables, and all other types of | 1452 // Three cases: global variables, lookup variables, and all other types of |
(...skipping 1213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2650 if (var->IsContextSlot()) { | 2666 if (var->IsContextSlot()) { |
2651 __ mov(edx, eax); | 2667 __ mov(edx, eax); |
2652 int offset = Context::SlotOffset(var->index()); | 2668 int offset = Context::SlotOffset(var->index()); |
2653 __ RecordWriteContextSlot(ecx, offset, edx, ebx, kDontSaveFPRegs); | 2669 __ RecordWriteContextSlot(ecx, offset, edx, ebx, kDontSaveFPRegs); |
2654 } | 2670 } |
2655 } | 2671 } |
2656 | 2672 |
2657 | 2673 |
2658 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, | 2674 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, |
2659 FeedbackVectorICSlot slot) { | 2675 FeedbackVectorICSlot slot) { |
2660 if (var->IsUnallocatedOrGlobalSlot()) { | 2676 if (var->IsUnallocated()) { |
2661 // Global var, const, or let. | 2677 // Global var, const, or let. |
2662 __ mov(StoreDescriptor::NameRegister(), var->name()); | 2678 __ mov(StoreDescriptor::NameRegister(), var->name()); |
2663 __ mov(StoreDescriptor::ReceiverRegister(), GlobalObjectOperand()); | 2679 __ mov(StoreDescriptor::ReceiverRegister(), GlobalObjectOperand()); |
2664 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot); | 2680 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot); |
2665 CallStoreIC(); | 2681 CallStoreIC(); |
2666 | 2682 |
| 2683 } else if (var->IsGlobalSlot()) { |
| 2684 // Global var, const, or let. |
| 2685 DCHECK(var->index() > 0); |
| 2686 DCHECK(var->IsStaticGlobalObjectProperty()); |
| 2687 // Each var occupies two slots in the context: for reads and writes. |
| 2688 int slot_index = var->index() + 1; |
| 2689 int depth = scope()->ContextChainLength(var->scope()); |
| 2690 __ mov(StoreGlobalViaContextDescriptor::DepthRegister(), |
| 2691 Immediate(Smi::FromInt(depth))); |
| 2692 __ mov(StoreGlobalViaContextDescriptor::SlotRegister(), |
| 2693 Immediate(Smi::FromInt(slot_index))); |
| 2694 __ mov(StoreGlobalViaContextDescriptor::NameRegister(), var->name()); |
| 2695 DCHECK(StoreGlobalViaContextDescriptor::ValueRegister().is(eax)); |
| 2696 StoreGlobalViaContextStub stub(isolate(), depth, language_mode()); |
| 2697 __ CallStub(&stub); |
| 2698 |
2667 } else if (var->mode() == LET && op != Token::INIT_LET) { | 2699 } else if (var->mode() == LET && op != Token::INIT_LET) { |
2668 // Non-initializing assignment to let variable needs a write barrier. | 2700 // Non-initializing assignment to let variable needs a write barrier. |
2669 DCHECK(!var->IsLookupSlot()); | 2701 DCHECK(!var->IsLookupSlot()); |
2670 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); | 2702 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); |
2671 Label assign; | 2703 Label assign; |
2672 MemOperand location = VarOperand(var, ecx); | 2704 MemOperand location = VarOperand(var, ecx); |
2673 __ mov(edx, location); | 2705 __ mov(edx, location); |
2674 __ cmp(edx, isolate()->factory()->the_hole_value()); | 2706 __ cmp(edx, isolate()->factory()->the_hole_value()); |
2675 __ j(not_equal, &assign, Label::kNear); | 2707 __ j(not_equal, &assign, Label::kNear); |
2676 __ push(Immediate(var->name())); | 2708 __ push(Immediate(var->name())); |
(...skipping 2784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5461 Assembler::target_address_at(call_target_address, | 5493 Assembler::target_address_at(call_target_address, |
5462 unoptimized_code)); | 5494 unoptimized_code)); |
5463 return OSR_AFTER_STACK_CHECK; | 5495 return OSR_AFTER_STACK_CHECK; |
5464 } | 5496 } |
5465 | 5497 |
5466 | 5498 |
5467 } // namespace internal | 5499 } // namespace internal |
5468 } // namespace v8 | 5500 } // namespace v8 |
5469 | 5501 |
5470 #endif // V8_TARGET_ARCH_IA32 | 5502 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |