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

Side by Side Diff: src/ia32/full-codegen-ia32.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/hydrogen.cc ('k') | src/parser.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 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_IA32 7 #if V8_TARGET_ARCH_IA32
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 1599 matching lines...) Expand 10 before | Expand all | Expand 10 after
1610 // If result_saved is true the result is on top of the stack. If 1610 // If result_saved is true the result is on top of the stack. If
1611 // result_saved is false the result is in eax. 1611 // result_saved is false the result is in eax.
1612 bool result_saved = false; 1612 bool result_saved = false;
1613 1613
1614 // Mark all computed expressions that are bound to a key that 1614 // Mark all computed expressions that are bound to a key that
1615 // is shadowed by a later occurrence of the same key. For the 1615 // is shadowed by a later occurrence of the same key. For the
1616 // marked expressions, no store code is emitted. 1616 // marked expressions, no store code is emitted.
1617 expr->CalculateEmitStore(zone()); 1617 expr->CalculateEmitStore(zone());
1618 1618
1619 AccessorTable accessor_table(zone()); 1619 AccessorTable accessor_table(zone());
1620 for (int i = 0; i < expr->properties()->length(); i++) { 1620 int property_index = 0;
1621 ObjectLiteral::Property* property = expr->properties()->at(i); 1621 for (; property_index < expr->properties()->length(); property_index++) {
1622 ObjectLiteral::Property* property = expr->properties()->at(property_index);
1623 if (property->is_computed_name()) break;
1622 if (property->IsCompileTimeValue()) continue; 1624 if (property->IsCompileTimeValue()) continue;
1623 1625
1624 Literal* key = property->key(); 1626 Literal* key = property->key()->AsLiteral();
1625 Expression* value = property->value(); 1627 Expression* value = property->value();
1626 if (!result_saved) { 1628 if (!result_saved) {
1627 __ push(eax); // Save result on the stack 1629 __ push(eax); // Save result on the stack
1628 result_saved = true; 1630 result_saved = true;
1629 } 1631 }
1630 switch (property->kind()) { 1632 switch (property->kind()) {
1631 case ObjectLiteral::Property::CONSTANT: 1633 case ObjectLiteral::Property::CONSTANT:
1632 UNREACHABLE(); 1634 UNREACHABLE();
1633 case ObjectLiteral::Property::MATERIALIZED_LITERAL: 1635 case ObjectLiteral::Property::MATERIALIZED_LITERAL:
1634 DCHECK(!CompileTimeValue::IsCompileTimeValue(value)); 1636 DCHECK(!CompileTimeValue::IsCompileTimeValue(value));
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1694 __ push(Operand(esp, 0)); // Duplicate receiver. 1696 __ push(Operand(esp, 0)); // Duplicate receiver.
1695 VisitForStackValue(it->first); 1697 VisitForStackValue(it->first);
1696 EmitAccessor(it->second->getter); 1698 EmitAccessor(it->second->getter);
1697 EmitSetHomeObjectIfNeeded(it->second->getter, 2); 1699 EmitSetHomeObjectIfNeeded(it->second->getter, 2);
1698 EmitAccessor(it->second->setter); 1700 EmitAccessor(it->second->setter);
1699 EmitSetHomeObjectIfNeeded(it->second->setter, 3); 1701 EmitSetHomeObjectIfNeeded(it->second->setter, 3);
1700 __ push(Immediate(Smi::FromInt(NONE))); 1702 __ push(Immediate(Smi::FromInt(NONE)));
1701 __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5); 1703 __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5);
1702 } 1704 }
1703 1705
1706 // Object literals have two parts. The "static" part on the left contains no
1707 // computed property names, and so we can compute its map ahead of time; see
1708 // runtime.cc::CreateObjectLiteralBoilerplate. The second "dynamic" part
1709 // starts with the first computed property name, and continues with all
1710 // properties to its right. All the code from above initializes the static
1711 // component of the object literal, and arranges for the map of the result to
1712 // reflect the static order in which the keys appear. For the dynamic
1713 // properties, we compile them into a series of "SetOwnProperty" runtime
1714 // calls. This will preserve insertion order.
1715 for (; property_index < expr->properties()->length(); property_index++) {
1716 ObjectLiteral::Property* property = expr->properties()->at(property_index);
1717
1718 Expression* value = property->value();
1719 if (!result_saved) {
1720 __ push(eax); // Save result on the stack
1721 result_saved = true;
1722 }
1723
1724 __ push(Operand(esp, 0)); // Duplicate receiver.
1725
1726 if (property->kind() == ObjectLiteral::Property::PROTOTYPE) {
1727 DCHECK(!property->is_computed_name());
1728 VisitForStackValue(value);
1729 if (property->emit_store()) {
1730 __ CallRuntime(Runtime::kInternalSetPrototype, 2);
1731 } else {
1732 __ Drop(2);
1733 }
1734 } else {
1735 EmitPropertyKey(property);
1736 VisitForStackValue(value);
1737
1738 switch (property->kind()) {
1739 case ObjectLiteral::Property::CONSTANT:
1740 case ObjectLiteral::Property::MATERIALIZED_LITERAL:
1741 case ObjectLiteral::Property::COMPUTED:
1742 if (property->emit_store()) {
1743 __ push(Immediate(Smi::FromInt(NONE)));
1744 __ CallRuntime(Runtime::kDefineDataPropertyUnchecked, 4);
1745 } else {
1746 __ Drop(3);
1747 }
1748 break;
1749
1750 case ObjectLiteral::Property::PROTOTYPE:
1751 UNREACHABLE();
1752 break;
1753
1754 case ObjectLiteral::Property::GETTER:
1755 __ CallRuntime(Runtime::kDefineGetterPropertyUnchecked, 3);
1756 break;
1757
1758 case ObjectLiteral::Property::SETTER:
1759 __ CallRuntime(Runtime::kDefineSetterPropertyUnchecked, 3);
1760 break;
1761 }
1762 }
1763 }
1764
1704 if (expr->has_function()) { 1765 if (expr->has_function()) {
1705 DCHECK(result_saved); 1766 DCHECK(result_saved);
1706 __ push(Operand(esp, 0)); 1767 __ push(Operand(esp, 0));
1707 __ CallRuntime(Runtime::kToFastProperties, 1); 1768 __ CallRuntime(Runtime::kToFastProperties, 1);
1708 } 1769 }
1709 1770
1710 if (result_saved) { 1771 if (result_saved) {
1711 context()->PlugTOS(); 1772 context()->PlugTOS();
1712 } else { 1773 } else {
1713 context()->Plug(eax); 1774 context()->Plug(eax);
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
2387 __ push(eax); 2448 __ push(eax);
2388 2449
2389 // No access check is needed here since the constructor is created by the 2450 // No access check is needed here since the constructor is created by the
2390 // class literal. 2451 // class literal.
2391 Register scratch = ebx; 2452 Register scratch = ebx;
2392 __ mov(scratch, FieldOperand(eax, JSFunction::kPrototypeOrInitialMapOffset)); 2453 __ mov(scratch, FieldOperand(eax, JSFunction::kPrototypeOrInitialMapOffset));
2393 __ Push(scratch); 2454 __ Push(scratch);
2394 2455
2395 for (int i = 0; i < lit->properties()->length(); i++) { 2456 for (int i = 0; i < lit->properties()->length(); i++) {
2396 ObjectLiteral::Property* property = lit->properties()->at(i); 2457 ObjectLiteral::Property* property = lit->properties()->at(i);
2397 Literal* key = property->key()->AsLiteral();
2398 Expression* value = property->value(); 2458 Expression* value = property->value();
2399 DCHECK(key != NULL);
2400 2459
2401 if (property->is_static()) { 2460 if (property->is_static()) {
2402 __ push(Operand(esp, kPointerSize)); // constructor 2461 __ push(Operand(esp, kPointerSize)); // constructor
2403 } else { 2462 } else {
2404 __ push(Operand(esp, 0)); // prototype 2463 __ push(Operand(esp, 0)); // prototype
2405 } 2464 }
2406 VisitForStackValue(key); 2465 EmitPropertyKey(property);
2407 VisitForStackValue(value); 2466 VisitForStackValue(value);
2408 EmitSetHomeObjectIfNeeded(value, 2); 2467 EmitSetHomeObjectIfNeeded(value, 2);
2409 2468
2410 switch (property->kind()) { 2469 switch (property->kind()) {
2411 case ObjectLiteral::Property::CONSTANT: 2470 case ObjectLiteral::Property::CONSTANT:
2412 case ObjectLiteral::Property::MATERIALIZED_LITERAL: 2471 case ObjectLiteral::Property::MATERIALIZED_LITERAL:
2413 case ObjectLiteral::Property::COMPUTED: 2472 case ObjectLiteral::Property::COMPUTED:
2414 case ObjectLiteral::Property::PROTOTYPE: 2473 case ObjectLiteral::Property::PROTOTYPE:
2415 __ CallRuntime(Runtime::kDefineClassMethod, 3); 2474 __ CallRuntime(Runtime::kDefineClassMethod, 3);
2416 break; 2475 break;
2417 2476
2418 case ObjectLiteral::Property::GETTER: 2477 case ObjectLiteral::Property::GETTER:
2419 __ CallRuntime(Runtime::kDefineClassGetter, 3); 2478 __ CallRuntime(Runtime::kDefineGetterPropertyUnchecked, 3);
2420 break; 2479 break;
2421 2480
2422 case ObjectLiteral::Property::SETTER: 2481 case ObjectLiteral::Property::SETTER:
2423 __ CallRuntime(Runtime::kDefineClassSetter, 3); 2482 __ CallRuntime(Runtime::kDefineSetterPropertyUnchecked, 3);
2424 break; 2483 break;
2425 2484
2426 default: 2485 default:
2427 UNREACHABLE(); 2486 UNREACHABLE();
2428 } 2487 }
2429 } 2488 }
2430 2489
2431 // prototype 2490 // prototype
2432 __ CallRuntime(Runtime::kToFastProperties, 1); 2491 __ CallRuntime(Runtime::kToFastProperties, 1);
2433 2492
(...skipping 2743 matching lines...) Expand 10 before | Expand all | Expand 10 after
5177 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 5236 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
5178 Assembler::target_address_at(call_target_address, 5237 Assembler::target_address_at(call_target_address,
5179 unoptimized_code)); 5238 unoptimized_code));
5180 return OSR_AFTER_STACK_CHECK; 5239 return OSR_AFTER_STACK_CHECK;
5181 } 5240 }
5182 5241
5183 5242
5184 } } // namespace v8::internal 5243 } } // namespace v8::internal
5185 5244
5186 #endif // V8_TARGET_ARCH_IA32 5245 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | src/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698