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

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

Issue 2606833002: [ESnext] Implement Object spread (Closed)
Patch Set: fix build 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
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 1606 matching lines...) Expand 10 before | Expand all | Expand 10 after
1617 int property_index = 0; 1617 int property_index = 0;
1618 AccessorTable accessor_table(zone()); 1618 AccessorTable accessor_table(zone());
1619 for (; property_index < expr->properties()->length(); property_index++) { 1619 for (; property_index < expr->properties()->length(); property_index++) {
1620 ObjectLiteral::Property* property = expr->properties()->at(property_index); 1620 ObjectLiteral::Property* property = expr->properties()->at(property_index);
1621 if (property->is_computed_name()) break; 1621 if (property->is_computed_name()) break;
1622 if (property->IsCompileTimeValue()) continue; 1622 if (property->IsCompileTimeValue()) continue;
1623 1623
1624 RegisterAllocationScope inner_register_scope(this); 1624 RegisterAllocationScope inner_register_scope(this);
1625 Literal* key = property->key()->AsLiteral(); 1625 Literal* key = property->key()->AsLiteral();
1626 switch (property->kind()) { 1626 switch (property->kind()) {
1627 case ObjectLiteral::Property::SPREAD:
1627 case ObjectLiteral::Property::CONSTANT: 1628 case ObjectLiteral::Property::CONSTANT:
1628 UNREACHABLE(); 1629 UNREACHABLE();
1629 case ObjectLiteral::Property::MATERIALIZED_LITERAL: 1630 case ObjectLiteral::Property::MATERIALIZED_LITERAL:
1630 DCHECK(!CompileTimeValue::IsCompileTimeValue(property->value())); 1631 DCHECK(!CompileTimeValue::IsCompileTimeValue(property->value()));
1631 // Fall through. 1632 // Fall through.
1632 case ObjectLiteral::Property::COMPUTED: { 1633 case ObjectLiteral::Property::COMPUTED: {
1633 // It is safe to use [[Put]] here because the boilerplate already 1634 // It is safe to use [[Put]] here because the boilerplate already
1634 // contains computed properties with an uninitialized value. 1635 // contains computed properties with an uninitialized value.
1635 if (key->IsStringLiteral()) { 1636 if (key->IsStringLiteral()) {
1636 DCHECK(key->IsPropertyName()); 1637 DCHECK(key->IsPropertyName());
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1760 builder() 1761 builder()
1761 ->LoadLiteral(Smi::FromInt(NONE)) 1762 ->LoadLiteral(Smi::FromInt(NONE))
1762 .StoreAccumulatorInRegister(args[3]); 1763 .StoreAccumulatorInRegister(args[3]);
1763 Runtime::FunctionId function_id = 1764 Runtime::FunctionId function_id =
1764 property->kind() == ObjectLiteral::Property::GETTER 1765 property->kind() == ObjectLiteral::Property::GETTER
1765 ? Runtime::kDefineGetterPropertyUnchecked 1766 ? Runtime::kDefineGetterPropertyUnchecked
1766 : Runtime::kDefineSetterPropertyUnchecked; 1767 : Runtime::kDefineSetterPropertyUnchecked;
1767 builder()->CallRuntime(function_id, args); 1768 builder()->CallRuntime(function_id, args);
1768 break; 1769 break;
1769 } 1770 }
1771 case ObjectLiteral::Property::SPREAD: {
1772 RegisterList args = register_allocator()->NewRegisterList(2);
1773 builder()->MoveRegister(literal, args[0]);
1774 VisitForRegisterValue(property->value(), args[1]);
1775 builder()->CallRuntime(Runtime::kCopyDataProperties, args);
1776 break;
1777 }
1770 case ObjectLiteral::Property::PROTOTYPE: 1778 case ObjectLiteral::Property::PROTOTYPE:
1771 UNREACHABLE(); // Handled specially above. 1779 UNREACHABLE(); // Handled specially above.
1772 break; 1780 break;
1773 } 1781 }
1774 } 1782 }
1775 1783
1776 builder()->LoadAccumulatorWithRegister(literal); 1784 builder()->LoadAccumulatorWithRegister(literal);
1777 } 1785 }
1778 1786
1779 void BytecodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { 1787 void BytecodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
(...skipping 1526 matching lines...) Expand 10 before | Expand all | Expand 10 after
3306 } 3314 }
3307 3315
3308 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { 3316 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() {
3309 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict 3317 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict
3310 : Runtime::kStoreKeyedToSuper_Sloppy; 3318 : Runtime::kStoreKeyedToSuper_Sloppy;
3311 } 3319 }
3312 3320
3313 } // namespace interpreter 3321 } // namespace interpreter
3314 } // namespace internal 3322 } // namespace internal
3315 } // namespace v8 3323 } // namespace v8
OLDNEW
« no previous file with comments | « src/full-codegen/x87/full-codegen-x87.cc ('k') | src/objects.h » ('j') | src/objects.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698