| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_ARM64 | 5 #if V8_TARGET_ARCH_ARM64 |
| 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 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 __ CompareRoot(x1, Heap::kCatchContextMapRootIndex); | 743 __ CompareRoot(x1, Heap::kCatchContextMapRootIndex); |
| 744 __ Check(ne, kDeclarationInCatchContext); | 744 __ Check(ne, kDeclarationInCatchContext); |
| 745 } | 745 } |
| 746 } | 746 } |
| 747 | 747 |
| 748 | 748 |
| 749 void FullCodeGenerator::VisitVariableDeclaration( | 749 void FullCodeGenerator::VisitVariableDeclaration( |
| 750 VariableDeclaration* declaration) { | 750 VariableDeclaration* declaration) { |
| 751 VariableProxy* proxy = declaration->proxy(); | 751 VariableProxy* proxy = declaration->proxy(); |
| 752 Variable* variable = proxy->var(); | 752 Variable* variable = proxy->var(); |
| 753 DCHECK(!variable->binding_needs_init()); |
| 753 switch (variable->location()) { | 754 switch (variable->location()) { |
| 754 case VariableLocation::UNALLOCATED: { | 755 case VariableLocation::UNALLOCATED: { |
| 755 DCHECK(!variable->binding_needs_init()); | |
| 756 globals_->Add(variable->name(), zone()); | 756 globals_->Add(variable->name(), zone()); |
| 757 FeedbackVectorSlot slot = proxy->VariableFeedbackSlot(); | 757 FeedbackVectorSlot slot = proxy->VariableFeedbackSlot(); |
| 758 DCHECK(!slot.IsInvalid()); | 758 DCHECK(!slot.IsInvalid()); |
| 759 globals_->Add(handle(Smi::FromInt(slot.ToInt()), isolate()), zone()); | 759 globals_->Add(handle(Smi::FromInt(slot.ToInt()), isolate()), zone()); |
| 760 globals_->Add(isolate()->factory()->undefined_value(), zone()); | 760 globals_->Add(isolate()->factory()->undefined_value(), zone()); |
| 761 break; | 761 break; |
| 762 } | 762 } |
| 763 case VariableLocation::PARAMETER: | 763 case VariableLocation::PARAMETER: |
| 764 case VariableLocation::LOCAL: | 764 case VariableLocation::LOCAL: |
| 765 if (variable->binding_needs_init()) { | |
| 766 Comment cmnt(masm_, "[ VariableDeclaration"); | |
| 767 __ LoadRoot(x10, Heap::kTheHoleValueRootIndex); | |
| 768 __ Str(x10, StackOperand(variable)); | |
| 769 } | |
| 770 break; | |
| 771 | |
| 772 case VariableLocation::CONTEXT: | 765 case VariableLocation::CONTEXT: |
| 773 if (variable->binding_needs_init()) { | |
| 774 Comment cmnt(masm_, "[ VariableDeclaration"); | |
| 775 EmitDebugCheckDeclarationContext(variable); | |
| 776 __ LoadRoot(x10, Heap::kTheHoleValueRootIndex); | |
| 777 __ Str(x10, ContextMemOperand(cp, variable->index())); | |
| 778 // No write barrier since the_hole_value is in old space. | |
| 779 PrepareForBailoutForId(proxy->id(), BailoutState::NO_REGISTERS); | |
| 780 } | |
| 781 break; | 766 break; |
| 782 | 767 |
| 783 case VariableLocation::LOOKUP: | 768 case VariableLocation::LOOKUP: |
| 784 case VariableLocation::MODULE: | 769 case VariableLocation::MODULE: |
| 785 UNREACHABLE(); | 770 UNREACHABLE(); |
| 786 } | 771 } |
| 787 } | 772 } |
| 788 | 773 |
| 789 | 774 |
| 790 void FullCodeGenerator::VisitFunctionDeclaration( | 775 void FullCodeGenerator::VisitFunctionDeclaration( |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1127 __ Peek(StoreDescriptor::ValueRegister(), offset * kPointerSize); | 1112 __ Peek(StoreDescriptor::ValueRegister(), offset * kPointerSize); |
| 1128 CallStoreIC(slot, isolate()->factory()->home_object_symbol()); | 1113 CallStoreIC(slot, isolate()->factory()->home_object_symbol()); |
| 1129 } | 1114 } |
| 1130 | 1115 |
| 1131 void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy, | 1116 void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy, |
| 1132 TypeofMode typeof_mode) { | 1117 TypeofMode typeof_mode) { |
| 1133 // Record position before possible IC call. | 1118 // Record position before possible IC call. |
| 1134 SetExpressionPosition(proxy); | 1119 SetExpressionPosition(proxy); |
| 1135 PrepareForBailoutForId(proxy->BeforeId(), BailoutState::NO_REGISTERS); | 1120 PrepareForBailoutForId(proxy->BeforeId(), BailoutState::NO_REGISTERS); |
| 1136 Variable* var = proxy->var(); | 1121 Variable* var = proxy->var(); |
| 1122 DCHECK(!var->binding_needs_init()); |
| 1137 | 1123 |
| 1138 // Two cases: global variables and all other types of variables. | 1124 // Two cases: global variables and all other types of variables. |
| 1139 switch (var->location()) { | 1125 switch (var->location()) { |
| 1140 case VariableLocation::UNALLOCATED: { | 1126 case VariableLocation::UNALLOCATED: { |
| 1141 Comment cmnt(masm_, "Global variable"); | 1127 Comment cmnt(masm_, "Global variable"); |
| 1142 EmitGlobalVariableLoad(proxy, typeof_mode); | 1128 EmitGlobalVariableLoad(proxy, typeof_mode); |
| 1143 context()->Plug(x0); | 1129 context()->Plug(x0); |
| 1144 break; | 1130 break; |
| 1145 } | 1131 } |
| 1146 | 1132 |
| 1147 case VariableLocation::PARAMETER: | 1133 case VariableLocation::PARAMETER: |
| 1148 case VariableLocation::LOCAL: | 1134 case VariableLocation::LOCAL: |
| 1149 case VariableLocation::CONTEXT: { | 1135 case VariableLocation::CONTEXT: { |
| 1150 DCHECK_EQ(NOT_INSIDE_TYPEOF, typeof_mode); | 1136 DCHECK_EQ(NOT_INSIDE_TYPEOF, typeof_mode); |
| 1151 Comment cmnt(masm_, var->IsContextSlot() | 1137 Comment cmnt(masm_, var->IsContextSlot() |
| 1152 ? "Context variable" | 1138 ? "Context variable" |
| 1153 : "Stack variable"); | 1139 : "Stack variable"); |
| 1154 if (proxy->hole_check_mode() == HoleCheckMode::kRequired) { | |
| 1155 // Throw a reference error when using an uninitialized let/const | |
| 1156 // binding in harmony mode. | |
| 1157 Label done; | |
| 1158 GetVar(x0, var); | |
| 1159 __ JumpIfNotRoot(x0, Heap::kTheHoleValueRootIndex, &done); | |
| 1160 __ Mov(x0, Operand(var->name())); | |
| 1161 __ Push(x0); | |
| 1162 __ CallRuntime(Runtime::kThrowReferenceError); | |
| 1163 __ Bind(&done); | |
| 1164 context()->Plug(x0); | |
| 1165 break; | |
| 1166 } | |
| 1167 context()->Plug(var); | 1140 context()->Plug(var); |
| 1168 break; | 1141 break; |
| 1169 } | 1142 } |
| 1170 | 1143 |
| 1171 case VariableLocation::LOOKUP: | 1144 case VariableLocation::LOOKUP: |
| 1172 case VariableLocation::MODULE: | 1145 case VariableLocation::MODULE: |
| 1173 UNREACHABLE(); | 1146 UNREACHABLE(); |
| 1174 } | 1147 } |
| 1175 } | 1148 } |
| 1176 | 1149 |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1469 } else { | 1442 } else { |
| 1470 VisitForAccumulatorValue(expr->value()); | 1443 VisitForAccumulatorValue(expr->value()); |
| 1471 } | 1444 } |
| 1472 | 1445 |
| 1473 SetExpressionPosition(expr); | 1446 SetExpressionPosition(expr); |
| 1474 | 1447 |
| 1475 // Store the value. | 1448 // Store the value. |
| 1476 switch (assign_type) { | 1449 switch (assign_type) { |
| 1477 case VARIABLE: { | 1450 case VARIABLE: { |
| 1478 VariableProxy* proxy = expr->target()->AsVariableProxy(); | 1451 VariableProxy* proxy = expr->target()->AsVariableProxy(); |
| 1479 EmitVariableAssignment(proxy->var(), expr->op(), expr->AssignmentSlot(), | 1452 EmitVariableAssignment(proxy->var(), expr->op(), expr->AssignmentSlot()); |
| 1480 proxy->hole_check_mode()); | |
| 1481 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); | 1453 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); |
| 1482 context()->Plug(x0); | 1454 context()->Plug(x0); |
| 1483 break; | 1455 break; |
| 1484 } | 1456 } |
| 1485 case NAMED_PROPERTY: | 1457 case NAMED_PROPERTY: |
| 1486 EmitNamedPropertyAssignment(expr); | 1458 EmitNamedPropertyAssignment(expr); |
| 1487 break; | 1459 break; |
| 1488 case KEYED_PROPERTY: | 1460 case KEYED_PROPERTY: |
| 1489 EmitKeyedPropertyAssignment(expr); | 1461 EmitKeyedPropertyAssignment(expr); |
| 1490 break; | 1462 break; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1611 FeedbackVectorSlot slot) { | 1583 FeedbackVectorSlot slot) { |
| 1612 DCHECK(expr->IsValidReferenceExpressionOrThis()); | 1584 DCHECK(expr->IsValidReferenceExpressionOrThis()); |
| 1613 | 1585 |
| 1614 Property* prop = expr->AsProperty(); | 1586 Property* prop = expr->AsProperty(); |
| 1615 LhsKind assign_type = Property::GetAssignType(prop); | 1587 LhsKind assign_type = Property::GetAssignType(prop); |
| 1616 | 1588 |
| 1617 switch (assign_type) { | 1589 switch (assign_type) { |
| 1618 case VARIABLE: { | 1590 case VARIABLE: { |
| 1619 VariableProxy* proxy = expr->AsVariableProxy(); | 1591 VariableProxy* proxy = expr->AsVariableProxy(); |
| 1620 EffectContext context(this); | 1592 EffectContext context(this); |
| 1621 EmitVariableAssignment(proxy->var(), Token::ASSIGN, slot, | 1593 EmitVariableAssignment(proxy->var(), Token::ASSIGN, slot); |
| 1622 proxy->hole_check_mode()); | |
| 1623 break; | 1594 break; |
| 1624 } | 1595 } |
| 1625 case NAMED_PROPERTY: { | 1596 case NAMED_PROPERTY: { |
| 1626 PushOperand(x0); // Preserve value. | 1597 PushOperand(x0); // Preserve value. |
| 1627 VisitForAccumulatorValue(prop->obj()); | 1598 VisitForAccumulatorValue(prop->obj()); |
| 1628 // TODO(all): We could introduce a VisitForRegValue(reg, expr) to avoid | 1599 // TODO(all): We could introduce a VisitForRegValue(reg, expr) to avoid |
| 1629 // this copy. | 1600 // this copy. |
| 1630 __ Mov(StoreDescriptor::ReceiverRegister(), x0); | 1601 __ Mov(StoreDescriptor::ReceiverRegister(), x0); |
| 1631 PopOperand(StoreDescriptor::ValueRegister()); // Restore value. | 1602 PopOperand(StoreDescriptor::ValueRegister()); // Restore value. |
| 1632 CallStoreIC(slot, prop->key()->AsLiteral()->value()); | 1603 CallStoreIC(slot, prop->key()->AsLiteral()->value()); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1657 if (var->IsContextSlot()) { | 1628 if (var->IsContextSlot()) { |
| 1658 // RecordWrite may destroy all its register arguments. | 1629 // RecordWrite may destroy all its register arguments. |
| 1659 __ Mov(x10, result_register()); | 1630 __ Mov(x10, result_register()); |
| 1660 int offset = Context::SlotOffset(var->index()); | 1631 int offset = Context::SlotOffset(var->index()); |
| 1661 __ RecordWriteContextSlot( | 1632 __ RecordWriteContextSlot( |
| 1662 x1, offset, x10, x11, kLRHasBeenSaved, kDontSaveFPRegs); | 1633 x1, offset, x10, x11, kLRHasBeenSaved, kDontSaveFPRegs); |
| 1663 } | 1634 } |
| 1664 } | 1635 } |
| 1665 | 1636 |
| 1666 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, | 1637 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, |
| 1667 FeedbackVectorSlot slot, | 1638 FeedbackVectorSlot slot) { |
| 1668 HoleCheckMode hole_check_mode) { | |
| 1669 ASM_LOCATION("FullCodeGenerator::EmitVariableAssignment"); | 1639 ASM_LOCATION("FullCodeGenerator::EmitVariableAssignment"); |
| 1640 DCHECK(!var->binding_needs_init()); |
| 1670 if (var->IsUnallocated()) { | 1641 if (var->IsUnallocated()) { |
| 1671 // Global var, const, or let. | 1642 // Global var, const, or let. |
| 1672 __ LoadGlobalObject(StoreDescriptor::ReceiverRegister()); | 1643 __ LoadGlobalObject(StoreDescriptor::ReceiverRegister()); |
| 1673 CallStoreIC(slot, var->name()); | 1644 CallStoreIC(slot, var->name()); |
| 1674 | 1645 |
| 1675 } else if (IsLexicalVariableMode(var->mode()) && op != Token::INIT) { | 1646 } else if (var->mode() == CONST && op != Token::INIT) { |
| 1676 DCHECK(!var->IsLookupSlot()); | 1647 if (var->throw_on_const_assignment(language_mode())) { |
| 1677 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); | |
| 1678 MemOperand location = VarOperand(var, x1); | |
| 1679 // Perform an initialization check for lexically declared variables. | |
| 1680 if (var->binding_needs_init()) { | |
| 1681 Label assign; | |
| 1682 __ Ldr(x10, location); | |
| 1683 __ JumpIfNotRoot(x10, Heap::kTheHoleValueRootIndex, &assign); | |
| 1684 __ Mov(x10, Operand(var->name())); | |
| 1685 __ Push(x10); | |
| 1686 __ CallRuntime(Runtime::kThrowReferenceError); | |
| 1687 __ Bind(&assign); | |
| 1688 } | |
| 1689 if (var->mode() != CONST) { | |
| 1690 EmitStoreToStackLocalOrContextSlot(var, location); | |
| 1691 } else if (var->throw_on_const_assignment(language_mode())) { | |
| 1692 __ CallRuntime(Runtime::kThrowConstAssignError); | 1648 __ CallRuntime(Runtime::kThrowConstAssignError); |
| 1693 } | 1649 } |
| 1694 } else if (var->is_this() && var->mode() == CONST && op == Token::INIT) { | |
| 1695 // Initializing assignment to const {this} needs a write barrier. | |
| 1696 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); | |
| 1697 Label uninitialized_this; | |
| 1698 MemOperand location = VarOperand(var, x1); | |
| 1699 __ Ldr(x10, location); | |
| 1700 __ JumpIfRoot(x10, Heap::kTheHoleValueRootIndex, &uninitialized_this); | |
| 1701 __ Mov(x0, Operand(var->name())); | |
| 1702 __ Push(x0); | |
| 1703 __ CallRuntime(Runtime::kThrowReferenceError); | |
| 1704 __ bind(&uninitialized_this); | |
| 1705 EmitStoreToStackLocalOrContextSlot(var, location); | |
| 1706 | |
| 1707 } else { | 1650 } else { |
| 1708 DCHECK(var->mode() != CONST || op == Token::INIT); | 1651 DCHECK(!var->is_this()); |
| 1709 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); | 1652 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); |
| 1710 DCHECK(!var->IsLookupSlot()); | 1653 DCHECK(!var->IsLookupSlot()); |
| 1711 // Assignment to var or initializing assignment to let/const in harmony | |
| 1712 // mode. | |
| 1713 MemOperand location = VarOperand(var, x1); | 1654 MemOperand location = VarOperand(var, x1); |
| 1714 if (FLAG_debug_code && var->mode() == LET && op == Token::INIT) { | |
| 1715 __ Ldr(x10, location); | |
| 1716 __ CompareRoot(x10, Heap::kTheHoleValueRootIndex); | |
| 1717 __ Check(eq, kLetBindingReInitialization); | |
| 1718 } | |
| 1719 EmitStoreToStackLocalOrContextSlot(var, location); | 1655 EmitStoreToStackLocalOrContextSlot(var, location); |
| 1720 } | 1656 } |
| 1721 } | 1657 } |
| 1722 | 1658 |
| 1723 | 1659 |
| 1724 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { | 1660 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { |
| 1725 ASM_LOCATION("FullCodeGenerator::EmitNamedPropertyAssignment"); | 1661 ASM_LOCATION("FullCodeGenerator::EmitNamedPropertyAssignment"); |
| 1726 // Assignment to a property, using a named store IC. | 1662 // Assignment to a property, using a named store IC. |
| 1727 Property* prop = expr->target()->AsProperty(); | 1663 Property* prop = expr->target()->AsProperty(); |
| 1728 DCHECK(prop != NULL); | 1664 DCHECK(prop != NULL); |
| (...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2463 patch_site.EmitPatchInfo(); | 2399 patch_site.EmitPatchInfo(); |
| 2464 } | 2400 } |
| 2465 __ Bind(&done); | 2401 __ Bind(&done); |
| 2466 | 2402 |
| 2467 // Store the value returned in x0. | 2403 // Store the value returned in x0. |
| 2468 switch (assign_type) { | 2404 switch (assign_type) { |
| 2469 case VARIABLE: { | 2405 case VARIABLE: { |
| 2470 VariableProxy* proxy = expr->expression()->AsVariableProxy(); | 2406 VariableProxy* proxy = expr->expression()->AsVariableProxy(); |
| 2471 if (expr->is_postfix()) { | 2407 if (expr->is_postfix()) { |
| 2472 { EffectContext context(this); | 2408 { EffectContext context(this); |
| 2473 EmitVariableAssignment(proxy->var(), Token::ASSIGN, expr->CountSlot(), | 2409 EmitVariableAssignment(proxy->var(), Token::ASSIGN, |
| 2474 proxy->hole_check_mode()); | 2410 expr->CountSlot()); |
| 2475 PrepareForBailoutForId(expr->AssignmentId(), | 2411 PrepareForBailoutForId(expr->AssignmentId(), |
| 2476 BailoutState::TOS_REGISTER); | 2412 BailoutState::TOS_REGISTER); |
| 2477 context.Plug(x0); | 2413 context.Plug(x0); |
| 2478 } | 2414 } |
| 2479 // For all contexts except EffectConstant We have the result on | 2415 // For all contexts except EffectConstant We have the result on |
| 2480 // top of the stack. | 2416 // top of the stack. |
| 2481 if (!context()->IsEffect()) { | 2417 if (!context()->IsEffect()) { |
| 2482 context()->PlugTOS(); | 2418 context()->PlugTOS(); |
| 2483 } | 2419 } |
| 2484 } else { | 2420 } else { |
| 2485 EmitVariableAssignment(proxy->var(), Token::ASSIGN, expr->CountSlot(), | 2421 EmitVariableAssignment(proxy->var(), Token::ASSIGN, expr->CountSlot()); |
| 2486 proxy->hole_check_mode()); | |
| 2487 PrepareForBailoutForId(expr->AssignmentId(), | 2422 PrepareForBailoutForId(expr->AssignmentId(), |
| 2488 BailoutState::TOS_REGISTER); | 2423 BailoutState::TOS_REGISTER); |
| 2489 context()->Plug(x0); | 2424 context()->Plug(x0); |
| 2490 } | 2425 } |
| 2491 break; | 2426 break; |
| 2492 } | 2427 } |
| 2493 case NAMED_PROPERTY: { | 2428 case NAMED_PROPERTY: { |
| 2494 PopOperand(StoreDescriptor::ReceiverRegister()); | 2429 PopOperand(StoreDescriptor::ReceiverRegister()); |
| 2495 CallStoreIC(expr->CountSlot(), prop->key()->AsLiteral()->value()); | 2430 CallStoreIC(expr->CountSlot(), prop->key()->AsLiteral()->value()); |
| 2496 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); | 2431 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2924 } | 2859 } |
| 2925 | 2860 |
| 2926 return INTERRUPT; | 2861 return INTERRUPT; |
| 2927 } | 2862 } |
| 2928 | 2863 |
| 2929 | 2864 |
| 2930 } // namespace internal | 2865 } // namespace internal |
| 2931 } // namespace v8 | 2866 } // namespace v8 |
| 2932 | 2867 |
| 2933 #endif // V8_TARGET_ARCH_ARM64 | 2868 #endif // V8_TARGET_ARCH_ARM64 |
| OLD | NEW |