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

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

Issue 829913005: MIPS: ES6 computed property names. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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/mips/full-codegen-mips.cc ('k') | no next file » | 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_MIPS64 7 #if V8_TARGET_ARCH_MIPS64
8 8
9 // Note on Mips implementation: 9 // Note on Mips implementation:
10 // 10 //
(...skipping 1650 matching lines...) Expand 10 before | Expand all | Expand 10 after
1661 // If result_saved is true the result is on top of the stack. If 1661 // If result_saved is true the result is on top of the stack. If
1662 // result_saved is false the result is in v0. 1662 // result_saved is false the result is in v0.
1663 bool result_saved = false; 1663 bool result_saved = false;
1664 1664
1665 // Mark all computed expressions that are bound to a key that 1665 // Mark all computed expressions that are bound to a key that
1666 // is shadowed by a later occurrence of the same key. For the 1666 // is shadowed by a later occurrence of the same key. For the
1667 // marked expressions, no store code is emitted. 1667 // marked expressions, no store code is emitted.
1668 expr->CalculateEmitStore(zone()); 1668 expr->CalculateEmitStore(zone());
1669 1669
1670 AccessorTable accessor_table(zone()); 1670 AccessorTable accessor_table(zone());
1671 for (int i = 0; i < expr->properties()->length(); i++) { 1671 int property_index = 0;
1672 ObjectLiteral::Property* property = expr->properties()->at(i); 1672 for (; property_index < expr->properties()->length(); property_index++) {
1673 ObjectLiteral::Property* property = expr->properties()->at(property_index);
1674 if (property->is_computed_name()) break;
1673 if (property->IsCompileTimeValue()) continue; 1675 if (property->IsCompileTimeValue()) continue;
1674 1676
1675 Literal* key = property->key(); 1677 Literal* key = property->key()->AsLiteral();
1676 Expression* value = property->value(); 1678 Expression* value = property->value();
1677 if (!result_saved) { 1679 if (!result_saved) {
1678 __ push(v0); // Save result on stack. 1680 __ push(v0); // Save result on stack.
1679 result_saved = true; 1681 result_saved = true;
1680 } 1682 }
1681 switch (property->kind()) { 1683 switch (property->kind()) {
1682 case ObjectLiteral::Property::CONSTANT: 1684 case ObjectLiteral::Property::CONSTANT:
1683 UNREACHABLE(); 1685 UNREACHABLE();
1684 case ObjectLiteral::Property::MATERIALIZED_LITERAL: 1686 case ObjectLiteral::Property::MATERIALIZED_LITERAL:
1685 DCHECK(!CompileTimeValue::IsCompileTimeValue(property->value())); 1687 DCHECK(!CompileTimeValue::IsCompileTimeValue(property->value()));
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1753 VisitForStackValue(it->first); 1755 VisitForStackValue(it->first);
1754 EmitAccessor(it->second->getter); 1756 EmitAccessor(it->second->getter);
1755 EmitSetHomeObjectIfNeeded(it->second->getter, 2); 1757 EmitSetHomeObjectIfNeeded(it->second->getter, 2);
1756 EmitAccessor(it->second->setter); 1758 EmitAccessor(it->second->setter);
1757 EmitSetHomeObjectIfNeeded(it->second->setter, 3); 1759 EmitSetHomeObjectIfNeeded(it->second->setter, 3);
1758 __ li(a0, Operand(Smi::FromInt(NONE))); 1760 __ li(a0, Operand(Smi::FromInt(NONE)));
1759 __ push(a0); 1761 __ push(a0);
1760 __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5); 1762 __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5);
1761 } 1763 }
1762 1764
1765 // Object literals have two parts. The "static" part on the left contains no
1766 // computed property names, and so we can compute its map ahead of time; see
1767 // runtime.cc::CreateObjectLiteralBoilerplate. The second "dynamic" part
1768 // starts with the first computed property name, and continues with all
1769 // properties to its right. All the code from above initializes the static
1770 // component of the object literal, and arranges for the map of the result to
1771 // reflect the static order in which the keys appear. For the dynamic
1772 // properties, we compile them into a series of "SetOwnProperty" runtime
1773 // calls. This will preserve insertion order.
1774 for (; property_index < expr->properties()->length(); property_index++) {
1775 ObjectLiteral::Property* property = expr->properties()->at(property_index);
1776
1777 Expression* value = property->value();
1778 if (!result_saved) {
1779 __ push(v0); // Save result on the stack
1780 result_saved = true;
1781 }
1782
1783 __ ld(a0, MemOperand(sp)); // Duplicate receiver.
1784 __ push(a0);
1785
1786 if (property->kind() == ObjectLiteral::Property::PROTOTYPE) {
1787 DCHECK(!property->is_computed_name());
1788 VisitForStackValue(value);
1789 if (property->emit_store()) {
1790 __ CallRuntime(Runtime::kInternalSetPrototype, 2);
1791 } else {
1792 __ Drop(2);
1793 }
1794 } else {
1795 EmitPropertyKey(property);
1796 VisitForStackValue(value);
1797
1798 switch (property->kind()) {
1799 case ObjectLiteral::Property::CONSTANT:
1800 case ObjectLiteral::Property::MATERIALIZED_LITERAL:
1801 case ObjectLiteral::Property::COMPUTED:
1802 if (property->emit_store()) {
1803 __ li(a0, Operand(Smi::FromInt(NONE)));
1804 __ push(a0);
1805 __ CallRuntime(Runtime::kDefineDataPropertyUnchecked, 4);
1806 } else {
1807 __ Drop(3);
1808 }
1809 break;
1810
1811 case ObjectLiteral::Property::PROTOTYPE:
1812 UNREACHABLE();
1813 break;
1814
1815 case ObjectLiteral::Property::GETTER:
1816 __ CallRuntime(Runtime::kDefineGetterPropertyUnchecked, 3);
1817 break;
1818
1819 case ObjectLiteral::Property::SETTER:
1820 __ CallRuntime(Runtime::kDefineSetterPropertyUnchecked, 3);
1821 break;
1822 }
1823 }
1824 }
1825
1763 if (expr->has_function()) { 1826 if (expr->has_function()) {
1764 DCHECK(result_saved); 1827 DCHECK(result_saved);
1765 __ ld(a0, MemOperand(sp)); 1828 __ ld(a0, MemOperand(sp));
1766 __ push(a0); 1829 __ push(a0);
1767 __ CallRuntime(Runtime::kToFastProperties, 1); 1830 __ CallRuntime(Runtime::kToFastProperties, 1);
1768 } 1831 }
1769 1832
1770 if (result_saved) { 1833 if (result_saved) {
1771 context()->PlugTOS(); 1834 context()->PlugTOS();
1772 } else { 1835 } else {
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
2446 2509
2447 // No access check is needed here since the constructor is created by the 2510 // No access check is needed here since the constructor is created by the
2448 // class literal. 2511 // class literal.
2449 Register scratch = a1; 2512 Register scratch = a1;
2450 __ ld(scratch, 2513 __ ld(scratch,
2451 FieldMemOperand(v0, JSFunction::kPrototypeOrInitialMapOffset)); 2514 FieldMemOperand(v0, JSFunction::kPrototypeOrInitialMapOffset));
2452 __ push(scratch); 2515 __ push(scratch);
2453 2516
2454 for (int i = 0; i < lit->properties()->length(); i++) { 2517 for (int i = 0; i < lit->properties()->length(); i++) {
2455 ObjectLiteral::Property* property = lit->properties()->at(i); 2518 ObjectLiteral::Property* property = lit->properties()->at(i);
2456 Literal* key = property->key()->AsLiteral();
2457 Expression* value = property->value(); 2519 Expression* value = property->value();
2458 DCHECK(key != NULL);
2459 2520
2460 if (property->is_static()) { 2521 if (property->is_static()) {
2461 __ ld(scratch, MemOperand(sp, kPointerSize)); // constructor 2522 __ ld(scratch, MemOperand(sp, kPointerSize)); // constructor
2462 } else { 2523 } else {
2463 __ ld(scratch, MemOperand(sp, 0)); // prototype 2524 __ ld(scratch, MemOperand(sp, 0)); // prototype
2464 } 2525 }
2465 __ push(scratch); 2526 __ push(scratch);
2466 VisitForStackValue(key); 2527 EmitPropertyKey(property);
2467 VisitForStackValue(value); 2528 VisitForStackValue(value);
2468 EmitSetHomeObjectIfNeeded(value, 2); 2529 EmitSetHomeObjectIfNeeded(value, 2);
2469 2530
2470 switch (property->kind()) { 2531 switch (property->kind()) {
2471 case ObjectLiteral::Property::CONSTANT: 2532 case ObjectLiteral::Property::CONSTANT:
2472 case ObjectLiteral::Property::MATERIALIZED_LITERAL: 2533 case ObjectLiteral::Property::MATERIALIZED_LITERAL:
2473 case ObjectLiteral::Property::COMPUTED: 2534 case ObjectLiteral::Property::COMPUTED:
2474 case ObjectLiteral::Property::PROTOTYPE: 2535 case ObjectLiteral::Property::PROTOTYPE:
2475 __ CallRuntime(Runtime::kDefineClassMethod, 3); 2536 __ CallRuntime(Runtime::kDefineClassMethod, 3);
2476 break; 2537 break;
2477 2538
2478 case ObjectLiteral::Property::GETTER: 2539 case ObjectLiteral::Property::GETTER:
2479 __ CallRuntime(Runtime::kDefineClassGetter, 3); 2540 __ CallRuntime(Runtime::kDefineGetterPropertyUnchecked, 3);
2480 break; 2541 break;
2481 2542
2482 case ObjectLiteral::Property::SETTER: 2543 case ObjectLiteral::Property::SETTER:
2483 __ CallRuntime(Runtime::kDefineClassSetter, 3); 2544 __ CallRuntime(Runtime::kDefineSetterPropertyUnchecked, 3);
2484 break; 2545 break;
2485 2546
2486 default: 2547 default:
2487 UNREACHABLE(); 2548 UNREACHABLE();
2488 } 2549 }
2489 } 2550 }
2490 2551
2491 // prototype 2552 // prototype
2492 __ CallRuntime(Runtime::kToFastProperties, 1); 2553 __ CallRuntime(Runtime::kToFastProperties, 1);
2493 2554
(...skipping 2748 matching lines...) Expand 10 before | Expand all | Expand 10 after
5242 Assembler::target_address_at(pc_immediate_load_address)) == 5303 Assembler::target_address_at(pc_immediate_load_address)) ==
5243 reinterpret_cast<uint64_t>( 5304 reinterpret_cast<uint64_t>(
5244 isolate->builtins()->OsrAfterStackCheck()->entry())); 5305 isolate->builtins()->OsrAfterStackCheck()->entry()));
5245 return OSR_AFTER_STACK_CHECK; 5306 return OSR_AFTER_STACK_CHECK;
5246 } 5307 }
5247 5308
5248 5309
5249 } } // namespace v8::internal 5310 } } // namespace v8::internal
5250 5311
5251 #endif // V8_TARGET_ARCH_MIPS64 5312 #endif // V8_TARGET_ARCH_MIPS64
OLDNEW
« no previous file with comments | « src/mips/full-codegen-mips.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698