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

Side by Side Diff: src/arm64/full-codegen-arm64.cc

Issue 798243004: ES6 computed property names (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Disable test on windows Created 5 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/arm/full-codegen-arm.cc ('k') | src/ast.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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/v8.h" 5 #include "src/v8.h"
6 6
7 #if V8_TARGET_ARCH_ARM64 7 #if V8_TARGET_ARCH_ARM64
8 8
9 #include "src/code-factory.h" 9 #include "src/code-factory.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 1649 matching lines...) Expand 10 before | Expand all | Expand 10 after
1660 // If result_saved is true the result is on top of the stack. If 1660 // If result_saved is true the result is on top of the stack. If
1661 // result_saved is false the result is in x0. 1661 // result_saved is false the result is in x0.
1662 bool result_saved = false; 1662 bool result_saved = false;
1663 1663
1664 // Mark all computed expressions that are bound to a key that 1664 // Mark all computed expressions that are bound to a key that
1665 // is shadowed by a later occurrence of the same key. For the 1665 // is shadowed by a later occurrence of the same key. For the
1666 // marked expressions, no store code is emitted. 1666 // marked expressions, no store code is emitted.
1667 expr->CalculateEmitStore(zone()); 1667 expr->CalculateEmitStore(zone());
1668 1668
1669 AccessorTable accessor_table(zone()); 1669 AccessorTable accessor_table(zone());
1670 for (int i = 0; i < expr->properties()->length(); i++) { 1670 int property_index = 0;
1671 ObjectLiteral::Property* property = expr->properties()->at(i); 1671 for (; property_index < expr->properties()->length(); property_index++) {
1672 ObjectLiteral::Property* property = expr->properties()->at(property_index);
1673 if (property->is_computed_name()) break;
1672 if (property->IsCompileTimeValue()) continue; 1674 if (property->IsCompileTimeValue()) continue;
1673 1675
1674 Literal* key = property->key(); 1676 Literal* key = property->key()->AsLiteral();
1675 Expression* value = property->value(); 1677 Expression* value = property->value();
1676 if (!result_saved) { 1678 if (!result_saved) {
1677 __ Push(x0); // Save result on stack 1679 __ Push(x0); // Save result on stack
1678 result_saved = true; 1680 result_saved = true;
1679 } 1681 }
1680 switch (property->kind()) { 1682 switch (property->kind()) {
1681 case ObjectLiteral::Property::CONSTANT: 1683 case ObjectLiteral::Property::CONSTANT:
1682 UNREACHABLE(); 1684 UNREACHABLE();
1683 case ObjectLiteral::Property::MATERIALIZED_LITERAL: 1685 case ObjectLiteral::Property::MATERIALIZED_LITERAL:
1684 DCHECK(!CompileTimeValue::IsCompileTimeValue(property->value())); 1686 DCHECK(!CompileTimeValue::IsCompileTimeValue(property->value()));
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1752 VisitForStackValue(it->first); 1754 VisitForStackValue(it->first);
1753 EmitAccessor(it->second->getter); 1755 EmitAccessor(it->second->getter);
1754 EmitSetHomeObjectIfNeeded(it->second->getter, 2); 1756 EmitSetHomeObjectIfNeeded(it->second->getter, 2);
1755 EmitAccessor(it->second->setter); 1757 EmitAccessor(it->second->setter);
1756 EmitSetHomeObjectIfNeeded(it->second->setter, 3); 1758 EmitSetHomeObjectIfNeeded(it->second->setter, 3);
1757 __ Mov(x10, Smi::FromInt(NONE)); 1759 __ Mov(x10, Smi::FromInt(NONE));
1758 __ Push(x10); 1760 __ Push(x10);
1759 __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5); 1761 __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5);
1760 } 1762 }
1761 1763
1764 // Object literals have two parts. The "static" part on the left contains no
1765 // computed property names, and so we can compute its map ahead of time; see
1766 // runtime.cc::CreateObjectLiteralBoilerplate. The second "dynamic" part
1767 // starts with the first computed property name, and continues with all
1768 // properties to its right. All the code from above initializes the static
1769 // component of the object literal, and arranges for the map of the result to
1770 // reflect the static order in which the keys appear. For the dynamic
1771 // properties, we compile them into a series of "SetOwnProperty" runtime
1772 // calls. This will preserve insertion order.
1773 for (; property_index < expr->properties()->length(); property_index++) {
1774 ObjectLiteral::Property* property = expr->properties()->at(property_index);
1775
1776 Expression* value = property->value();
1777 if (!result_saved) {
1778 __ Push(x0); // Save result on stack
1779 result_saved = true;
1780 }
1781
1782 __ Peek(x10, 0); // Duplicate receiver.
1783 __ Push(x10);
1784
1785 if (property->kind() == ObjectLiteral::Property::PROTOTYPE) {
1786 DCHECK(!property->is_computed_name());
1787 VisitForStackValue(value);
1788 if (property->emit_store()) {
1789 __ CallRuntime(Runtime::kInternalSetPrototype, 2);
1790 } else {
1791 __ Drop(2);
1792 }
1793 } else {
1794 EmitPropertyKey(property);
1795 VisitForStackValue(value);
1796
1797 switch (property->kind()) {
1798 case ObjectLiteral::Property::CONSTANT:
1799 case ObjectLiteral::Property::MATERIALIZED_LITERAL:
1800 case ObjectLiteral::Property::COMPUTED:
1801 if (property->emit_store()) {
1802 __ Mov(x0, Smi::FromInt(NONE));
1803 __ Push(x0);
1804 __ CallRuntime(Runtime::kDefineDataPropertyUnchecked, 4);
1805 } else {
1806 __ Drop(3);
1807 }
1808 break;
1809
1810 case ObjectLiteral::Property::PROTOTYPE:
1811 UNREACHABLE();
1812 break;
1813
1814 case ObjectLiteral::Property::GETTER:
1815 __ CallRuntime(Runtime::kDefineGetterPropertyUnchecked, 3);
1816 break;
1817
1818 case ObjectLiteral::Property::SETTER:
1819 __ CallRuntime(Runtime::kDefineSetterPropertyUnchecked, 3);
1820 break;
1821 }
1822 }
1823 }
1824
1762 if (expr->has_function()) { 1825 if (expr->has_function()) {
1763 DCHECK(result_saved); 1826 DCHECK(result_saved);
1764 __ Peek(x0, 0); 1827 __ Peek(x0, 0);
1765 __ Push(x0); 1828 __ Push(x0);
1766 __ CallRuntime(Runtime::kToFastProperties, 1); 1829 __ CallRuntime(Runtime::kToFastProperties, 1);
1767 } 1830 }
1768 1831
1769 if (result_saved) { 1832 if (result_saved) {
1770 context()->PlugTOS(); 1833 context()->PlugTOS();
1771 } else { 1834 } else {
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
2168 2231
2169 // No access check is needed here since the constructor is created by the 2232 // No access check is needed here since the constructor is created by the
2170 // class literal. 2233 // class literal.
2171 Register scratch = x1; 2234 Register scratch = x1;
2172 __ Ldr(scratch, 2235 __ Ldr(scratch,
2173 FieldMemOperand(x0, JSFunction::kPrototypeOrInitialMapOffset)); 2236 FieldMemOperand(x0, JSFunction::kPrototypeOrInitialMapOffset));
2174 __ Push(scratch); 2237 __ Push(scratch);
2175 2238
2176 for (int i = 0; i < lit->properties()->length(); i++) { 2239 for (int i = 0; i < lit->properties()->length(); i++) {
2177 ObjectLiteral::Property* property = lit->properties()->at(i); 2240 ObjectLiteral::Property* property = lit->properties()->at(i);
2178 Literal* key = property->key()->AsLiteral();
2179 Expression* value = property->value(); 2241 Expression* value = property->value();
2180 DCHECK(key != NULL);
2181 2242
2182 if (property->is_static()) { 2243 if (property->is_static()) {
2183 __ Peek(scratch, kPointerSize); // constructor 2244 __ Peek(scratch, kPointerSize); // constructor
2184 } else { 2245 } else {
2185 __ Peek(scratch, 0); // prototype 2246 __ Peek(scratch, 0); // prototype
2186 } 2247 }
2187 __ Push(scratch); 2248 __ Push(scratch);
2188 VisitForStackValue(key); 2249 EmitPropertyKey(property);
2189 VisitForStackValue(value); 2250 VisitForStackValue(value);
2190 EmitSetHomeObjectIfNeeded(value, 2); 2251 EmitSetHomeObjectIfNeeded(value, 2);
2191 2252
2192 switch (property->kind()) { 2253 switch (property->kind()) {
2193 case ObjectLiteral::Property::CONSTANT: 2254 case ObjectLiteral::Property::CONSTANT:
2194 case ObjectLiteral::Property::MATERIALIZED_LITERAL: 2255 case ObjectLiteral::Property::MATERIALIZED_LITERAL:
2195 case ObjectLiteral::Property::COMPUTED: 2256 case ObjectLiteral::Property::COMPUTED:
2196 case ObjectLiteral::Property::PROTOTYPE: 2257 case ObjectLiteral::Property::PROTOTYPE:
2197 __ CallRuntime(Runtime::kDefineClassMethod, 3); 2258 __ CallRuntime(Runtime::kDefineClassMethod, 3);
2198 break; 2259 break;
2199 2260
2200 case ObjectLiteral::Property::GETTER: 2261 case ObjectLiteral::Property::GETTER:
2201 __ CallRuntime(Runtime::kDefineClassGetter, 3); 2262 __ CallRuntime(Runtime::kDefineGetterPropertyUnchecked, 3);
2202 break; 2263 break;
2203 2264
2204 case ObjectLiteral::Property::SETTER: 2265 case ObjectLiteral::Property::SETTER:
2205 __ CallRuntime(Runtime::kDefineClassSetter, 3); 2266 __ CallRuntime(Runtime::kDefineSetterPropertyUnchecked, 3);
2206 break; 2267 break;
2207 2268
2208 default: 2269 default:
2209 UNREACHABLE(); 2270 UNREACHABLE();
2210 } 2271 }
2211 } 2272 }
2212 2273
2213 // prototype 2274 // prototype
2214 __ CallRuntime(Runtime::kToFastProperties, 1); 2275 __ CallRuntime(Runtime::kToFastProperties, 1);
2215 2276
(...skipping 3064 matching lines...) Expand 10 before | Expand all | Expand 10 after
5280 return previous_; 5341 return previous_;
5281 } 5342 }
5282 5343
5283 5344
5284 #undef __ 5345 #undef __
5285 5346
5286 5347
5287 } } // namespace v8::internal 5348 } } // namespace v8::internal
5288 5349
5289 #endif // V8_TARGET_ARCH_ARM64 5350 #endif // V8_TARGET_ARCH_ARM64
OLDNEW
« no previous file with comments | « src/arm/full-codegen-arm.cc ('k') | src/ast.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698