| 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 #if V8_TARGET_ARCH_MIPS64 | 5 #if V8_TARGET_ARCH_MIPS64 |
| 6 | 6 |
| 7 // Note on Mips implementation: | 7 // Note on Mips implementation: |
| 8 // | 8 // |
| 9 // The result_register() for mips is the 'v0' register, which is defined | 9 // The result_register() for mips is the 'v0' register, which is defined |
| 10 // by the ABI to contain function return values. However, the first | 10 // by the ABI to contain function return values. However, the first |
| (...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 747 __ Check(ne, kDeclarationInCatchContext, | 747 __ Check(ne, kDeclarationInCatchContext, |
| 748 a1, Operand(a4)); | 748 a1, Operand(a4)); |
| 749 } | 749 } |
| 750 } | 750 } |
| 751 | 751 |
| 752 | 752 |
| 753 void FullCodeGenerator::VisitVariableDeclaration( | 753 void FullCodeGenerator::VisitVariableDeclaration( |
| 754 VariableDeclaration* declaration) { | 754 VariableDeclaration* declaration) { |
| 755 VariableProxy* proxy = declaration->proxy(); | 755 VariableProxy* proxy = declaration->proxy(); |
| 756 Variable* variable = proxy->var(); | 756 Variable* variable = proxy->var(); |
| 757 DCHECK(!variable->binding_needs_init()); |
| 757 switch (variable->location()) { | 758 switch (variable->location()) { |
| 758 case VariableLocation::UNALLOCATED: { | 759 case VariableLocation::UNALLOCATED: { |
| 759 DCHECK(!variable->binding_needs_init()); | |
| 760 globals_->Add(variable->name(), zone()); | 760 globals_->Add(variable->name(), zone()); |
| 761 FeedbackVectorSlot slot = proxy->VariableFeedbackSlot(); | 761 FeedbackVectorSlot slot = proxy->VariableFeedbackSlot(); |
| 762 DCHECK(!slot.IsInvalid()); | 762 DCHECK(!slot.IsInvalid()); |
| 763 globals_->Add(handle(Smi::FromInt(slot.ToInt()), isolate()), zone()); | 763 globals_->Add(handle(Smi::FromInt(slot.ToInt()), isolate()), zone()); |
| 764 globals_->Add(isolate()->factory()->undefined_value(), zone()); | 764 globals_->Add(isolate()->factory()->undefined_value(), zone()); |
| 765 break; | 765 break; |
| 766 } | 766 } |
| 767 case VariableLocation::PARAMETER: | 767 case VariableLocation::PARAMETER: |
| 768 case VariableLocation::LOCAL: | 768 case VariableLocation::LOCAL: |
| 769 if (variable->binding_needs_init()) { | |
| 770 Comment cmnt(masm_, "[ VariableDeclaration"); | |
| 771 __ LoadRoot(a4, Heap::kTheHoleValueRootIndex); | |
| 772 __ sd(a4, StackOperand(variable)); | |
| 773 } | |
| 774 break; | |
| 775 | |
| 776 case VariableLocation::CONTEXT: | 769 case VariableLocation::CONTEXT: |
| 777 if (variable->binding_needs_init()) { | |
| 778 Comment cmnt(masm_, "[ VariableDeclaration"); | |
| 779 EmitDebugCheckDeclarationContext(variable); | |
| 780 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); | |
| 781 __ sd(at, ContextMemOperand(cp, variable->index())); | |
| 782 // No write barrier since the_hole_value is in old space. | |
| 783 PrepareForBailoutForId(proxy->id(), BailoutState::NO_REGISTERS); | |
| 784 } | |
| 785 break; | 770 break; |
| 786 | 771 |
| 787 case VariableLocation::LOOKUP: | 772 case VariableLocation::LOOKUP: |
| 788 case VariableLocation::MODULE: | 773 case VariableLocation::MODULE: |
| 789 UNREACHABLE(); | 774 UNREACHABLE(); |
| 790 } | 775 } |
| 791 } | 776 } |
| 792 | 777 |
| 793 | 778 |
| 794 void FullCodeGenerator::VisitFunctionDeclaration( | 779 void FullCodeGenerator::VisitFunctionDeclaration( |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1141 MemOperand(sp, offset * kPointerSize)); | 1126 MemOperand(sp, offset * kPointerSize)); |
| 1142 CallStoreIC(slot, isolate()->factory()->home_object_symbol()); | 1127 CallStoreIC(slot, isolate()->factory()->home_object_symbol()); |
| 1143 } | 1128 } |
| 1144 | 1129 |
| 1145 void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy, | 1130 void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy, |
| 1146 TypeofMode typeof_mode) { | 1131 TypeofMode typeof_mode) { |
| 1147 // Record position before possible IC call. | 1132 // Record position before possible IC call. |
| 1148 SetExpressionPosition(proxy); | 1133 SetExpressionPosition(proxy); |
| 1149 PrepareForBailoutForId(proxy->BeforeId(), BailoutState::NO_REGISTERS); | 1134 PrepareForBailoutForId(proxy->BeforeId(), BailoutState::NO_REGISTERS); |
| 1150 Variable* var = proxy->var(); | 1135 Variable* var = proxy->var(); |
| 1136 DCHECK(!var->binding_needs_init()); |
| 1151 | 1137 |
| 1152 // Two cases: global variables and all other types of variables. | 1138 // Two cases: global variables and all other types of variables. |
| 1153 switch (var->location()) { | 1139 switch (var->location()) { |
| 1154 case VariableLocation::UNALLOCATED: { | 1140 case VariableLocation::UNALLOCATED: { |
| 1155 Comment cmnt(masm_, "[ Global variable"); | 1141 Comment cmnt(masm_, "[ Global variable"); |
| 1156 EmitGlobalVariableLoad(proxy, typeof_mode); | 1142 EmitGlobalVariableLoad(proxy, typeof_mode); |
| 1157 context()->Plug(v0); | 1143 context()->Plug(v0); |
| 1158 break; | 1144 break; |
| 1159 } | 1145 } |
| 1160 | 1146 |
| 1161 case VariableLocation::PARAMETER: | 1147 case VariableLocation::PARAMETER: |
| 1162 case VariableLocation::LOCAL: | 1148 case VariableLocation::LOCAL: |
| 1163 case VariableLocation::CONTEXT: { | 1149 case VariableLocation::CONTEXT: { |
| 1164 DCHECK_EQ(NOT_INSIDE_TYPEOF, typeof_mode); | 1150 DCHECK_EQ(NOT_INSIDE_TYPEOF, typeof_mode); |
| 1165 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context variable" | 1151 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context variable" |
| 1166 : "[ Stack variable"); | 1152 : "[ Stack variable"); |
| 1167 if (proxy->hole_check_mode() == HoleCheckMode::kRequired) { | |
| 1168 // Throw a reference error when using an uninitialized let/const | |
| 1169 // binding in harmony mode. | |
| 1170 Label done; | |
| 1171 GetVar(v0, var); | |
| 1172 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); | |
| 1173 __ dsubu(at, v0, at); // Sub as compare: at == 0 on eq. | |
| 1174 __ Branch(&done, ne, at, Operand(zero_reg)); | |
| 1175 __ li(a0, Operand(var->name())); | |
| 1176 __ push(a0); | |
| 1177 __ CallRuntime(Runtime::kThrowReferenceError); | |
| 1178 __ bind(&done); | |
| 1179 context()->Plug(v0); | |
| 1180 break; | |
| 1181 } | |
| 1182 context()->Plug(var); | 1153 context()->Plug(var); |
| 1183 break; | 1154 break; |
| 1184 } | 1155 } |
| 1185 | 1156 |
| 1186 case VariableLocation::LOOKUP: | 1157 case VariableLocation::LOOKUP: |
| 1187 case VariableLocation::MODULE: | 1158 case VariableLocation::MODULE: |
| 1188 UNREACHABLE(); | 1159 UNREACHABLE(); |
| 1189 } | 1160 } |
| 1190 } | 1161 } |
| 1191 | 1162 |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1490 } else { | 1461 } else { |
| 1491 VisitForAccumulatorValue(expr->value()); | 1462 VisitForAccumulatorValue(expr->value()); |
| 1492 } | 1463 } |
| 1493 | 1464 |
| 1494 SetExpressionPosition(expr); | 1465 SetExpressionPosition(expr); |
| 1495 | 1466 |
| 1496 // Store the value. | 1467 // Store the value. |
| 1497 switch (assign_type) { | 1468 switch (assign_type) { |
| 1498 case VARIABLE: { | 1469 case VARIABLE: { |
| 1499 VariableProxy* proxy = expr->target()->AsVariableProxy(); | 1470 VariableProxy* proxy = expr->target()->AsVariableProxy(); |
| 1500 EmitVariableAssignment(proxy->var(), expr->op(), expr->AssignmentSlot(), | 1471 EmitVariableAssignment(proxy->var(), expr->op(), expr->AssignmentSlot()); |
| 1501 proxy->hole_check_mode()); | |
| 1502 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); | 1472 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); |
| 1503 context()->Plug(v0); | 1473 context()->Plug(v0); |
| 1504 break; | 1474 break; |
| 1505 } | 1475 } |
| 1506 case NAMED_PROPERTY: | 1476 case NAMED_PROPERTY: |
| 1507 EmitNamedPropertyAssignment(expr); | 1477 EmitNamedPropertyAssignment(expr); |
| 1508 break; | 1478 break; |
| 1509 case KEYED_PROPERTY: | 1479 case KEYED_PROPERTY: |
| 1510 EmitKeyedPropertyAssignment(expr); | 1480 EmitKeyedPropertyAssignment(expr); |
| 1511 break; | 1481 break; |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1682 FeedbackVectorSlot slot) { | 1652 FeedbackVectorSlot slot) { |
| 1683 DCHECK(expr->IsValidReferenceExpressionOrThis()); | 1653 DCHECK(expr->IsValidReferenceExpressionOrThis()); |
| 1684 | 1654 |
| 1685 Property* prop = expr->AsProperty(); | 1655 Property* prop = expr->AsProperty(); |
| 1686 LhsKind assign_type = Property::GetAssignType(prop); | 1656 LhsKind assign_type = Property::GetAssignType(prop); |
| 1687 | 1657 |
| 1688 switch (assign_type) { | 1658 switch (assign_type) { |
| 1689 case VARIABLE: { | 1659 case VARIABLE: { |
| 1690 VariableProxy* proxy = expr->AsVariableProxy(); | 1660 VariableProxy* proxy = expr->AsVariableProxy(); |
| 1691 EffectContext context(this); | 1661 EffectContext context(this); |
| 1692 EmitVariableAssignment(proxy->var(), Token::ASSIGN, slot, | 1662 EmitVariableAssignment(proxy->var(), Token::ASSIGN, slot); |
| 1693 proxy->hole_check_mode()); | |
| 1694 break; | 1663 break; |
| 1695 } | 1664 } |
| 1696 case NAMED_PROPERTY: { | 1665 case NAMED_PROPERTY: { |
| 1697 PushOperand(result_register()); // Preserve value. | 1666 PushOperand(result_register()); // Preserve value. |
| 1698 VisitForAccumulatorValue(prop->obj()); | 1667 VisitForAccumulatorValue(prop->obj()); |
| 1699 __ mov(StoreDescriptor::ReceiverRegister(), result_register()); | 1668 __ mov(StoreDescriptor::ReceiverRegister(), result_register()); |
| 1700 PopOperand(StoreDescriptor::ValueRegister()); // Restore value. | 1669 PopOperand(StoreDescriptor::ValueRegister()); // Restore value. |
| 1701 CallStoreIC(slot, prop->key()->AsLiteral()->value()); | 1670 CallStoreIC(slot, prop->key()->AsLiteral()->value()); |
| 1702 break; | 1671 break; |
| 1703 } | 1672 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1726 if (var->IsContextSlot()) { | 1695 if (var->IsContextSlot()) { |
| 1727 // RecordWrite may destroy all its register arguments. | 1696 // RecordWrite may destroy all its register arguments. |
| 1728 __ Move(a3, result_register()); | 1697 __ Move(a3, result_register()); |
| 1729 int offset = Context::SlotOffset(var->index()); | 1698 int offset = Context::SlotOffset(var->index()); |
| 1730 __ RecordWriteContextSlot( | 1699 __ RecordWriteContextSlot( |
| 1731 a1, offset, a3, a2, kRAHasBeenSaved, kDontSaveFPRegs); | 1700 a1, offset, a3, a2, kRAHasBeenSaved, kDontSaveFPRegs); |
| 1732 } | 1701 } |
| 1733 } | 1702 } |
| 1734 | 1703 |
| 1735 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, | 1704 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, |
| 1736 FeedbackVectorSlot slot, | 1705 FeedbackVectorSlot slot) { |
| 1737 HoleCheckMode hole_check_mode) { | 1706 DCHECK(!var->binding_needs_init()); |
| 1738 if (var->IsUnallocated()) { | 1707 if (var->IsUnallocated()) { |
| 1739 // Global var, const, or let. | 1708 // Global var, const, or let. |
| 1740 __ mov(StoreDescriptor::ValueRegister(), result_register()); | 1709 __ mov(StoreDescriptor::ValueRegister(), result_register()); |
| 1741 __ LoadGlobalObject(StoreDescriptor::ReceiverRegister()); | 1710 __ LoadGlobalObject(StoreDescriptor::ReceiverRegister()); |
| 1742 CallStoreIC(slot, var->name()); | 1711 CallStoreIC(slot, var->name()); |
| 1743 | 1712 |
| 1744 } else if (IsLexicalVariableMode(var->mode()) && op != Token::INIT) { | 1713 } else if (var->mode() == CONST && op != Token::INIT) { |
| 1745 DCHECK(!var->IsLookupSlot()); | 1714 if (var->throw_on_const_assignment(language_mode())) { |
| 1746 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); | |
| 1747 MemOperand location = VarOperand(var, a1); | |
| 1748 // Perform an initialization check for lexically declared variables. | |
| 1749 if (hole_check_mode == HoleCheckMode::kRequired) { | |
| 1750 Label assign; | |
| 1751 __ ld(a3, location); | |
| 1752 __ LoadRoot(a4, Heap::kTheHoleValueRootIndex); | |
| 1753 __ Branch(&assign, ne, a3, Operand(a4)); | |
| 1754 __ li(a3, Operand(var->name())); | |
| 1755 __ push(a3); | |
| 1756 __ CallRuntime(Runtime::kThrowReferenceError); | |
| 1757 __ bind(&assign); | |
| 1758 } | |
| 1759 if (var->mode() != CONST) { | |
| 1760 EmitStoreToStackLocalOrContextSlot(var, location); | |
| 1761 } else if (var->throw_on_const_assignment(language_mode())) { | |
| 1762 __ CallRuntime(Runtime::kThrowConstAssignError); | 1715 __ CallRuntime(Runtime::kThrowConstAssignError); |
| 1763 } | 1716 } |
| 1764 } else if (var->is_this() && var->mode() == CONST && op == Token::INIT) { | |
| 1765 // Initializing assignment to const {this} needs a write barrier. | |
| 1766 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); | |
| 1767 Label uninitialized_this; | |
| 1768 MemOperand location = VarOperand(var, a1); | |
| 1769 __ ld(a3, location); | |
| 1770 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); | |
| 1771 __ Branch(&uninitialized_this, eq, a3, Operand(at)); | |
| 1772 __ li(a0, Operand(var->name())); | |
| 1773 __ Push(a0); | |
| 1774 __ CallRuntime(Runtime::kThrowReferenceError); | |
| 1775 __ bind(&uninitialized_this); | |
| 1776 EmitStoreToStackLocalOrContextSlot(var, location); | |
| 1777 | |
| 1778 } else { | 1717 } else { |
| 1779 DCHECK(var->mode() != CONST || op == Token::INIT); | 1718 DCHECK(!var->is_this()); |
| 1780 DCHECK((var->IsStackAllocated() || var->IsContextSlot())); | 1719 DCHECK((var->IsStackAllocated() || var->IsContextSlot())); |
| 1781 DCHECK(!var->IsLookupSlot()); | 1720 DCHECK(!var->IsLookupSlot()); |
| 1782 // Assignment to var or initializing assignment to let/const in harmony | |
| 1783 // mode. | |
| 1784 MemOperand location = VarOperand(var, a1); | 1721 MemOperand location = VarOperand(var, a1); |
| 1785 if (FLAG_debug_code && var->mode() == LET && op == Token::INIT) { | |
| 1786 // Check for an uninitialized let binding. | |
| 1787 __ ld(a2, location); | |
| 1788 __ LoadRoot(a4, Heap::kTheHoleValueRootIndex); | |
| 1789 __ Check(eq, kLetBindingReInitialization, a2, Operand(a4)); | |
| 1790 } | |
| 1791 EmitStoreToStackLocalOrContextSlot(var, location); | 1722 EmitStoreToStackLocalOrContextSlot(var, location); |
| 1792 } | 1723 } |
| 1793 } | 1724 } |
| 1794 | 1725 |
| 1795 | 1726 |
| 1796 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { | 1727 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { |
| 1797 // Assignment to a property, using a named store IC. | 1728 // Assignment to a property, using a named store IC. |
| 1798 Property* prop = expr->target()->AsProperty(); | 1729 Property* prop = expr->target()->AsProperty(); |
| 1799 DCHECK(prop != NULL); | 1730 DCHECK(prop != NULL); |
| 1800 DCHECK(prop->key()->IsLiteral()); | 1731 DCHECK(prop->key()->IsLiteral()); |
| (...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2522 CallIC(code, expr->CountBinOpFeedbackId()); | 2453 CallIC(code, expr->CountBinOpFeedbackId()); |
| 2523 patch_site.EmitPatchInfo(); | 2454 patch_site.EmitPatchInfo(); |
| 2524 __ bind(&done); | 2455 __ bind(&done); |
| 2525 | 2456 |
| 2526 // Store the value returned in v0. | 2457 // Store the value returned in v0. |
| 2527 switch (assign_type) { | 2458 switch (assign_type) { |
| 2528 case VARIABLE: { | 2459 case VARIABLE: { |
| 2529 VariableProxy* proxy = expr->expression()->AsVariableProxy(); | 2460 VariableProxy* proxy = expr->expression()->AsVariableProxy(); |
| 2530 if (expr->is_postfix()) { | 2461 if (expr->is_postfix()) { |
| 2531 { EffectContext context(this); | 2462 { EffectContext context(this); |
| 2532 EmitVariableAssignment(proxy->var(), Token::ASSIGN, expr->CountSlot(), | 2463 EmitVariableAssignment(proxy->var(), Token::ASSIGN, |
| 2533 proxy->hole_check_mode()); | 2464 expr->CountSlot()); |
| 2534 PrepareForBailoutForId(expr->AssignmentId(), | 2465 PrepareForBailoutForId(expr->AssignmentId(), |
| 2535 BailoutState::TOS_REGISTER); | 2466 BailoutState::TOS_REGISTER); |
| 2536 context.Plug(v0); | 2467 context.Plug(v0); |
| 2537 } | 2468 } |
| 2538 // For all contexts except EffectConstant we have the result on | 2469 // For all contexts except EffectConstant we have the result on |
| 2539 // top of the stack. | 2470 // top of the stack. |
| 2540 if (!context()->IsEffect()) { | 2471 if (!context()->IsEffect()) { |
| 2541 context()->PlugTOS(); | 2472 context()->PlugTOS(); |
| 2542 } | 2473 } |
| 2543 } else { | 2474 } else { |
| 2544 EmitVariableAssignment(proxy->var(), Token::ASSIGN, expr->CountSlot(), | 2475 EmitVariableAssignment(proxy->var(), Token::ASSIGN, expr->CountSlot()); |
| 2545 proxy->hole_check_mode()); | |
| 2546 PrepareForBailoutForId(expr->AssignmentId(), | 2476 PrepareForBailoutForId(expr->AssignmentId(), |
| 2547 BailoutState::TOS_REGISTER); | 2477 BailoutState::TOS_REGISTER); |
| 2548 context()->Plug(v0); | 2478 context()->Plug(v0); |
| 2549 } | 2479 } |
| 2550 break; | 2480 break; |
| 2551 } | 2481 } |
| 2552 case NAMED_PROPERTY: { | 2482 case NAMED_PROPERTY: { |
| 2553 __ mov(StoreDescriptor::ValueRegister(), result_register()); | 2483 __ mov(StoreDescriptor::ValueRegister(), result_register()); |
| 2554 PopOperand(StoreDescriptor::ReceiverRegister()); | 2484 PopOperand(StoreDescriptor::ReceiverRegister()); |
| 2555 CallStoreIC(expr->CountSlot(), prop->key()->AsLiteral()->value()); | 2485 CallStoreIC(expr->CountSlot(), prop->key()->AsLiteral()->value()); |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2892 reinterpret_cast<uint64_t>( | 2822 reinterpret_cast<uint64_t>( |
| 2893 isolate->builtins()->OnStackReplacement()->entry())); | 2823 isolate->builtins()->OnStackReplacement()->entry())); |
| 2894 return ON_STACK_REPLACEMENT; | 2824 return ON_STACK_REPLACEMENT; |
| 2895 } | 2825 } |
| 2896 | 2826 |
| 2897 | 2827 |
| 2898 } // namespace internal | 2828 } // namespace internal |
| 2899 } // namespace v8 | 2829 } // namespace v8 |
| 2900 | 2830 |
| 2901 #endif // V8_TARGET_ARCH_MIPS64 | 2831 #endif // V8_TARGET_ARCH_MIPS64 |
| OLD | NEW |