Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(267)

Side by Side Diff: src/interpreter/bytecode-generator.cc

Issue 1922523002: [Interpreter] Use FastCloneShallowObjectStub in CreateObjectLiteral bytecode. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address Toon's comments Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1518 matching lines...) Expand 10 before | Expand all | Expand 10 after
1536 1537
1537 void BytecodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) { 1538 void BytecodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) {
1538 // Materialize a regular expression literal. 1539 // Materialize a regular expression literal.
1539 builder()->CreateRegExpLiteral(expr->pattern(), expr->literal_index(), 1540 builder()->CreateRegExpLiteral(expr->pattern(), expr->literal_index(),
1540 expr->flags()); 1541 expr->flags());
1541 execution_result()->SetResultInAccumulator(); 1542 execution_result()->SetResultInAccumulator();
1542 } 1543 }
1543 1544
1544 1545
1545 void BytecodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { 1546 void BytecodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
1546 // Deep-copy the literal boilerplate. 1547 // Copy the literal boilerplate.
1548 int fast_clone_properties_count = 0;
1549 if (FastCloneShallowObjectStub::IsSupported(expr)) {
1550 STATIC_ASSERT(
oth 2016/04/28 14:17:15 This assertion might be better placed in the encod
rmcilroy 2016/04/29 13:53:21 I can't put it in the encode routine since that is
1551 FastCloneShallowObjectStub::kMaximumClonedProperties <=
1552 1 << CreateObjectLiteralFlags::FastClonePropertiesCountBits::kShift);
1553 fast_clone_properties_count =
1554 FastCloneShallowObjectStub::PropertiesCount(expr->properties_count());
1555 }
1556 uint8_t flags =
1557 CreateObjectLiteralFlags::FlagsBits::encode(expr->ComputeFlags()) |
oth 2016/04/28 14:17:15 The code could DCHECK here that the components of
rmcilroy 2016/04/29 13:53:21 Good point. Switched to using kNext in the definit
1558 CreateObjectLiteralFlags::FastClonePropertiesCountBits::encode(
1559 fast_clone_properties_count);
1547 builder()->CreateObjectLiteral(expr->constant_properties(), 1560 builder()->CreateObjectLiteral(expr->constant_properties(),
1548 expr->literal_index(), 1561 expr->literal_index(), flags);
1549 expr->ComputeFlags(true));
1550 1562
1551 // Allocate in the outer scope since this register is used to return the 1563 // Allocate in the outer scope since this register is used to return the
1552 // expression's results to the caller. 1564 // expression's results to the caller.
1553 Register literal = register_allocator()->outer()->NewRegister(); 1565 Register literal = register_allocator()->outer()->NewRegister();
1554 builder()->StoreAccumulatorInRegister(literal); 1566 builder()->StoreAccumulatorInRegister(literal);
1555 1567
1556 // Store computed values into the literal. 1568 // Store computed values into the literal.
1557 int property_index = 0; 1569 int property_index = 0;
1558 AccessorTable accessor_table(zone()); 1570 AccessorTable accessor_table(zone());
1559 for (; property_index < expr->properties()->length(); property_index++) { 1571 for (; property_index < expr->properties()->length(); property_index++) {
(...skipping 1652 matching lines...) Expand 10 before | Expand all | Expand 10 after
3212 } 3224 }
3213 3225
3214 3226
3215 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { 3227 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const {
3216 return info()->shared_info()->feedback_vector()->GetIndex(slot); 3228 return info()->shared_info()->feedback_vector()->GetIndex(slot);
3217 } 3229 }
3218 3230
3219 } // namespace interpreter 3231 } // namespace interpreter
3220 } // namespace internal 3232 } // namespace internal
3221 } // namespace v8 3233 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698