| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/interpreter/bytecode-generator.h" | 5 #include "src/interpreter/bytecode-generator.h" |
| 6 | 6 |
| 7 #include "src/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
| 8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
| 9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
| 10 #include "src/interpreter/bytecode-flags.h" | 10 #include "src/interpreter/bytecode-flags.h" |
| (...skipping 1616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1627 | 1627 |
| 1628 // Store computed values into the literal. | 1628 // Store computed values into the literal. |
| 1629 int property_index = 0; | 1629 int property_index = 0; |
| 1630 AccessorTable accessor_table(zone()); | 1630 AccessorTable accessor_table(zone()); |
| 1631 for (; property_index < expr->properties()->length(); property_index++) { | 1631 for (; property_index < expr->properties()->length(); property_index++) { |
| 1632 ObjectLiteral::Property* property = expr->properties()->at(property_index); | 1632 ObjectLiteral::Property* property = expr->properties()->at(property_index); |
| 1633 if (property->is_computed_name()) break; | 1633 if (property->is_computed_name()) break; |
| 1634 if (property->IsCompileTimeValue()) continue; | 1634 if (property->IsCompileTimeValue()) continue; |
| 1635 | 1635 |
| 1636 RegisterAllocationScope inner_register_scope(this); | 1636 RegisterAllocationScope inner_register_scope(this); |
| 1637 Literal* literal_key = property->key()->AsLiteral(); | 1637 Literal* key = property->key()->AsLiteral(); |
| 1638 switch (property->kind()) { | 1638 switch (property->kind()) { |
| 1639 case ObjectLiteral::Property::CONSTANT: | 1639 case ObjectLiteral::Property::CONSTANT: |
| 1640 UNREACHABLE(); | 1640 UNREACHABLE(); |
| 1641 case ObjectLiteral::Property::MATERIALIZED_LITERAL: | 1641 case ObjectLiteral::Property::MATERIALIZED_LITERAL: |
| 1642 DCHECK(!CompileTimeValue::IsCompileTimeValue(property->value())); | 1642 DCHECK(!CompileTimeValue::IsCompileTimeValue(property->value())); |
| 1643 // Fall through. | 1643 // Fall through. |
| 1644 case ObjectLiteral::Property::COMPUTED: { | 1644 case ObjectLiteral::Property::COMPUTED: { |
| 1645 // It is safe to use [[Put]] here because the boilerplate already | 1645 // It is safe to use [[Put]] here because the boilerplate already |
| 1646 // contains computed properties with an uninitialized value. | 1646 // contains computed properties with an uninitialized value. |
| 1647 | 1647 if (key->IsPropertyName()) { |
| 1648 // TODO(5203): Remove this temporary exception. | |
| 1649 AllowHandleDereference allow_deref; | |
| 1650 | |
| 1651 if (literal_key->value()->IsInternalizedString()) { | |
| 1652 if (property->emit_store()) { | 1648 if (property->emit_store()) { |
| 1653 VisitForAccumulatorValue(property->value()); | 1649 VisitForAccumulatorValue(property->value()); |
| 1654 if (FunctionLiteral::NeedsHomeObject(property->value())) { | 1650 if (FunctionLiteral::NeedsHomeObject(property->value())) { |
| 1655 RegisterAllocationScope register_scope(this); | 1651 RegisterAllocationScope register_scope(this); |
| 1656 Register value = register_allocator()->NewRegister(); | 1652 Register value = register_allocator()->NewRegister(); |
| 1657 builder()->StoreAccumulatorInRegister(value); | 1653 builder()->StoreAccumulatorInRegister(value); |
| 1658 builder()->StoreNamedProperty( | 1654 builder()->StoreNamedProperty( |
| 1659 literal, literal_key->AsPropertyName(), | 1655 literal, key->AsPropertyName(), |
| 1660 feedback_index(property->GetSlot(0)), language_mode()); | 1656 feedback_index(property->GetSlot(0)), language_mode()); |
| 1661 VisitSetHomeObject(value, literal, property, 1); | 1657 VisitSetHomeObject(value, literal, property, 1); |
| 1662 } else { | 1658 } else { |
| 1663 builder()->StoreNamedProperty( | 1659 builder()->StoreNamedProperty( |
| 1664 literal, literal_key->AsPropertyName(), | 1660 literal, key->AsPropertyName(), |
| 1665 feedback_index(property->GetSlot(0)), language_mode()); | 1661 feedback_index(property->GetSlot(0)), language_mode()); |
| 1666 } | 1662 } |
| 1667 } else { | 1663 } else { |
| 1668 VisitForEffect(property->value()); | 1664 VisitForEffect(property->value()); |
| 1669 } | 1665 } |
| 1670 } else { | 1666 } else { |
| 1671 register_allocator()->PrepareForConsecutiveAllocations(4); | 1667 register_allocator()->PrepareForConsecutiveAllocations(4); |
| 1672 Register literal_argument = | 1668 Register literal_argument = |
| 1673 register_allocator()->NextConsecutiveRegister(); | 1669 register_allocator()->NextConsecutiveRegister(); |
| 1674 Register key = register_allocator()->NextConsecutiveRegister(); | 1670 Register key = register_allocator()->NextConsecutiveRegister(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1698 Register value = register_allocator()->NextConsecutiveRegister(); | 1694 Register value = register_allocator()->NextConsecutiveRegister(); |
| 1699 | 1695 |
| 1700 builder()->MoveRegister(literal, literal_argument); | 1696 builder()->MoveRegister(literal, literal_argument); |
| 1701 VisitForAccumulatorValue(property->value()); | 1697 VisitForAccumulatorValue(property->value()); |
| 1702 builder()->StoreAccumulatorInRegister(value).CallRuntime( | 1698 builder()->StoreAccumulatorInRegister(value).CallRuntime( |
| 1703 Runtime::kInternalSetPrototype, literal_argument, 2); | 1699 Runtime::kInternalSetPrototype, literal_argument, 2); |
| 1704 break; | 1700 break; |
| 1705 } | 1701 } |
| 1706 case ObjectLiteral::Property::GETTER: | 1702 case ObjectLiteral::Property::GETTER: |
| 1707 if (property->emit_store()) { | 1703 if (property->emit_store()) { |
| 1708 accessor_table.lookup(literal_key)->second->getter = property; | 1704 accessor_table.lookup(key)->second->getter = property; |
| 1709 } | 1705 } |
| 1710 break; | 1706 break; |
| 1711 case ObjectLiteral::Property::SETTER: | 1707 case ObjectLiteral::Property::SETTER: |
| 1712 if (property->emit_store()) { | 1708 if (property->emit_store()) { |
| 1713 accessor_table.lookup(literal_key)->second->setter = property; | 1709 accessor_table.lookup(key)->second->setter = property; |
| 1714 } | 1710 } |
| 1715 break; | 1711 break; |
| 1716 } | 1712 } |
| 1717 } | 1713 } |
| 1718 | 1714 |
| 1719 // Define accessors, using only a single call to the runtime for each pair of | 1715 // Define accessors, using only a single call to the runtime for each pair of |
| 1720 // corresponding getters and setters. | 1716 // corresponding getters and setters. |
| 1721 for (AccessorTable::Iterator it = accessor_table.begin(); | 1717 for (AccessorTable::Iterator it = accessor_table.begin(); |
| 1722 it != accessor_table.end(); ++it) { | 1718 it != accessor_table.end(); ++it) { |
| 1723 RegisterAllocationScope inner_register_scope(this); | 1719 RegisterAllocationScope inner_register_scope(this); |
| (...skipping 1561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3285 return execution_context()->scope()->language_mode(); | 3281 return execution_context()->scope()->language_mode(); |
| 3286 } | 3282 } |
| 3287 | 3283 |
| 3288 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 3284 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
| 3289 return TypeFeedbackVector::GetIndex(slot); | 3285 return TypeFeedbackVector::GetIndex(slot); |
| 3290 } | 3286 } |
| 3291 | 3287 |
| 3292 } // namespace interpreter | 3288 } // namespace interpreter |
| 3293 } // namespace internal | 3289 } // namespace internal |
| 3294 } // namespace v8 | 3290 } // namespace v8 |
| OLD | NEW |