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/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-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 1622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1633 } else if (raw_value->IsTheHole()) { | 1633 } else if (raw_value->IsTheHole()) { |
1634 builder()->LoadTheHole(); | 1634 builder()->LoadTheHole(); |
1635 } else { | 1635 } else { |
1636 builder()->LoadLiteral(raw_value->value()); | 1636 builder()->LoadLiteral(raw_value->value()); |
1637 } | 1637 } |
1638 } | 1638 } |
1639 } | 1639 } |
1640 | 1640 |
1641 void BytecodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) { | 1641 void BytecodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) { |
1642 // Materialize a regular expression literal. | 1642 // Materialize a regular expression literal. |
1643 builder()->CreateRegExpLiteral(expr->pattern(), expr->literal_index(), | 1643 builder()->CreateRegExpLiteral( |
1644 expr->flags()); | 1644 expr->pattern(), feedback_index(expr->literal_slot()), expr->flags()); |
1645 } | 1645 } |
1646 | 1646 |
1647 void BytecodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { | 1647 void BytecodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { |
1648 // Deep-copy the literal boilerplate. | 1648 // Deep-copy the literal boilerplate. |
1649 uint8_t flags = CreateObjectLiteralFlags::Encode( | 1649 uint8_t flags = CreateObjectLiteralFlags::Encode( |
1650 expr->IsFastCloningSupported(), | 1650 expr->IsFastCloningSupported(), |
1651 ConstructorBuiltinsAssembler::FastCloneShallowObjectPropertiesCount( | 1651 ConstructorBuiltinsAssembler::FastCloneShallowObjectPropertiesCount( |
1652 expr->properties_count()), | 1652 expr->properties_count()), |
1653 expr->ComputeFlags()); | 1653 expr->ComputeFlags()); |
1654 | 1654 |
1655 Register literal = register_allocator()->NewRegister(); | 1655 Register literal = register_allocator()->NewRegister(); |
1656 size_t entry; | 1656 size_t entry; |
1657 // If constant properties is an empty fixed array, use our cached | 1657 // If constant properties is an empty fixed array, use our cached |
1658 // empty_fixed_array to ensure it's only added to the constant pool once. | 1658 // empty_fixed_array to ensure it's only added to the constant pool once. |
1659 if (expr->properties_count() == 0) { | 1659 if (expr->properties_count() == 0) { |
1660 entry = builder()->GetConstantPoolEntry(empty_fixed_array()); | 1660 entry = builder()->GetConstantPoolEntry(empty_fixed_array()); |
1661 } else { | 1661 } else { |
1662 entry = builder()->AllocateConstantPoolEntry(); | 1662 entry = builder()->AllocateConstantPoolEntry(); |
1663 object_literals_.push_back(std::make_pair(expr, entry)); | 1663 object_literals_.push_back(std::make_pair(expr, entry)); |
1664 } | 1664 } |
1665 builder()->CreateObjectLiteral(entry, expr->literal_index(), flags, literal); | 1665 builder()->CreateObjectLiteral(entry, feedback_index(expr->literal_slot()), |
| 1666 flags, literal); |
1666 | 1667 |
1667 // Store computed values into the literal. | 1668 // Store computed values into the literal. |
1668 int property_index = 0; | 1669 int property_index = 0; |
1669 AccessorTable accessor_table(zone()); | 1670 AccessorTable accessor_table(zone()); |
1670 for (; property_index < expr->properties()->length(); property_index++) { | 1671 for (; property_index < expr->properties()->length(); property_index++) { |
1671 ObjectLiteral::Property* property = expr->properties()->at(property_index); | 1672 ObjectLiteral::Property* property = expr->properties()->at(property_index); |
1672 if (property->is_computed_name()) break; | 1673 if (property->is_computed_name()) break; |
1673 if (property->IsCompileTimeValue()) continue; | 1674 if (property->IsCompileTimeValue()) continue; |
1674 | 1675 |
1675 RegisterAllocationScope inner_register_scope(this); | 1676 RegisterAllocationScope inner_register_scope(this); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1839 | 1840 |
1840 builder()->LoadAccumulatorWithRegister(literal); | 1841 builder()->LoadAccumulatorWithRegister(literal); |
1841 } | 1842 } |
1842 | 1843 |
1843 void BytecodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { | 1844 void BytecodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { |
1844 // Deep-copy the literal boilerplate. | 1845 // Deep-copy the literal boilerplate. |
1845 uint8_t flags = CreateArrayLiteralFlags::Encode( | 1846 uint8_t flags = CreateArrayLiteralFlags::Encode( |
1846 expr->IsFastCloningSupported(), expr->ComputeFlags()); | 1847 expr->IsFastCloningSupported(), expr->ComputeFlags()); |
1847 | 1848 |
1848 size_t entry = builder()->AllocateConstantPoolEntry(); | 1849 size_t entry = builder()->AllocateConstantPoolEntry(); |
1849 builder()->CreateArrayLiteral(entry, expr->literal_index(), flags); | 1850 builder()->CreateArrayLiteral(entry, feedback_index(expr->literal_slot()), |
| 1851 flags); |
1850 array_literals_.push_back(std::make_pair(expr, entry)); | 1852 array_literals_.push_back(std::make_pair(expr, entry)); |
1851 | 1853 |
1852 Register index, literal; | 1854 Register index, literal; |
1853 | 1855 |
1854 // Evaluate all the non-constant subexpressions and store them into the | 1856 // Evaluate all the non-constant subexpressions and store them into the |
1855 // newly cloned array. | 1857 // newly cloned array. |
1856 bool literal_in_accumulator = true; | 1858 bool literal_in_accumulator = true; |
1857 for (int array_index = 0; array_index < expr->values()->length(); | 1859 for (int array_index = 0; array_index < expr->values()->length(); |
1858 array_index++) { | 1860 array_index++) { |
1859 Expression* subexpr = expr->values()->at(array_index); | 1861 Expression* subexpr = expr->values()->at(array_index); |
(...skipping 1515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3375 } | 3377 } |
3376 | 3378 |
3377 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { | 3379 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { |
3378 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict | 3380 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict |
3379 : Runtime::kStoreKeyedToSuper_Sloppy; | 3381 : Runtime::kStoreKeyedToSuper_Sloppy; |
3380 } | 3382 } |
3381 | 3383 |
3382 } // namespace interpreter | 3384 } // namespace interpreter |
3383 } // namespace internal | 3385 } // namespace internal |
3384 } // namespace v8 | 3386 } // namespace v8 |
OLD | NEW |