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

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

Issue 807033003: Revert of ES6 computed property names (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 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/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 int property_index = 0; 1670 for (int i = 0; i < expr->properties()->length(); i++) {
1671 for (; property_index < expr->properties()->length(); property_index++) { 1671 ObjectLiteral::Property* property = expr->properties()->at(i);
1672 ObjectLiteral::Property* property = expr->properties()->at(property_index);
1673 if (property->is_computed_name()) break;
1674 if (property->IsCompileTimeValue()) continue; 1672 if (property->IsCompileTimeValue()) continue;
1675 1673
1676 Literal* key = property->key()->AsLiteral(); 1674 Literal* key = property->key();
1677 Expression* value = property->value(); 1675 Expression* value = property->value();
1678 if (!result_saved) { 1676 if (!result_saved) {
1679 __ Push(x0); // Save result on stack 1677 __ Push(x0); // Save result on stack
1680 result_saved = true; 1678 result_saved = true;
1681 } 1679 }
1682 switch (property->kind()) { 1680 switch (property->kind()) {
1683 case ObjectLiteral::Property::CONSTANT: 1681 case ObjectLiteral::Property::CONSTANT:
1684 UNREACHABLE(); 1682 UNREACHABLE();
1685 case ObjectLiteral::Property::MATERIALIZED_LITERAL: 1683 case ObjectLiteral::Property::MATERIALIZED_LITERAL:
1686 DCHECK(!CompileTimeValue::IsCompileTimeValue(property->value())); 1684 DCHECK(!CompileTimeValue::IsCompileTimeValue(property->value()));
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1754 VisitForStackValue(it->first); 1752 VisitForStackValue(it->first);
1755 EmitAccessor(it->second->getter); 1753 EmitAccessor(it->second->getter);
1756 EmitSetHomeObjectIfNeeded(it->second->getter, 2); 1754 EmitSetHomeObjectIfNeeded(it->second->getter, 2);
1757 EmitAccessor(it->second->setter); 1755 EmitAccessor(it->second->setter);
1758 EmitSetHomeObjectIfNeeded(it->second->setter, 3); 1756 EmitSetHomeObjectIfNeeded(it->second->setter, 3);
1759 __ Mov(x10, Smi::FromInt(NONE)); 1757 __ Mov(x10, Smi::FromInt(NONE));
1760 __ Push(x10); 1758 __ Push(x10);
1761 __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5); 1759 __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5);
1762 } 1760 }
1763 1761
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
1825 if (expr->has_function()) { 1762 if (expr->has_function()) {
1826 DCHECK(result_saved); 1763 DCHECK(result_saved);
1827 __ Peek(x0, 0); 1764 __ Peek(x0, 0);
1828 __ Push(x0); 1765 __ Push(x0);
1829 __ CallRuntime(Runtime::kToFastProperties, 1); 1766 __ CallRuntime(Runtime::kToFastProperties, 1);
1830 } 1767 }
1831 1768
1832 if (result_saved) { 1769 if (result_saved) {
1833 context()->PlugTOS(); 1770 context()->PlugTOS();
1834 } else { 1771 } else {
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
2231 2168
2232 // No access check is needed here since the constructor is created by the 2169 // No access check is needed here since the constructor is created by the
2233 // class literal. 2170 // class literal.
2234 Register scratch = x1; 2171 Register scratch = x1;
2235 __ Ldr(scratch, 2172 __ Ldr(scratch,
2236 FieldMemOperand(x0, JSFunction::kPrototypeOrInitialMapOffset)); 2173 FieldMemOperand(x0, JSFunction::kPrototypeOrInitialMapOffset));
2237 __ Push(scratch); 2174 __ Push(scratch);
2238 2175
2239 for (int i = 0; i < lit->properties()->length(); i++) { 2176 for (int i = 0; i < lit->properties()->length(); i++) {
2240 ObjectLiteral::Property* property = lit->properties()->at(i); 2177 ObjectLiteral::Property* property = lit->properties()->at(i);
2178 Literal* key = property->key()->AsLiteral();
2241 Expression* value = property->value(); 2179 Expression* value = property->value();
2180 DCHECK(key != NULL);
2242 2181
2243 if (property->is_static()) { 2182 if (property->is_static()) {
2244 __ Peek(scratch, kPointerSize); // constructor 2183 __ Peek(scratch, kPointerSize); // constructor
2245 } else { 2184 } else {
2246 __ Peek(scratch, 0); // prototype 2185 __ Peek(scratch, 0); // prototype
2247 } 2186 }
2248 __ Push(scratch); 2187 __ Push(scratch);
2249 EmitPropertyKey(property); 2188 VisitForStackValue(key);
2250 VisitForStackValue(value); 2189 VisitForStackValue(value);
2251 EmitSetHomeObjectIfNeeded(value, 2); 2190 EmitSetHomeObjectIfNeeded(value, 2);
2252 2191
2253 switch (property->kind()) { 2192 switch (property->kind()) {
2254 case ObjectLiteral::Property::CONSTANT: 2193 case ObjectLiteral::Property::CONSTANT:
2255 case ObjectLiteral::Property::MATERIALIZED_LITERAL: 2194 case ObjectLiteral::Property::MATERIALIZED_LITERAL:
2256 case ObjectLiteral::Property::COMPUTED: 2195 case ObjectLiteral::Property::COMPUTED:
2257 case ObjectLiteral::Property::PROTOTYPE: 2196 case ObjectLiteral::Property::PROTOTYPE:
2258 __ CallRuntime(Runtime::kDefineClassMethod, 3); 2197 __ CallRuntime(Runtime::kDefineClassMethod, 3);
2259 break; 2198 break;
2260 2199
2261 case ObjectLiteral::Property::GETTER: 2200 case ObjectLiteral::Property::GETTER:
2262 __ CallRuntime(Runtime::kDefineGetterPropertyUnchecked, 3); 2201 __ CallRuntime(Runtime::kDefineClassGetter, 3);
2263 break; 2202 break;
2264 2203
2265 case ObjectLiteral::Property::SETTER: 2204 case ObjectLiteral::Property::SETTER:
2266 __ CallRuntime(Runtime::kDefineSetterPropertyUnchecked, 3); 2205 __ CallRuntime(Runtime::kDefineClassSetter, 3);
2267 break; 2206 break;
2268 2207
2269 default: 2208 default:
2270 UNREACHABLE(); 2209 UNREACHABLE();
2271 } 2210 }
2272 } 2211 }
2273 2212
2274 // prototype 2213 // prototype
2275 __ CallRuntime(Runtime::kToFastProperties, 1); 2214 __ CallRuntime(Runtime::kToFastProperties, 1);
2276 2215
(...skipping 3063 matching lines...) Expand 10 before | Expand all | Expand 10 after
5340 return previous_; 5279 return previous_;
5341 } 5280 }
5342 5281
5343 5282
5344 #undef __ 5283 #undef __
5345 5284
5346 5285
5347 } } // namespace v8::internal 5286 } } // namespace v8::internal
5348 5287
5349 #endif // V8_TARGET_ARCH_ARM64 5288 #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