| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 #if V8_TARGET_ARCH_PPC | 5 #if V8_TARGET_ARCH_PPC |
| 6 | 6 |
| 7 #include "src/ast/compile-time-value.h" | 7 #include "src/ast/compile-time-value.h" |
| 8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
| 9 #include "src/builtins/builtins-constructor.h" | 9 #include "src/builtins/builtins-constructor.h" |
| 10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
| (...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 __ CompareRoot(r4, Heap::kCatchContextMapRootIndex); | 714 __ CompareRoot(r4, Heap::kCatchContextMapRootIndex); |
| 715 __ Check(ne, kDeclarationInCatchContext); | 715 __ Check(ne, kDeclarationInCatchContext); |
| 716 } | 716 } |
| 717 } | 717 } |
| 718 | 718 |
| 719 | 719 |
| 720 void FullCodeGenerator::VisitVariableDeclaration( | 720 void FullCodeGenerator::VisitVariableDeclaration( |
| 721 VariableDeclaration* declaration) { | 721 VariableDeclaration* declaration) { |
| 722 VariableProxy* proxy = declaration->proxy(); | 722 VariableProxy* proxy = declaration->proxy(); |
| 723 Variable* variable = proxy->var(); | 723 Variable* variable = proxy->var(); |
| 724 DCHECK(!variable->binding_needs_init()); | |
| 725 switch (variable->location()) { | 724 switch (variable->location()) { |
| 726 case VariableLocation::UNALLOCATED: { | 725 case VariableLocation::UNALLOCATED: { |
| 726 DCHECK(!variable->binding_needs_init()); |
| 727 globals_->Add(variable->name(), zone()); | 727 globals_->Add(variable->name(), zone()); |
| 728 FeedbackVectorSlot slot = proxy->VariableFeedbackSlot(); | 728 FeedbackVectorSlot slot = proxy->VariableFeedbackSlot(); |
| 729 DCHECK(!slot.IsInvalid()); | 729 DCHECK(!slot.IsInvalid()); |
| 730 globals_->Add(handle(Smi::FromInt(slot.ToInt()), isolate()), zone()); | 730 globals_->Add(handle(Smi::FromInt(slot.ToInt()), isolate()), zone()); |
| 731 globals_->Add(isolate()->factory()->undefined_value(), zone()); | 731 globals_->Add(isolate()->factory()->undefined_value(), zone()); |
| 732 break; | 732 break; |
| 733 } | 733 } |
| 734 case VariableLocation::PARAMETER: | 734 case VariableLocation::PARAMETER: |
| 735 case VariableLocation::LOCAL: | 735 case VariableLocation::LOCAL: |
| 736 if (variable->binding_needs_init()) { |
| 737 Comment cmnt(masm_, "[ VariableDeclaration"); |
| 738 __ LoadRoot(ip, Heap::kTheHoleValueRootIndex); |
| 739 __ StoreP(ip, StackOperand(variable)); |
| 740 } |
| 741 break; |
| 742 |
| 736 case VariableLocation::CONTEXT: | 743 case VariableLocation::CONTEXT: |
| 744 if (variable->binding_needs_init()) { |
| 745 Comment cmnt(masm_, "[ VariableDeclaration"); |
| 746 EmitDebugCheckDeclarationContext(variable); |
| 747 __ LoadRoot(ip, Heap::kTheHoleValueRootIndex); |
| 748 __ StoreP(ip, ContextMemOperand(cp, variable->index()), r0); |
| 749 // No write barrier since the_hole_value is in old space. |
| 750 PrepareForBailoutForId(proxy->id(), BailoutState::NO_REGISTERS); |
| 751 } |
| 737 break; | 752 break; |
| 738 | 753 |
| 739 case VariableLocation::LOOKUP: | 754 case VariableLocation::LOOKUP: |
| 740 case VariableLocation::MODULE: | 755 case VariableLocation::MODULE: |
| 741 UNREACHABLE(); | 756 UNREACHABLE(); |
| 742 } | 757 } |
| 743 } | 758 } |
| 744 | 759 |
| 745 | 760 |
| 746 void FullCodeGenerator::VisitFunctionDeclaration( | 761 void FullCodeGenerator::VisitFunctionDeclaration( |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1094 MemOperand(sp, offset * kPointerSize)); | 1109 MemOperand(sp, offset * kPointerSize)); |
| 1095 CallStoreIC(slot, isolate()->factory()->home_object_symbol()); | 1110 CallStoreIC(slot, isolate()->factory()->home_object_symbol()); |
| 1096 } | 1111 } |
| 1097 | 1112 |
| 1098 void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy, | 1113 void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy, |
| 1099 TypeofMode typeof_mode) { | 1114 TypeofMode typeof_mode) { |
| 1100 // Record position before possible IC call. | 1115 // Record position before possible IC call. |
| 1101 SetExpressionPosition(proxy); | 1116 SetExpressionPosition(proxy); |
| 1102 PrepareForBailoutForId(proxy->BeforeId(), BailoutState::NO_REGISTERS); | 1117 PrepareForBailoutForId(proxy->BeforeId(), BailoutState::NO_REGISTERS); |
| 1103 Variable* var = proxy->var(); | 1118 Variable* var = proxy->var(); |
| 1104 DCHECK(!var->binding_needs_init()); | |
| 1105 | 1119 |
| 1106 // Two cases: global variables and all other types of variables. | 1120 // Two cases: global variables and all other types of variables. |
| 1107 switch (var->location()) { | 1121 switch (var->location()) { |
| 1108 case VariableLocation::UNALLOCATED: { | 1122 case VariableLocation::UNALLOCATED: { |
| 1109 Comment cmnt(masm_, "[ Global variable"); | 1123 Comment cmnt(masm_, "[ Global variable"); |
| 1110 EmitGlobalVariableLoad(proxy, typeof_mode); | 1124 EmitGlobalVariableLoad(proxy, typeof_mode); |
| 1111 context()->Plug(r3); | 1125 context()->Plug(r3); |
| 1112 break; | 1126 break; |
| 1113 } | 1127 } |
| 1114 | 1128 |
| 1115 case VariableLocation::PARAMETER: | 1129 case VariableLocation::PARAMETER: |
| 1116 case VariableLocation::LOCAL: | 1130 case VariableLocation::LOCAL: |
| 1117 case VariableLocation::CONTEXT: { | 1131 case VariableLocation::CONTEXT: { |
| 1118 DCHECK_EQ(NOT_INSIDE_TYPEOF, typeof_mode); | 1132 DCHECK_EQ(NOT_INSIDE_TYPEOF, typeof_mode); |
| 1119 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context variable" | 1133 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context variable" |
| 1120 : "[ Stack variable"); | 1134 : "[ Stack variable"); |
| 1135 if (proxy->hole_check_mode() == HoleCheckMode::kRequired) { |
| 1136 // Throw a reference error when using an uninitialized let/const |
| 1137 // binding in harmony mode. |
| 1138 Label done; |
| 1139 GetVar(r3, var); |
| 1140 __ CompareRoot(r3, Heap::kTheHoleValueRootIndex); |
| 1141 __ bne(&done); |
| 1142 __ mov(r3, Operand(var->name())); |
| 1143 __ push(r3); |
| 1144 __ CallRuntime(Runtime::kThrowReferenceError); |
| 1145 __ bind(&done); |
| 1146 context()->Plug(r3); |
| 1147 break; |
| 1148 } |
| 1121 context()->Plug(var); | 1149 context()->Plug(var); |
| 1122 break; | 1150 break; |
| 1123 } | 1151 } |
| 1124 | 1152 |
| 1125 case VariableLocation::LOOKUP: | 1153 case VariableLocation::LOOKUP: |
| 1126 case VariableLocation::MODULE: | 1154 case VariableLocation::MODULE: |
| 1127 UNREACHABLE(); | 1155 UNREACHABLE(); |
| 1128 } | 1156 } |
| 1129 } | 1157 } |
| 1130 | 1158 |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1426 } else { | 1454 } else { |
| 1427 VisitForAccumulatorValue(expr->value()); | 1455 VisitForAccumulatorValue(expr->value()); |
| 1428 } | 1456 } |
| 1429 | 1457 |
| 1430 SetExpressionPosition(expr); | 1458 SetExpressionPosition(expr); |
| 1431 | 1459 |
| 1432 // Store the value. | 1460 // Store the value. |
| 1433 switch (assign_type) { | 1461 switch (assign_type) { |
| 1434 case VARIABLE: { | 1462 case VARIABLE: { |
| 1435 VariableProxy* proxy = expr->target()->AsVariableProxy(); | 1463 VariableProxy* proxy = expr->target()->AsVariableProxy(); |
| 1436 EmitVariableAssignment(proxy->var(), expr->op(), expr->AssignmentSlot()); | 1464 EmitVariableAssignment(proxy->var(), expr->op(), expr->AssignmentSlot(), |
| 1465 proxy->hole_check_mode()); |
| 1437 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); | 1466 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); |
| 1438 context()->Plug(r3); | 1467 context()->Plug(r3); |
| 1439 break; | 1468 break; |
| 1440 } | 1469 } |
| 1441 case NAMED_PROPERTY: | 1470 case NAMED_PROPERTY: |
| 1442 EmitNamedPropertyAssignment(expr); | 1471 EmitNamedPropertyAssignment(expr); |
| 1443 break; | 1472 break; |
| 1444 case KEYED_PROPERTY: | 1473 case KEYED_PROPERTY: |
| 1445 EmitKeyedPropertyAssignment(expr); | 1474 EmitKeyedPropertyAssignment(expr); |
| 1446 break; | 1475 break; |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1653 FeedbackVectorSlot slot) { | 1682 FeedbackVectorSlot slot) { |
| 1654 DCHECK(expr->IsValidReferenceExpressionOrThis()); | 1683 DCHECK(expr->IsValidReferenceExpressionOrThis()); |
| 1655 | 1684 |
| 1656 Property* prop = expr->AsProperty(); | 1685 Property* prop = expr->AsProperty(); |
| 1657 LhsKind assign_type = Property::GetAssignType(prop); | 1686 LhsKind assign_type = Property::GetAssignType(prop); |
| 1658 | 1687 |
| 1659 switch (assign_type) { | 1688 switch (assign_type) { |
| 1660 case VARIABLE: { | 1689 case VARIABLE: { |
| 1661 VariableProxy* proxy = expr->AsVariableProxy(); | 1690 VariableProxy* proxy = expr->AsVariableProxy(); |
| 1662 EffectContext context(this); | 1691 EffectContext context(this); |
| 1663 EmitVariableAssignment(proxy->var(), Token::ASSIGN, slot); | 1692 EmitVariableAssignment(proxy->var(), Token::ASSIGN, slot, |
| 1693 proxy->hole_check_mode()); |
| 1664 break; | 1694 break; |
| 1665 } | 1695 } |
| 1666 case NAMED_PROPERTY: { | 1696 case NAMED_PROPERTY: { |
| 1667 PushOperand(r3); // Preserve value. | 1697 PushOperand(r3); // Preserve value. |
| 1668 VisitForAccumulatorValue(prop->obj()); | 1698 VisitForAccumulatorValue(prop->obj()); |
| 1669 __ Move(StoreDescriptor::ReceiverRegister(), r3); | 1699 __ Move(StoreDescriptor::ReceiverRegister(), r3); |
| 1670 PopOperand(StoreDescriptor::ValueRegister()); // Restore value. | 1700 PopOperand(StoreDescriptor::ValueRegister()); // Restore value. |
| 1671 CallStoreIC(slot, prop->key()->AsLiteral()->value()); | 1701 CallStoreIC(slot, prop->key()->AsLiteral()->value()); |
| 1672 break; | 1702 break; |
| 1673 } | 1703 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1696 if (var->IsContextSlot()) { | 1726 if (var->IsContextSlot()) { |
| 1697 // RecordWrite may destroy all its register arguments. | 1727 // RecordWrite may destroy all its register arguments. |
| 1698 __ mr(r6, result_register()); | 1728 __ mr(r6, result_register()); |
| 1699 int offset = Context::SlotOffset(var->index()); | 1729 int offset = Context::SlotOffset(var->index()); |
| 1700 __ RecordWriteContextSlot(r4, offset, r6, r5, kLRHasBeenSaved, | 1730 __ RecordWriteContextSlot(r4, offset, r6, r5, kLRHasBeenSaved, |
| 1701 kDontSaveFPRegs); | 1731 kDontSaveFPRegs); |
| 1702 } | 1732 } |
| 1703 } | 1733 } |
| 1704 | 1734 |
| 1705 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, | 1735 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, |
| 1706 FeedbackVectorSlot slot) { | 1736 FeedbackVectorSlot slot, |
| 1707 DCHECK(!var->binding_needs_init()); | 1737 HoleCheckMode hole_check_mode) { |
| 1708 if (var->IsUnallocated()) { | 1738 if (var->IsUnallocated()) { |
| 1709 // Global var, const, or let. | 1739 // Global var, const, or let. |
| 1710 __ LoadGlobalObject(StoreDescriptor::ReceiverRegister()); | 1740 __ LoadGlobalObject(StoreDescriptor::ReceiverRegister()); |
| 1711 CallStoreIC(slot, var->name()); | 1741 CallStoreIC(slot, var->name()); |
| 1712 | 1742 |
| 1713 } else if (var->mode() == CONST && op != Token::INIT) { | 1743 } else if (IsLexicalVariableMode(var->mode()) && op != Token::INIT) { |
| 1714 if (var->throw_on_const_assignment(language_mode())) { | 1744 DCHECK(!var->IsLookupSlot()); |
| 1745 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); |
| 1746 MemOperand location = VarOperand(var, r4); |
| 1747 // Perform an initialization check for lexically declared variables. |
| 1748 if (hole_check_mode == HoleCheckMode::kRequired) { |
| 1749 Label assign; |
| 1750 __ LoadP(r6, location); |
| 1751 __ CompareRoot(r6, Heap::kTheHoleValueRootIndex); |
| 1752 __ bne(&assign); |
| 1753 __ mov(r6, Operand(var->name())); |
| 1754 __ push(r6); |
| 1755 __ CallRuntime(Runtime::kThrowReferenceError); |
| 1756 __ bind(&assign); |
| 1757 } |
| 1758 if (var->mode() != CONST) { |
| 1759 EmitStoreToStackLocalOrContextSlot(var, location); |
| 1760 } else if (var->throw_on_const_assignment(language_mode())) { |
| 1715 __ CallRuntime(Runtime::kThrowConstAssignError); | 1761 __ CallRuntime(Runtime::kThrowConstAssignError); |
| 1716 } | 1762 } |
| 1763 } else if (var->is_this() && var->mode() == CONST && op == Token::INIT) { |
| 1764 // Initializing assignment to const {this} needs a write barrier. |
| 1765 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); |
| 1766 Label uninitialized_this; |
| 1767 MemOperand location = VarOperand(var, r4); |
| 1768 __ LoadP(r6, location); |
| 1769 __ CompareRoot(r6, Heap::kTheHoleValueRootIndex); |
| 1770 __ beq(&uninitialized_this); |
| 1771 __ mov(r4, Operand(var->name())); |
| 1772 __ push(r4); |
| 1773 __ CallRuntime(Runtime::kThrowReferenceError); |
| 1774 __ bind(&uninitialized_this); |
| 1775 EmitStoreToStackLocalOrContextSlot(var, location); |
| 1776 |
| 1717 } else { | 1777 } else { |
| 1718 DCHECK(!var->is_this()); | 1778 DCHECK(var->mode() != CONST || op == Token::INIT); |
| 1719 DCHECK((var->IsStackAllocated() || var->IsContextSlot())); | 1779 DCHECK((var->IsStackAllocated() || var->IsContextSlot())); |
| 1720 DCHECK(!var->IsLookupSlot()); | 1780 DCHECK(!var->IsLookupSlot()); |
| 1781 // Assignment to var or initializing assignment to let/const in harmony |
| 1782 // mode. |
| 1721 MemOperand location = VarOperand(var, r4); | 1783 MemOperand location = VarOperand(var, r4); |
| 1784 if (FLAG_debug_code && var->mode() == LET && op == Token::INIT) { |
| 1785 // Check for an uninitialized let binding. |
| 1786 __ LoadP(r5, location); |
| 1787 __ CompareRoot(r5, Heap::kTheHoleValueRootIndex); |
| 1788 __ Check(eq, kLetBindingReInitialization); |
| 1789 } |
| 1722 EmitStoreToStackLocalOrContextSlot(var, location); | 1790 EmitStoreToStackLocalOrContextSlot(var, location); |
| 1723 } | 1791 } |
| 1724 } | 1792 } |
| 1725 | 1793 |
| 1726 | 1794 |
| 1727 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { | 1795 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { |
| 1728 // Assignment to a property, using a named store IC. | 1796 // Assignment to a property, using a named store IC. |
| 1729 Property* prop = expr->target()->AsProperty(); | 1797 Property* prop = expr->target()->AsProperty(); |
| 1730 DCHECK(prop != NULL); | 1798 DCHECK(prop != NULL); |
| 1731 DCHECK(prop->key()->IsLiteral()); | 1799 DCHECK(prop->key()->IsLiteral()); |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2420 patch_site.EmitPatchInfo(); | 2488 patch_site.EmitPatchInfo(); |
| 2421 __ bind(&done); | 2489 __ bind(&done); |
| 2422 | 2490 |
| 2423 // Store the value returned in r3. | 2491 // Store the value returned in r3. |
| 2424 switch (assign_type) { | 2492 switch (assign_type) { |
| 2425 case VARIABLE: { | 2493 case VARIABLE: { |
| 2426 VariableProxy* proxy = expr->expression()->AsVariableProxy(); | 2494 VariableProxy* proxy = expr->expression()->AsVariableProxy(); |
| 2427 if (expr->is_postfix()) { | 2495 if (expr->is_postfix()) { |
| 2428 { | 2496 { |
| 2429 EffectContext context(this); | 2497 EffectContext context(this); |
| 2430 EmitVariableAssignment(proxy->var(), Token::ASSIGN, | 2498 EmitVariableAssignment(proxy->var(), Token::ASSIGN, expr->CountSlot(), |
| 2431 expr->CountSlot()); | 2499 proxy->hole_check_mode()); |
| 2432 PrepareForBailoutForId(expr->AssignmentId(), | 2500 PrepareForBailoutForId(expr->AssignmentId(), |
| 2433 BailoutState::TOS_REGISTER); | 2501 BailoutState::TOS_REGISTER); |
| 2434 context.Plug(r3); | 2502 context.Plug(r3); |
| 2435 } | 2503 } |
| 2436 // For all contexts except EffectConstant We have the result on | 2504 // For all contexts except EffectConstant We have the result on |
| 2437 // top of the stack. | 2505 // top of the stack. |
| 2438 if (!context()->IsEffect()) { | 2506 if (!context()->IsEffect()) { |
| 2439 context()->PlugTOS(); | 2507 context()->PlugTOS(); |
| 2440 } | 2508 } |
| 2441 } else { | 2509 } else { |
| 2442 EmitVariableAssignment(proxy->var(), Token::ASSIGN, expr->CountSlot()); | 2510 EmitVariableAssignment(proxy->var(), Token::ASSIGN, expr->CountSlot(), |
| 2511 proxy->hole_check_mode()); |
| 2443 PrepareForBailoutForId(expr->AssignmentId(), | 2512 PrepareForBailoutForId(expr->AssignmentId(), |
| 2444 BailoutState::TOS_REGISTER); | 2513 BailoutState::TOS_REGISTER); |
| 2445 context()->Plug(r3); | 2514 context()->Plug(r3); |
| 2446 } | 2515 } |
| 2447 break; | 2516 break; |
| 2448 } | 2517 } |
| 2449 case NAMED_PROPERTY: { | 2518 case NAMED_PROPERTY: { |
| 2450 PopOperand(StoreDescriptor::ReceiverRegister()); | 2519 PopOperand(StoreDescriptor::ReceiverRegister()); |
| 2451 CallStoreIC(expr->CountSlot(), prop->key()->AsLiteral()->value()); | 2520 CallStoreIC(expr->CountSlot(), prop->key()->AsLiteral()->value()); |
| 2452 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); | 2521 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2772 | 2841 |
| 2773 DCHECK(Assembler::IsCrSet(Assembler::instr_at(cmp_address))); | 2842 DCHECK(Assembler::IsCrSet(Assembler::instr_at(cmp_address))); |
| 2774 | 2843 |
| 2775 DCHECK(interrupt_address == | 2844 DCHECK(interrupt_address == |
| 2776 isolate->builtins()->OnStackReplacement()->entry()); | 2845 isolate->builtins()->OnStackReplacement()->entry()); |
| 2777 return ON_STACK_REPLACEMENT; | 2846 return ON_STACK_REPLACEMENT; |
| 2778 } | 2847 } |
| 2779 } // namespace internal | 2848 } // namespace internal |
| 2780 } // namespace v8 | 2849 } // namespace v8 |
| 2781 #endif // V8_TARGET_ARCH_PPC | 2850 #endif // V8_TARGET_ARCH_PPC |
| OLD | NEW |