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

Side by Side Diff: src/x64/full-codegen-x64.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/typing.cc ('k') | test/cctest/test-parsing.cc » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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_X64 7 #if V8_TARGET_ARCH_X64
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 1633 matching lines...) Expand 10 before | Expand all | Expand 10 after
1644 // If result_saved is true the result is on top of the stack. If 1644 // If result_saved is true the result is on top of the stack. If
1645 // result_saved is false the result is in rax. 1645 // result_saved is false the result is in rax.
1646 bool result_saved = false; 1646 bool result_saved = false;
1647 1647
1648 // Mark all computed expressions that are bound to a key that 1648 // Mark all computed expressions that are bound to a key that
1649 // is shadowed by a later occurrence of the same key. For the 1649 // is shadowed by a later occurrence of the same key. For the
1650 // marked expressions, no store code is emitted. 1650 // marked expressions, no store code is emitted.
1651 expr->CalculateEmitStore(zone()); 1651 expr->CalculateEmitStore(zone());
1652 1652
1653 AccessorTable accessor_table(zone()); 1653 AccessorTable accessor_table(zone());
1654 for (int i = 0; i < expr->properties()->length(); i++) { 1654 int property_index = 0;
1655 ObjectLiteral::Property* property = expr->properties()->at(i); 1655 for (; property_index < expr->properties()->length(); property_index++) {
1656 ObjectLiteral::Property* property = expr->properties()->at(property_index);
1657 if (property->is_computed_name()) break;
1656 if (property->IsCompileTimeValue()) continue; 1658 if (property->IsCompileTimeValue()) continue;
1657 1659
1658 Literal* key = property->key(); 1660 Literal* key = property->key()->AsLiteral();
1659 Expression* value = property->value(); 1661 Expression* value = property->value();
1660 if (!result_saved) { 1662 if (!result_saved) {
1661 __ Push(rax); // Save result on the stack 1663 __ Push(rax); // Save result on the stack
1662 result_saved = true; 1664 result_saved = true;
1663 } 1665 }
1664 switch (property->kind()) { 1666 switch (property->kind()) {
1665 case ObjectLiteral::Property::CONSTANT: 1667 case ObjectLiteral::Property::CONSTANT:
1666 UNREACHABLE(); 1668 UNREACHABLE();
1667 case ObjectLiteral::Property::MATERIALIZED_LITERAL: 1669 case ObjectLiteral::Property::MATERIALIZED_LITERAL:
1668 DCHECK(!CompileTimeValue::IsCompileTimeValue(value)); 1670 DCHECK(!CompileTimeValue::IsCompileTimeValue(value));
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1728 __ Push(Operand(rsp, 0)); // Duplicate receiver. 1730 __ Push(Operand(rsp, 0)); // Duplicate receiver.
1729 VisitForStackValue(it->first); 1731 VisitForStackValue(it->first);
1730 EmitAccessor(it->second->getter); 1732 EmitAccessor(it->second->getter);
1731 EmitSetHomeObjectIfNeeded(it->second->getter, 2); 1733 EmitSetHomeObjectIfNeeded(it->second->getter, 2);
1732 EmitAccessor(it->second->setter); 1734 EmitAccessor(it->second->setter);
1733 EmitSetHomeObjectIfNeeded(it->second->setter, 3); 1735 EmitSetHomeObjectIfNeeded(it->second->setter, 3);
1734 __ Push(Smi::FromInt(NONE)); 1736 __ Push(Smi::FromInt(NONE));
1735 __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5); 1737 __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5);
1736 } 1738 }
1737 1739
1740 // Object literals have two parts. The "static" part on the left contains no
1741 // computed property names, and so we can compute its map ahead of time; see
1742 // runtime.cc::CreateObjectLiteralBoilerplate. The second "dynamic" part
1743 // starts with the first computed property name, and continues with all
1744 // properties to its right. All the code from above initializes the static
1745 // component of the object literal, and arranges for the map of the result to
1746 // reflect the static order in which the keys appear. For the dynamic
1747 // properties, we compile them into a series of "SetOwnProperty" runtime
1748 // calls. This will preserve insertion order.
1749 for (; property_index < expr->properties()->length(); property_index++) {
1750 ObjectLiteral::Property* property = expr->properties()->at(property_index);
1751
1752 Expression* value = property->value();
1753 if (!result_saved) {
1754 __ Push(rax); // Save result on the stack
1755 result_saved = true;
1756 }
1757
1758 __ Push(Operand(rsp, 0)); // Duplicate receiver.
1759
1760 if (property->kind() == ObjectLiteral::Property::PROTOTYPE) {
1761 DCHECK(!property->is_computed_name());
1762 VisitForStackValue(value);
1763 if (property->emit_store()) {
1764 __ CallRuntime(Runtime::kInternalSetPrototype, 2);
1765 } else {
1766 __ Drop(2);
1767 }
1768 } else {
1769 EmitPropertyKey(property);
1770 VisitForStackValue(value);
1771
1772 switch (property->kind()) {
1773 case ObjectLiteral::Property::CONSTANT:
1774 case ObjectLiteral::Property::MATERIALIZED_LITERAL:
1775 case ObjectLiteral::Property::COMPUTED:
1776 if (property->emit_store()) {
1777 __ Push(Smi::FromInt(NONE));
1778 __ CallRuntime(Runtime::kDefineDataPropertyUnchecked, 4);
1779 } else {
1780 __ Drop(3);
1781 }
1782 break;
1783
1784 case ObjectLiteral::Property::PROTOTYPE:
1785 UNREACHABLE();
1786 break;
1787
1788 case ObjectLiteral::Property::GETTER:
1789 __ CallRuntime(Runtime::kDefineGetterPropertyUnchecked, 3);
1790 break;
1791
1792 case ObjectLiteral::Property::SETTER:
1793 __ CallRuntime(Runtime::kDefineSetterPropertyUnchecked, 3);
1794 break;
1795 }
1796 }
1797 }
1798
1738 if (expr->has_function()) { 1799 if (expr->has_function()) {
1739 DCHECK(result_saved); 1800 DCHECK(result_saved);
1740 __ Push(Operand(rsp, 0)); 1801 __ Push(Operand(rsp, 0));
1741 __ CallRuntime(Runtime::kToFastProperties, 1); 1802 __ CallRuntime(Runtime::kToFastProperties, 1);
1742 } 1803 }
1743 1804
1744 if (result_saved) { 1805 if (result_saved) {
1745 context()->PlugTOS(); 1806 context()->PlugTOS();
1746 } else { 1807 } else {
1747 context()->Plug(rax); 1808 context()->Plug(rax);
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
2386 __ Push(rax); 2447 __ Push(rax);
2387 2448
2388 // No access check is needed here since the constructor is created by the 2449 // No access check is needed here since the constructor is created by the
2389 // class literal. 2450 // class literal.
2390 Register scratch = rbx; 2451 Register scratch = rbx;
2391 __ movp(scratch, FieldOperand(rax, JSFunction::kPrototypeOrInitialMapOffset)); 2452 __ movp(scratch, FieldOperand(rax, JSFunction::kPrototypeOrInitialMapOffset));
2392 __ Push(scratch); 2453 __ Push(scratch);
2393 2454
2394 for (int i = 0; i < lit->properties()->length(); i++) { 2455 for (int i = 0; i < lit->properties()->length(); i++) {
2395 ObjectLiteral::Property* property = lit->properties()->at(i); 2456 ObjectLiteral::Property* property = lit->properties()->at(i);
2396 Literal* key = property->key()->AsLiteral();
2397 Expression* value = property->value(); 2457 Expression* value = property->value();
2398 DCHECK(key != NULL);
2399 2458
2400 if (property->is_static()) { 2459 if (property->is_static()) {
2401 __ Push(Operand(rsp, kPointerSize)); // constructor 2460 __ Push(Operand(rsp, kPointerSize)); // constructor
2402 } else { 2461 } else {
2403 __ Push(Operand(rsp, 0)); // prototype 2462 __ Push(Operand(rsp, 0)); // prototype
2404 } 2463 }
2405 VisitForStackValue(key); 2464 EmitPropertyKey(property);
2406 VisitForStackValue(value); 2465 VisitForStackValue(value);
2407 EmitSetHomeObjectIfNeeded(value, 2); 2466 EmitSetHomeObjectIfNeeded(value, 2);
2408 2467
2409 switch (property->kind()) { 2468 switch (property->kind()) {
2410 case ObjectLiteral::Property::CONSTANT: 2469 case ObjectLiteral::Property::CONSTANT:
2411 case ObjectLiteral::Property::MATERIALIZED_LITERAL: 2470 case ObjectLiteral::Property::MATERIALIZED_LITERAL:
2412 case ObjectLiteral::Property::COMPUTED: 2471 case ObjectLiteral::Property::COMPUTED:
2413 case ObjectLiteral::Property::PROTOTYPE: 2472 case ObjectLiteral::Property::PROTOTYPE:
2414 __ CallRuntime(Runtime::kDefineClassMethod, 3); 2473 __ CallRuntime(Runtime::kDefineClassMethod, 3);
2415 break; 2474 break;
2416 2475
2417 case ObjectLiteral::Property::GETTER: 2476 case ObjectLiteral::Property::GETTER:
2418 __ CallRuntime(Runtime::kDefineClassGetter, 3); 2477 __ CallRuntime(Runtime::kDefineGetterPropertyUnchecked, 3);
2419 break; 2478 break;
2420 2479
2421 case ObjectLiteral::Property::SETTER: 2480 case ObjectLiteral::Property::SETTER:
2422 __ CallRuntime(Runtime::kDefineClassSetter, 3); 2481 __ CallRuntime(Runtime::kDefineSetterPropertyUnchecked, 3);
2423 break; 2482 break;
2424 2483
2425 default: 2484 default:
2426 UNREACHABLE(); 2485 UNREACHABLE();
2427 } 2486 }
2428 } 2487 }
2429 2488
2430 // prototype 2489 // prototype
2431 __ CallRuntime(Runtime::kToFastProperties, 1); 2490 __ CallRuntime(Runtime::kToFastProperties, 1);
2432 2491
(...skipping 2761 matching lines...) Expand 10 before | Expand all | Expand 10 after
5194 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 5253 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
5195 Assembler::target_address_at(call_target_address, 5254 Assembler::target_address_at(call_target_address,
5196 unoptimized_code)); 5255 unoptimized_code));
5197 return OSR_AFTER_STACK_CHECK; 5256 return OSR_AFTER_STACK_CHECK;
5198 } 5257 }
5199 5258
5200 5259
5201 } } // namespace v8::internal 5260 } } // namespace v8::internal
5202 5261
5203 #endif // V8_TARGET_ARCH_X64 5262 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/typing.cc ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698