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

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

Issue 2570843002: Fix usage of literal cloning for large double arrays. (Closed)
Patch Set: Addressed comments. Created 4 years 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
« no previous file with comments | « src/full-codegen/full-codegen.cc ('k') | test/mjsunit/regress/regress-crbug-672792.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/compilation-info.h" 10 #include "src/compilation-info.h"
(...skipping 1573 matching lines...) Expand 10 before | Expand all | Expand 10 after
1584 } 1584 }
1585 } 1585 }
1586 1586
1587 void BytecodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) { 1587 void BytecodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) {
1588 // Materialize a regular expression literal. 1588 // Materialize a regular expression literal.
1589 builder()->CreateRegExpLiteral(expr->pattern(), expr->literal_index(), 1589 builder()->CreateRegExpLiteral(expr->pattern(), expr->literal_index(),
1590 expr->flags()); 1590 expr->flags());
1591 } 1591 }
1592 1592
1593 void BytecodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { 1593 void BytecodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
1594 // Copy the literal boilerplate. 1594 // Deep-copy the literal boilerplate.
1595 uint8_t flags = CreateObjectLiteralFlags::Encode( 1595 uint8_t flags = CreateObjectLiteralFlags::Encode(
1596 FastCloneShallowObjectStub::IsSupported(expr), 1596 expr->IsFastCloningSupported(),
1597 FastCloneShallowObjectStub::PropertiesCount(expr->properties_count()), 1597 FastCloneShallowObjectStub::PropertiesCount(expr->properties_count()),
1598 expr->ComputeFlags()); 1598 expr->ComputeFlags());
1599 // If constant properties is an empty fixed array, use our cached 1599 // If constant properties is an empty fixed array, use our cached
1600 // empty_fixed_array to ensure it's only added to the constant pool once. 1600 // empty_fixed_array to ensure it's only added to the constant pool once.
1601 Handle<FixedArray> constant_properties = expr->properties_count() == 0 1601 Handle<FixedArray> constant_properties = expr->properties_count() == 0
1602 ? empty_fixed_array() 1602 ? empty_fixed_array()
1603 : expr->constant_properties(); 1603 : expr->constant_properties();
1604 Register literal = register_allocator()->NewRegister(); 1604 Register literal = register_allocator()->NewRegister();
1605 builder()->CreateObjectLiteral(constant_properties, expr->literal_index(), 1605 builder()->CreateObjectLiteral(constant_properties, expr->literal_index(),
1606 flags, literal); 1606 flags, literal);
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1762 UNREACHABLE(); // Handled specially above. 1762 UNREACHABLE(); // Handled specially above.
1763 break; 1763 break;
1764 } 1764 }
1765 } 1765 }
1766 1766
1767 builder()->LoadAccumulatorWithRegister(literal); 1767 builder()->LoadAccumulatorWithRegister(literal);
1768 } 1768 }
1769 1769
1770 void BytecodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { 1770 void BytecodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
1771 // Deep-copy the literal boilerplate. 1771 // Deep-copy the literal boilerplate.
1772 int runtime_flags = expr->ComputeFlags(); 1772 uint8_t flags = CreateArrayLiteralFlags::Encode(
1773 bool use_fast_shallow_clone = 1773 expr->IsFastCloningSupported(), expr->ComputeFlags());
1774 (runtime_flags & ArrayLiteral::kShallowElements) != 0 &&
1775 expr->values()->length() <= JSArray::kInitialMaxFastElementArray;
1776 uint8_t flags =
1777 CreateArrayLiteralFlags::Encode(use_fast_shallow_clone, runtime_flags);
1778 builder()->CreateArrayLiteral(expr->constant_elements(), 1774 builder()->CreateArrayLiteral(expr->constant_elements(),
1779 expr->literal_index(), flags); 1775 expr->literal_index(), flags);
1780 Register index, literal; 1776 Register index, literal;
1781 1777
1782 // Evaluate all the non-constant subexpressions and store them into the 1778 // Evaluate all the non-constant subexpressions and store them into the
1783 // newly cloned array. 1779 // newly cloned array.
1784 bool literal_in_accumulator = true; 1780 bool literal_in_accumulator = true;
1785 for (int array_index = 0; array_index < expr->values()->length(); 1781 for (int array_index = 0; array_index < expr->values()->length();
1786 array_index++) { 1782 array_index++) {
1787 Expression* subexpr = expr->values()->at(array_index); 1783 Expression* subexpr = expr->values()->at(array_index);
(...skipping 1472 matching lines...) Expand 10 before | Expand all | Expand 10 after
3260 } 3256 }
3261 3257
3262 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { 3258 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() {
3263 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict 3259 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict
3264 : Runtime::kStoreKeyedToSuper_Sloppy; 3260 : Runtime::kStoreKeyedToSuper_Sloppy;
3265 } 3261 }
3266 3262
3267 } // namespace interpreter 3263 } // namespace interpreter
3268 } // namespace internal 3264 } // namespace internal
3269 } // namespace v8 3265 } // namespace v8
OLDNEW
« no previous file with comments | « src/full-codegen/full-codegen.cc ('k') | test/mjsunit/regress/regress-crbug-672792.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698