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 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1403 __ jmp(done); | 1403 __ jmp(done); |
1404 } | 1404 } |
1405 } | 1405 } |
1406 | 1406 |
1407 | 1407 |
1408 void FullCodeGenerator::EmitGlobalVariableLoad(VariableProxy* proxy, | 1408 void FullCodeGenerator::EmitGlobalVariableLoad(VariableProxy* proxy, |
1409 TypeofState typeof_state) { | 1409 TypeofState typeof_state) { |
1410 Variable* var = proxy->var(); | 1410 Variable* var = proxy->var(); |
1411 DCHECK(var->IsUnallocatedOrGlobalSlot() || | 1411 DCHECK(var->IsUnallocatedOrGlobalSlot() || |
1412 (var->IsLookupSlot() && var->mode() == DYNAMIC_GLOBAL)); | 1412 (var->IsLookupSlot() && var->mode() == DYNAMIC_GLOBAL)); |
1413 __ mov(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); | 1413 if (var->IsGlobalSlot()) { |
1414 __ mov(LoadDescriptor::NameRegister(), var->name()); | 1414 DCHECK(var->index() > 0); |
1415 __ mov(LoadDescriptor::SlotRegister(), | 1415 DCHECK(var->IsStaticGlobalObjectProperty()); |
1416 Immediate(SmiFromSlot(proxy->VariableFeedbackSlot()))); | 1416 // Each var occupies two slots in the context: for reads and writes. |
1417 // Inside typeof use a regular load, not a contextual load, to avoid | 1417 int slot_index = var->index(); |
1418 // a reference error. | 1418 int depth = scope()->ContextChainLength(var->scope()); |
1419 CallLoadIC(typeof_state == NOT_INSIDE_TYPEOF ? CONTEXTUAL : NOT_CONTEXTUAL); | 1419 __ mov(LoadGlobalViaContextDescriptor::DepthRegister(), |
| 1420 Immediate(Smi::FromInt(depth))); |
| 1421 __ mov(LoadGlobalViaContextDescriptor::SlotRegister(), |
| 1422 Immediate(Smi::FromInt(slot_index))); |
| 1423 __ mov(LoadGlobalViaContextDescriptor::NameRegister(), var->name()); |
| 1424 LoadGlobalViaContextStub stub(isolate(), depth); |
| 1425 __ CallStub(&stub); |
| 1426 |
| 1427 } else { |
| 1428 __ mov(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); |
| 1429 __ mov(LoadDescriptor::NameRegister(), var->name()); |
| 1430 __ mov(LoadDescriptor::SlotRegister(), |
| 1431 Immediate(SmiFromSlot(proxy->VariableFeedbackSlot()))); |
| 1432 // Inside typeof use a regular load, not a contextual load, to avoid |
| 1433 // a reference error. |
| 1434 CallLoadIC(typeof_state == NOT_INSIDE_TYPEOF ? CONTEXTUAL : NOT_CONTEXTUAL); |
| 1435 } |
1420 } | 1436 } |
1421 | 1437 |
1422 | 1438 |
1423 void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy, | 1439 void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy, |
1424 TypeofState typeof_state) { | 1440 TypeofState typeof_state) { |
1425 SetExpressionPosition(proxy); | 1441 SetExpressionPosition(proxy); |
1426 PrepareForBailoutForId(proxy->BeforeId(), NO_REGISTERS); | 1442 PrepareForBailoutForId(proxy->BeforeId(), NO_REGISTERS); |
1427 Variable* var = proxy->var(); | 1443 Variable* var = proxy->var(); |
1428 | 1444 |
1429 // Three cases: global variables, lookup variables, and all other types of | 1445 // Three cases: global variables, lookup variables, and all other types of |
(...skipping 1211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2641 if (var->IsContextSlot()) { | 2657 if (var->IsContextSlot()) { |
2642 __ mov(edx, eax); | 2658 __ mov(edx, eax); |
2643 int offset = Context::SlotOffset(var->index()); | 2659 int offset = Context::SlotOffset(var->index()); |
2644 __ RecordWriteContextSlot(ecx, offset, edx, ebx, kDontSaveFPRegs); | 2660 __ RecordWriteContextSlot(ecx, offset, edx, ebx, kDontSaveFPRegs); |
2645 } | 2661 } |
2646 } | 2662 } |
2647 | 2663 |
2648 | 2664 |
2649 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, | 2665 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, |
2650 FeedbackVectorICSlot slot) { | 2666 FeedbackVectorICSlot slot) { |
2651 if (var->IsUnallocatedOrGlobalSlot()) { | 2667 if (var->IsUnallocated()) { |
2652 // Global var, const, or let. | 2668 // Global var, const, or let. |
2653 __ mov(StoreDescriptor::NameRegister(), var->name()); | 2669 __ mov(StoreDescriptor::NameRegister(), var->name()); |
2654 __ mov(StoreDescriptor::ReceiverRegister(), GlobalObjectOperand()); | 2670 __ mov(StoreDescriptor::ReceiverRegister(), GlobalObjectOperand()); |
2655 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot); | 2671 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot); |
2656 CallStoreIC(); | 2672 CallStoreIC(); |
2657 | 2673 |
| 2674 } else if (var->IsGlobalSlot()) { |
| 2675 // Global var, const, or let. |
| 2676 DCHECK(var->index() > 0); |
| 2677 DCHECK(var->IsStaticGlobalObjectProperty()); |
| 2678 // Each var occupies two slots in the context: for reads and writes. |
| 2679 int slot_index = var->index() + 1; |
| 2680 int depth = scope()->ContextChainLength(var->scope()); |
| 2681 __ mov(StoreGlobalViaContextDescriptor::DepthRegister(), |
| 2682 Immediate(Smi::FromInt(depth))); |
| 2683 __ mov(StoreGlobalViaContextDescriptor::SlotRegister(), |
| 2684 Immediate(Smi::FromInt(slot_index))); |
| 2685 __ mov(StoreGlobalViaContextDescriptor::NameRegister(), var->name()); |
| 2686 DCHECK(StoreGlobalViaContextDescriptor::ValueRegister().is(eax)); |
| 2687 StoreGlobalViaContextStub stub(isolate(), depth, language_mode()); |
| 2688 __ CallStub(&stub); |
| 2689 |
2658 } else if (var->mode() == LET && op != Token::INIT_LET) { | 2690 } else if (var->mode() == LET && op != Token::INIT_LET) { |
2659 // Non-initializing assignment to let variable needs a write barrier. | 2691 // Non-initializing assignment to let variable needs a write barrier. |
2660 DCHECK(!var->IsLookupSlot()); | 2692 DCHECK(!var->IsLookupSlot()); |
2661 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); | 2693 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); |
2662 Label assign; | 2694 Label assign; |
2663 MemOperand location = VarOperand(var, ecx); | 2695 MemOperand location = VarOperand(var, ecx); |
2664 __ mov(edx, location); | 2696 __ mov(edx, location); |
2665 __ cmp(edx, isolate()->factory()->the_hole_value()); | 2697 __ cmp(edx, isolate()->factory()->the_hole_value()); |
2666 __ j(not_equal, &assign, Label::kNear); | 2698 __ j(not_equal, &assign, Label::kNear); |
2667 __ push(Immediate(var->name())); | 2699 __ push(Immediate(var->name())); |
(...skipping 2783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5451 Assembler::target_address_at(call_target_address, | 5483 Assembler::target_address_at(call_target_address, |
5452 unoptimized_code)); | 5484 unoptimized_code)); |
5453 return OSR_AFTER_STACK_CHECK; | 5485 return OSR_AFTER_STACK_CHECK; |
5454 } | 5486 } |
5455 | 5487 |
5456 | 5488 |
5457 } // namespace internal | 5489 } // namespace internal |
5458 } // namespace v8 | 5490 } // namespace v8 |
5459 | 5491 |
5460 #endif // V8_TARGET_ARCH_X87 | 5492 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |