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

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

Powered by Google App Engine
This is Rietveld 408576698