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/compiler.h" | 9 #include "src/compiler.h" |
9 #include "src/interpreter/bytecode-register-allocator.h" | 10 #include "src/interpreter/bytecode-register-allocator.h" |
10 #include "src/interpreter/control-flow-builders.h" | 11 #include "src/interpreter/control-flow-builders.h" |
11 #include "src/objects.h" | 12 #include "src/objects.h" |
12 #include "src/parsing/parser.h" | 13 #include "src/parsing/parser.h" |
13 #include "src/parsing/token.h" | 14 #include "src/parsing/token.h" |
14 | 15 |
15 namespace v8 { | 16 namespace v8 { |
16 namespace internal { | 17 namespace internal { |
17 namespace interpreter { | 18 namespace interpreter { |
(...skipping 1571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1589 | 1590 |
1590 void BytecodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) { | 1591 void BytecodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) { |
1591 // Materialize a regular expression literal. | 1592 // Materialize a regular expression literal. |
1592 builder()->CreateRegExpLiteral(expr->pattern(), expr->literal_index(), | 1593 builder()->CreateRegExpLiteral(expr->pattern(), expr->literal_index(), |
1593 expr->flags()); | 1594 expr->flags()); |
1594 execution_result()->SetResultInAccumulator(); | 1595 execution_result()->SetResultInAccumulator(); |
1595 } | 1596 } |
1596 | 1597 |
1597 | 1598 |
1598 void BytecodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { | 1599 void BytecodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { |
1599 // Deep-copy the literal boilerplate. | 1600 // Copy the literal boilerplate. |
| 1601 int fast_clone_properties_count = 0; |
| 1602 if (FastCloneShallowObjectStub::IsSupported(expr)) { |
| 1603 STATIC_ASSERT( |
| 1604 FastCloneShallowObjectStub::kMaximumClonedProperties <= |
| 1605 1 << CreateObjectLiteralFlags::FastClonePropertiesCountBits::kShift); |
| 1606 fast_clone_properties_count = |
| 1607 FastCloneShallowObjectStub::PropertiesCount(expr->properties_count()); |
| 1608 } |
| 1609 uint8_t flags = |
| 1610 CreateObjectLiteralFlags::FlagsBits::encode(expr->ComputeFlags()) | |
| 1611 CreateObjectLiteralFlags::FastClonePropertiesCountBits::encode( |
| 1612 fast_clone_properties_count); |
1600 builder()->CreateObjectLiteral(expr->constant_properties(), | 1613 builder()->CreateObjectLiteral(expr->constant_properties(), |
1601 expr->literal_index(), | 1614 expr->literal_index(), flags); |
1602 expr->ComputeFlags(true)); | |
1603 | 1615 |
1604 // Allocate in the outer scope since this register is used to return the | 1616 // Allocate in the outer scope since this register is used to return the |
1605 // expression's results to the caller. | 1617 // expression's results to the caller. |
1606 Register literal = register_allocator()->outer()->NewRegister(); | 1618 Register literal = register_allocator()->outer()->NewRegister(); |
1607 builder()->StoreAccumulatorInRegister(literal); | 1619 builder()->StoreAccumulatorInRegister(literal); |
1608 | 1620 |
1609 // Store computed values into the literal. | 1621 // Store computed values into the literal. |
1610 int property_index = 0; | 1622 int property_index = 0; |
1611 AccessorTable accessor_table(zone()); | 1623 AccessorTable accessor_table(zone()); |
1612 for (; property_index < expr->properties()->length(); property_index++) { | 1624 for (; property_index < expr->properties()->length(); property_index++) { |
(...skipping 1658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3271 } | 3283 } |
3272 | 3284 |
3273 | 3285 |
3274 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 3286 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
3275 return info()->shared_info()->feedback_vector()->GetIndex(slot); | 3287 return info()->shared_info()->feedback_vector()->GetIndex(slot); |
3276 } | 3288 } |
3277 | 3289 |
3278 } // namespace interpreter | 3290 } // namespace interpreter |
3279 } // namespace internal | 3291 } // namespace internal |
3280 } // namespace v8 | 3292 } // namespace v8 |
OLD | NEW |