| OLD | NEW |
| 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_ARM | 7 #if V8_TARGET_ARCH_ARM |
| 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 1668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1679 // If result_saved is true the result is on top of the stack. If | 1679 // If result_saved is true the result is on top of the stack. If |
| 1680 // result_saved is false the result is in r0. | 1680 // result_saved is false the result is in r0. |
| 1681 bool result_saved = false; | 1681 bool result_saved = false; |
| 1682 | 1682 |
| 1683 // Mark all computed expressions that are bound to a key that | 1683 // Mark all computed expressions that are bound to a key that |
| 1684 // is shadowed by a later occurrence of the same key. For the | 1684 // is shadowed by a later occurrence of the same key. For the |
| 1685 // marked expressions, no store code is emitted. | 1685 // marked expressions, no store code is emitted. |
| 1686 expr->CalculateEmitStore(zone()); | 1686 expr->CalculateEmitStore(zone()); |
| 1687 | 1687 |
| 1688 AccessorTable accessor_table(zone()); | 1688 AccessorTable accessor_table(zone()); |
| 1689 int property_index = 0; | 1689 for (int i = 0; i < expr->properties()->length(); i++) { |
| 1690 for (; property_index < expr->properties()->length(); property_index++) { | 1690 ObjectLiteral::Property* property = expr->properties()->at(i); |
| 1691 ObjectLiteral::Property* property = expr->properties()->at(property_index); | |
| 1692 if (property->is_computed_name()) break; | |
| 1693 if (property->IsCompileTimeValue()) continue; | 1691 if (property->IsCompileTimeValue()) continue; |
| 1694 | 1692 |
| 1695 Literal* key = property->key()->AsLiteral(); | 1693 Literal* key = property->key(); |
| 1696 Expression* value = property->value(); | 1694 Expression* value = property->value(); |
| 1697 if (!result_saved) { | 1695 if (!result_saved) { |
| 1698 __ push(r0); // Save result on stack | 1696 __ push(r0); // Save result on stack |
| 1699 result_saved = true; | 1697 result_saved = true; |
| 1700 } | 1698 } |
| 1701 switch (property->kind()) { | 1699 switch (property->kind()) { |
| 1702 case ObjectLiteral::Property::CONSTANT: | 1700 case ObjectLiteral::Property::CONSTANT: |
| 1703 UNREACHABLE(); | 1701 UNREACHABLE(); |
| 1704 case ObjectLiteral::Property::MATERIALIZED_LITERAL: | 1702 case ObjectLiteral::Property::MATERIALIZED_LITERAL: |
| 1705 DCHECK(!CompileTimeValue::IsCompileTimeValue(property->value())); | 1703 DCHECK(!CompileTimeValue::IsCompileTimeValue(property->value())); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1773 VisitForStackValue(it->first); | 1771 VisitForStackValue(it->first); |
| 1774 EmitAccessor(it->second->getter); | 1772 EmitAccessor(it->second->getter); |
| 1775 EmitSetHomeObjectIfNeeded(it->second->getter, 2); | 1773 EmitSetHomeObjectIfNeeded(it->second->getter, 2); |
| 1776 EmitAccessor(it->second->setter); | 1774 EmitAccessor(it->second->setter); |
| 1777 EmitSetHomeObjectIfNeeded(it->second->setter, 3); | 1775 EmitSetHomeObjectIfNeeded(it->second->setter, 3); |
| 1778 __ mov(r0, Operand(Smi::FromInt(NONE))); | 1776 __ mov(r0, Operand(Smi::FromInt(NONE))); |
| 1779 __ push(r0); | 1777 __ push(r0); |
| 1780 __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5); | 1778 __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5); |
| 1781 } | 1779 } |
| 1782 | 1780 |
| 1783 // Object literals have two parts. The "static" part on the left contains no | |
| 1784 // computed property names, and so we can compute its map ahead of time; see | |
| 1785 // runtime.cc::CreateObjectLiteralBoilerplate. The second "dynamic" part | |
| 1786 // starts with the first computed property name, and continues with all | |
| 1787 // properties to its right. All the code from above initializes the static | |
| 1788 // component of the object literal, and arranges for the map of the result to | |
| 1789 // reflect the static order in which the keys appear. For the dynamic | |
| 1790 // properties, we compile them into a series of "SetOwnProperty" runtime | |
| 1791 // calls. This will preserve insertion order. | |
| 1792 for (; property_index < expr->properties()->length(); property_index++) { | |
| 1793 ObjectLiteral::Property* property = expr->properties()->at(property_index); | |
| 1794 | |
| 1795 Expression* value = property->value(); | |
| 1796 if (!result_saved) { | |
| 1797 __ push(r0); // Save result on the stack | |
| 1798 result_saved = true; | |
| 1799 } | |
| 1800 | |
| 1801 __ ldr(r0, MemOperand(sp)); // Duplicate receiver. | |
| 1802 __ push(r0); | |
| 1803 | |
| 1804 if (property->kind() == ObjectLiteral::Property::PROTOTYPE) { | |
| 1805 DCHECK(!property->is_computed_name()); | |
| 1806 VisitForStackValue(value); | |
| 1807 if (property->emit_store()) { | |
| 1808 __ CallRuntime(Runtime::kInternalSetPrototype, 2); | |
| 1809 } else { | |
| 1810 __ Drop(2); | |
| 1811 } | |
| 1812 } else { | |
| 1813 EmitPropertyKey(property); | |
| 1814 VisitForStackValue(value); | |
| 1815 | |
| 1816 switch (property->kind()) { | |
| 1817 case ObjectLiteral::Property::CONSTANT: | |
| 1818 case ObjectLiteral::Property::MATERIALIZED_LITERAL: | |
| 1819 case ObjectLiteral::Property::COMPUTED: | |
| 1820 if (property->emit_store()) { | |
| 1821 __ mov(r0, Operand(Smi::FromInt(NONE))); | |
| 1822 __ push(r0); | |
| 1823 __ CallRuntime(Runtime::kDefineDataPropertyUnchecked, 4); | |
| 1824 } else { | |
| 1825 __ Drop(3); | |
| 1826 } | |
| 1827 break; | |
| 1828 | |
| 1829 case ObjectLiteral::Property::PROTOTYPE: | |
| 1830 UNREACHABLE(); | |
| 1831 break; | |
| 1832 | |
| 1833 case ObjectLiteral::Property::GETTER: | |
| 1834 __ CallRuntime(Runtime::kDefineGetterPropertyUnchecked, 3); | |
| 1835 break; | |
| 1836 | |
| 1837 case ObjectLiteral::Property::SETTER: | |
| 1838 __ CallRuntime(Runtime::kDefineSetterPropertyUnchecked, 3); | |
| 1839 break; | |
| 1840 } | |
| 1841 } | |
| 1842 } | |
| 1843 | |
| 1844 if (expr->has_function()) { | 1781 if (expr->has_function()) { |
| 1845 DCHECK(result_saved); | 1782 DCHECK(result_saved); |
| 1846 __ ldr(r0, MemOperand(sp)); | 1783 __ ldr(r0, MemOperand(sp)); |
| 1847 __ push(r0); | 1784 __ push(r0); |
| 1848 __ CallRuntime(Runtime::kToFastProperties, 1); | 1785 __ CallRuntime(Runtime::kToFastProperties, 1); |
| 1849 } | 1786 } |
| 1850 | 1787 |
| 1851 if (result_saved) { | 1788 if (result_saved) { |
| 1852 context()->PlugTOS(); | 1789 context()->PlugTOS(); |
| 1853 } else { | 1790 } else { |
| (...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2534 | 2471 |
| 2535 // No access check is needed here since the constructor is created by the | 2472 // No access check is needed here since the constructor is created by the |
| 2536 // class literal. | 2473 // class literal. |
| 2537 Register scratch = r1; | 2474 Register scratch = r1; |
| 2538 __ ldr(scratch, | 2475 __ ldr(scratch, |
| 2539 FieldMemOperand(r0, JSFunction::kPrototypeOrInitialMapOffset)); | 2476 FieldMemOperand(r0, JSFunction::kPrototypeOrInitialMapOffset)); |
| 2540 __ push(scratch); | 2477 __ push(scratch); |
| 2541 | 2478 |
| 2542 for (int i = 0; i < lit->properties()->length(); i++) { | 2479 for (int i = 0; i < lit->properties()->length(); i++) { |
| 2543 ObjectLiteral::Property* property = lit->properties()->at(i); | 2480 ObjectLiteral::Property* property = lit->properties()->at(i); |
| 2481 Literal* key = property->key()->AsLiteral(); |
| 2544 Expression* value = property->value(); | 2482 Expression* value = property->value(); |
| 2483 DCHECK(key != NULL); |
| 2545 | 2484 |
| 2546 if (property->is_static()) { | 2485 if (property->is_static()) { |
| 2547 __ ldr(scratch, MemOperand(sp, kPointerSize)); // constructor | 2486 __ ldr(scratch, MemOperand(sp, kPointerSize)); // constructor |
| 2548 } else { | 2487 } else { |
| 2549 __ ldr(scratch, MemOperand(sp, 0)); // prototype | 2488 __ ldr(scratch, MemOperand(sp, 0)); // prototype |
| 2550 } | 2489 } |
| 2551 __ push(scratch); | 2490 __ push(scratch); |
| 2552 EmitPropertyKey(property); | 2491 VisitForStackValue(key); |
| 2553 VisitForStackValue(value); | 2492 VisitForStackValue(value); |
| 2554 EmitSetHomeObjectIfNeeded(value, 2); | 2493 EmitSetHomeObjectIfNeeded(value, 2); |
| 2555 | 2494 |
| 2556 switch (property->kind()) { | 2495 switch (property->kind()) { |
| 2557 case ObjectLiteral::Property::CONSTANT: | 2496 case ObjectLiteral::Property::CONSTANT: |
| 2558 case ObjectLiteral::Property::MATERIALIZED_LITERAL: | 2497 case ObjectLiteral::Property::MATERIALIZED_LITERAL: |
| 2559 case ObjectLiteral::Property::COMPUTED: | 2498 case ObjectLiteral::Property::COMPUTED: |
| 2560 case ObjectLiteral::Property::PROTOTYPE: | 2499 case ObjectLiteral::Property::PROTOTYPE: |
| 2561 __ CallRuntime(Runtime::kDefineClassMethod, 3); | 2500 __ CallRuntime(Runtime::kDefineClassMethod, 3); |
| 2562 break; | 2501 break; |
| 2563 | 2502 |
| 2564 case ObjectLiteral::Property::GETTER: | 2503 case ObjectLiteral::Property::GETTER: |
| 2565 __ CallRuntime(Runtime::kDefineGetterPropertyUnchecked, 3); | 2504 __ CallRuntime(Runtime::kDefineClassGetter, 3); |
| 2566 break; | 2505 break; |
| 2567 | 2506 |
| 2568 case ObjectLiteral::Property::SETTER: | 2507 case ObjectLiteral::Property::SETTER: |
| 2569 __ CallRuntime(Runtime::kDefineSetterPropertyUnchecked, 3); | 2508 __ CallRuntime(Runtime::kDefineClassSetter, 3); |
| 2570 break; | 2509 break; |
| 2571 | 2510 |
| 2572 default: | 2511 default: |
| 2573 UNREACHABLE(); | 2512 UNREACHABLE(); |
| 2574 } | 2513 } |
| 2575 } | 2514 } |
| 2576 | 2515 |
| 2577 // prototype | 2516 // prototype |
| 2578 __ CallRuntime(Runtime::kToFastProperties, 1); | 2517 __ CallRuntime(Runtime::kToFastProperties, 1); |
| 2579 | 2518 |
| (...skipping 2780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5360 | 5299 |
| 5361 DCHECK(interrupt_address == | 5300 DCHECK(interrupt_address == |
| 5362 isolate->builtins()->OsrAfterStackCheck()->entry()); | 5301 isolate->builtins()->OsrAfterStackCheck()->entry()); |
| 5363 return OSR_AFTER_STACK_CHECK; | 5302 return OSR_AFTER_STACK_CHECK; |
| 5364 } | 5303 } |
| 5365 | 5304 |
| 5366 | 5305 |
| 5367 } } // namespace v8::internal | 5306 } } // namespace v8::internal |
| 5368 | 5307 |
| 5369 #endif // V8_TARGET_ARCH_ARM | 5308 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |