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

Side by Side Diff: src/ia32/full-codegen-ia32.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/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 int property_index = 0; 1620 for (int i = 0; i < expr->properties()->length(); i++) {
1621 for (; property_index < expr->properties()->length(); property_index++) { 1621 ObjectLiteral::Property* property = expr->properties()->at(i);
1622 ObjectLiteral::Property* property = expr->properties()->at(property_index);
1623 if (property->is_computed_name()) break;
1624 if (property->IsCompileTimeValue()) continue; 1622 if (property->IsCompileTimeValue()) continue;
1625 1623
1626 Literal* key = property->key()->AsLiteral(); 1624 Literal* key = property->key();
1627 Expression* value = property->value(); 1625 Expression* value = property->value();
1628 if (!result_saved) { 1626 if (!result_saved) {
1629 __ push(eax); // Save result on the stack 1627 __ push(eax); // Save result on the stack
1630 result_saved = true; 1628 result_saved = true;
1631 } 1629 }
1632 switch (property->kind()) { 1630 switch (property->kind()) {
1633 case ObjectLiteral::Property::CONSTANT: 1631 case ObjectLiteral::Property::CONSTANT:
1634 UNREACHABLE(); 1632 UNREACHABLE();
1635 case ObjectLiteral::Property::MATERIALIZED_LITERAL: 1633 case ObjectLiteral::Property::MATERIALIZED_LITERAL:
1636 DCHECK(!CompileTimeValue::IsCompileTimeValue(value)); 1634 DCHECK(!CompileTimeValue::IsCompileTimeValue(value));
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1696 __ push(Operand(esp, 0)); // Duplicate receiver. 1694 __ push(Operand(esp, 0)); // Duplicate receiver.
1697 VisitForStackValue(it->first); 1695 VisitForStackValue(it->first);
1698 EmitAccessor(it->second->getter); 1696 EmitAccessor(it->second->getter);
1699 EmitSetHomeObjectIfNeeded(it->second->getter, 2); 1697 EmitSetHomeObjectIfNeeded(it->second->getter, 2);
1700 EmitAccessor(it->second->setter); 1698 EmitAccessor(it->second->setter);
1701 EmitSetHomeObjectIfNeeded(it->second->setter, 3); 1699 EmitSetHomeObjectIfNeeded(it->second->setter, 3);
1702 __ push(Immediate(Smi::FromInt(NONE))); 1700 __ push(Immediate(Smi::FromInt(NONE)));
1703 __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5); 1701 __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5);
1704 } 1702 }
1705 1703
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
1765 if (expr->has_function()) { 1704 if (expr->has_function()) {
1766 DCHECK(result_saved); 1705 DCHECK(result_saved);
1767 __ push(Operand(esp, 0)); 1706 __ push(Operand(esp, 0));
1768 __ CallRuntime(Runtime::kToFastProperties, 1); 1707 __ CallRuntime(Runtime::kToFastProperties, 1);
1769 } 1708 }
1770 1709
1771 if (result_saved) { 1710 if (result_saved) {
1772 context()->PlugTOS(); 1711 context()->PlugTOS();
1773 } else { 1712 } else {
1774 context()->Plug(eax); 1713 context()->Plug(eax);
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
2448 __ push(eax); 2387 __ push(eax);
2449 2388
2450 // No access check is needed here since the constructor is created by the 2389 // No access check is needed here since the constructor is created by the
2451 // class literal. 2390 // class literal.
2452 Register scratch = ebx; 2391 Register scratch = ebx;
2453 __ mov(scratch, FieldOperand(eax, JSFunction::kPrototypeOrInitialMapOffset)); 2392 __ mov(scratch, FieldOperand(eax, JSFunction::kPrototypeOrInitialMapOffset));
2454 __ Push(scratch); 2393 __ Push(scratch);
2455 2394
2456 for (int i = 0; i < lit->properties()->length(); i++) { 2395 for (int i = 0; i < lit->properties()->length(); i++) {
2457 ObjectLiteral::Property* property = lit->properties()->at(i); 2396 ObjectLiteral::Property* property = lit->properties()->at(i);
2397 Literal* key = property->key()->AsLiteral();
2458 Expression* value = property->value(); 2398 Expression* value = property->value();
2399 DCHECK(key != NULL);
2459 2400
2460 if (property->is_static()) { 2401 if (property->is_static()) {
2461 __ push(Operand(esp, kPointerSize)); // constructor 2402 __ push(Operand(esp, kPointerSize)); // constructor
2462 } else { 2403 } else {
2463 __ push(Operand(esp, 0)); // prototype 2404 __ push(Operand(esp, 0)); // prototype
2464 } 2405 }
2465 EmitPropertyKey(property); 2406 VisitForStackValue(key);
2466 VisitForStackValue(value); 2407 VisitForStackValue(value);
2467 EmitSetHomeObjectIfNeeded(value, 2); 2408 EmitSetHomeObjectIfNeeded(value, 2);
2468 2409
2469 switch (property->kind()) { 2410 switch (property->kind()) {
2470 case ObjectLiteral::Property::CONSTANT: 2411 case ObjectLiteral::Property::CONSTANT:
2471 case ObjectLiteral::Property::MATERIALIZED_LITERAL: 2412 case ObjectLiteral::Property::MATERIALIZED_LITERAL:
2472 case ObjectLiteral::Property::COMPUTED: 2413 case ObjectLiteral::Property::COMPUTED:
2473 case ObjectLiteral::Property::PROTOTYPE: 2414 case ObjectLiteral::Property::PROTOTYPE:
2474 __ CallRuntime(Runtime::kDefineClassMethod, 3); 2415 __ CallRuntime(Runtime::kDefineClassMethod, 3);
2475 break; 2416 break;
2476 2417
2477 case ObjectLiteral::Property::GETTER: 2418 case ObjectLiteral::Property::GETTER:
2478 __ CallRuntime(Runtime::kDefineGetterPropertyUnchecked, 3); 2419 __ CallRuntime(Runtime::kDefineClassGetter, 3);
2479 break; 2420 break;
2480 2421
2481 case ObjectLiteral::Property::SETTER: 2422 case ObjectLiteral::Property::SETTER:
2482 __ CallRuntime(Runtime::kDefineSetterPropertyUnchecked, 3); 2423 __ CallRuntime(Runtime::kDefineClassSetter, 3);
2483 break; 2424 break;
2484 2425
2485 default: 2426 default:
2486 UNREACHABLE(); 2427 UNREACHABLE();
2487 } 2428 }
2488 } 2429 }
2489 2430
2490 // prototype 2431 // prototype
2491 __ CallRuntime(Runtime::kToFastProperties, 1); 2432 __ CallRuntime(Runtime::kToFastProperties, 1);
2492 2433
(...skipping 2742 matching lines...) Expand 10 before | Expand all | Expand 10 after
5235 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 5176 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
5236 Assembler::target_address_at(call_target_address, 5177 Assembler::target_address_at(call_target_address,
5237 unoptimized_code)); 5178 unoptimized_code));
5238 return OSR_AFTER_STACK_CHECK; 5179 return OSR_AFTER_STACK_CHECK;
5239 } 5180 }
5240 5181
5241 5182
5242 } } // namespace v8::internal 5183 } } // namespace v8::internal
5243 5184
5244 #endif // V8_TARGET_ARCH_IA32 5185 #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