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

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

Issue 2606833002: [ESnext] Implement Object spread (Closed)
Patch Set: fix test Created 3 years, 11 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
« no previous file with comments | « src/full-codegen/x87/full-codegen-x87.cc ('k') | src/objects.h » ('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/builtins/builtins-constructor.h" 9 #include "src/builtins/builtins-constructor.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 1617 matching lines...) Expand 10 before | Expand all | Expand 10 after
1628 int property_index = 0; 1628 int property_index = 0;
1629 AccessorTable accessor_table(zone()); 1629 AccessorTable accessor_table(zone());
1630 for (; property_index < expr->properties()->length(); property_index++) { 1630 for (; property_index < expr->properties()->length(); property_index++) {
1631 ObjectLiteral::Property* property = expr->properties()->at(property_index); 1631 ObjectLiteral::Property* property = expr->properties()->at(property_index);
1632 if (property->is_computed_name()) break; 1632 if (property->is_computed_name()) break;
1633 if (property->IsCompileTimeValue()) continue; 1633 if (property->IsCompileTimeValue()) continue;
1634 1634
1635 RegisterAllocationScope inner_register_scope(this); 1635 RegisterAllocationScope inner_register_scope(this);
1636 Literal* key = property->key()->AsLiteral(); 1636 Literal* key = property->key()->AsLiteral();
1637 switch (property->kind()) { 1637 switch (property->kind()) {
1638 case ObjectLiteral::Property::SPREAD:
1638 case ObjectLiteral::Property::CONSTANT: 1639 case ObjectLiteral::Property::CONSTANT:
1639 UNREACHABLE(); 1640 UNREACHABLE();
1640 case ObjectLiteral::Property::MATERIALIZED_LITERAL: 1641 case ObjectLiteral::Property::MATERIALIZED_LITERAL:
1641 DCHECK(!CompileTimeValue::IsCompileTimeValue(property->value())); 1642 DCHECK(!CompileTimeValue::IsCompileTimeValue(property->value()));
1642 // Fall through. 1643 // Fall through.
1643 case ObjectLiteral::Property::COMPUTED: { 1644 case ObjectLiteral::Property::COMPUTED: {
1644 // It is safe to use [[Put]] here because the boilerplate already 1645 // It is safe to use [[Put]] here because the boilerplate already
1645 // contains computed properties with an uninitialized value. 1646 // contains computed properties with an uninitialized value.
1646 if (key->IsStringLiteral()) { 1647 if (key->IsStringLiteral()) {
1647 DCHECK(key->IsPropertyName()); 1648 DCHECK(key->IsPropertyName());
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1776 builder() 1777 builder()
1777 ->LoadLiteral(Smi::FromInt(NONE)) 1778 ->LoadLiteral(Smi::FromInt(NONE))
1778 .StoreAccumulatorInRegister(args[3]); 1779 .StoreAccumulatorInRegister(args[3]);
1779 Runtime::FunctionId function_id = 1780 Runtime::FunctionId function_id =
1780 property->kind() == ObjectLiteral::Property::GETTER 1781 property->kind() == ObjectLiteral::Property::GETTER
1781 ? Runtime::kDefineGetterPropertyUnchecked 1782 ? Runtime::kDefineGetterPropertyUnchecked
1782 : Runtime::kDefineSetterPropertyUnchecked; 1783 : Runtime::kDefineSetterPropertyUnchecked;
1783 builder()->CallRuntime(function_id, args); 1784 builder()->CallRuntime(function_id, args);
1784 break; 1785 break;
1785 } 1786 }
1787 case ObjectLiteral::Property::SPREAD: {
1788 RegisterList args = register_allocator()->NewRegisterList(2);
1789 builder()->MoveRegister(literal, args[0]);
1790 VisitForRegisterValue(property->value(), args[1]);
1791 builder()->CallRuntime(Runtime::kCopyDataProperties, args);
1792 break;
1793 }
1786 case ObjectLiteral::Property::PROTOTYPE: 1794 case ObjectLiteral::Property::PROTOTYPE:
1787 UNREACHABLE(); // Handled specially above. 1795 UNREACHABLE(); // Handled specially above.
1788 break; 1796 break;
1789 } 1797 }
1790 } 1798 }
1791 1799
1792 builder()->LoadAccumulatorWithRegister(literal); 1800 builder()->LoadAccumulatorWithRegister(literal);
1793 } 1801 }
1794 1802
1795 void BytecodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { 1803 void BytecodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
(...skipping 1527 matching lines...) Expand 10 before | Expand all | Expand 10 after
3323 } 3331 }
3324 3332
3325 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { 3333 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() {
3326 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict 3334 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict
3327 : Runtime::kStoreKeyedToSuper_Sloppy; 3335 : Runtime::kStoreKeyedToSuper_Sloppy;
3328 } 3336 }
3329 3337
3330 } // namespace interpreter 3338 } // namespace interpreter
3331 } // namespace internal 3339 } // namespace internal
3332 } // namespace v8 3340 } // namespace v8
OLDNEW
« no previous file with comments | « src/full-codegen/x87/full-codegen-x87.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698