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 for (int i = 0; i < expr->properties()->length(); i++) { | 1689 int property_index = 0; |
1690 ObjectLiteral::Property* property = expr->properties()->at(i); | 1690 for (; property_index < expr->properties()->length(); property_index++) { |
| 1691 ObjectLiteral::Property* property = expr->properties()->at(property_index); |
| 1692 if (property->is_computed_name()) break; |
1691 if (property->IsCompileTimeValue()) continue; | 1693 if (property->IsCompileTimeValue()) continue; |
1692 | 1694 |
1693 Literal* key = property->key(); | 1695 Literal* key = property->key()->AsLiteral(); |
1694 Expression* value = property->value(); | 1696 Expression* value = property->value(); |
1695 if (!result_saved) { | 1697 if (!result_saved) { |
1696 __ push(r0); // Save result on stack | 1698 __ push(r0); // Save result on stack |
1697 result_saved = true; | 1699 result_saved = true; |
1698 } | 1700 } |
1699 switch (property->kind()) { | 1701 switch (property->kind()) { |
1700 case ObjectLiteral::Property::CONSTANT: | 1702 case ObjectLiteral::Property::CONSTANT: |
1701 UNREACHABLE(); | 1703 UNREACHABLE(); |
1702 case ObjectLiteral::Property::MATERIALIZED_LITERAL: | 1704 case ObjectLiteral::Property::MATERIALIZED_LITERAL: |
1703 DCHECK(!CompileTimeValue::IsCompileTimeValue(property->value())); | 1705 DCHECK(!CompileTimeValue::IsCompileTimeValue(property->value())); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1771 VisitForStackValue(it->first); | 1773 VisitForStackValue(it->first); |
1772 EmitAccessor(it->second->getter); | 1774 EmitAccessor(it->second->getter); |
1773 EmitSetHomeObjectIfNeeded(it->second->getter, 2); | 1775 EmitSetHomeObjectIfNeeded(it->second->getter, 2); |
1774 EmitAccessor(it->second->setter); | 1776 EmitAccessor(it->second->setter); |
1775 EmitSetHomeObjectIfNeeded(it->second->setter, 3); | 1777 EmitSetHomeObjectIfNeeded(it->second->setter, 3); |
1776 __ mov(r0, Operand(Smi::FromInt(NONE))); | 1778 __ mov(r0, Operand(Smi::FromInt(NONE))); |
1777 __ push(r0); | 1779 __ push(r0); |
1778 __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5); | 1780 __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5); |
1779 } | 1781 } |
1780 | 1782 |
| 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 |
1781 if (expr->has_function()) { | 1844 if (expr->has_function()) { |
1782 DCHECK(result_saved); | 1845 DCHECK(result_saved); |
1783 __ ldr(r0, MemOperand(sp)); | 1846 __ ldr(r0, MemOperand(sp)); |
1784 __ push(r0); | 1847 __ push(r0); |
1785 __ CallRuntime(Runtime::kToFastProperties, 1); | 1848 __ CallRuntime(Runtime::kToFastProperties, 1); |
1786 } | 1849 } |
1787 | 1850 |
1788 if (result_saved) { | 1851 if (result_saved) { |
1789 context()->PlugTOS(); | 1852 context()->PlugTOS(); |
1790 } else { | 1853 } else { |
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2471 | 2534 |
2472 // No access check is needed here since the constructor is created by the | 2535 // No access check is needed here since the constructor is created by the |
2473 // class literal. | 2536 // class literal. |
2474 Register scratch = r1; | 2537 Register scratch = r1; |
2475 __ ldr(scratch, | 2538 __ ldr(scratch, |
2476 FieldMemOperand(r0, JSFunction::kPrototypeOrInitialMapOffset)); | 2539 FieldMemOperand(r0, JSFunction::kPrototypeOrInitialMapOffset)); |
2477 __ push(scratch); | 2540 __ push(scratch); |
2478 | 2541 |
2479 for (int i = 0; i < lit->properties()->length(); i++) { | 2542 for (int i = 0; i < lit->properties()->length(); i++) { |
2480 ObjectLiteral::Property* property = lit->properties()->at(i); | 2543 ObjectLiteral::Property* property = lit->properties()->at(i); |
2481 Literal* key = property->key()->AsLiteral(); | |
2482 Expression* value = property->value(); | 2544 Expression* value = property->value(); |
2483 DCHECK(key != NULL); | |
2484 | 2545 |
2485 if (property->is_static()) { | 2546 if (property->is_static()) { |
2486 __ ldr(scratch, MemOperand(sp, kPointerSize)); // constructor | 2547 __ ldr(scratch, MemOperand(sp, kPointerSize)); // constructor |
2487 } else { | 2548 } else { |
2488 __ ldr(scratch, MemOperand(sp, 0)); // prototype | 2549 __ ldr(scratch, MemOperand(sp, 0)); // prototype |
2489 } | 2550 } |
2490 __ push(scratch); | 2551 __ push(scratch); |
2491 VisitForStackValue(key); | 2552 EmitPropertyKey(property); |
2492 VisitForStackValue(value); | 2553 VisitForStackValue(value); |
2493 EmitSetHomeObjectIfNeeded(value, 2); | 2554 EmitSetHomeObjectIfNeeded(value, 2); |
2494 | 2555 |
2495 switch (property->kind()) { | 2556 switch (property->kind()) { |
2496 case ObjectLiteral::Property::CONSTANT: | 2557 case ObjectLiteral::Property::CONSTANT: |
2497 case ObjectLiteral::Property::MATERIALIZED_LITERAL: | 2558 case ObjectLiteral::Property::MATERIALIZED_LITERAL: |
2498 case ObjectLiteral::Property::COMPUTED: | 2559 case ObjectLiteral::Property::COMPUTED: |
2499 case ObjectLiteral::Property::PROTOTYPE: | 2560 case ObjectLiteral::Property::PROTOTYPE: |
2500 __ CallRuntime(Runtime::kDefineClassMethod, 3); | 2561 __ CallRuntime(Runtime::kDefineClassMethod, 3); |
2501 break; | 2562 break; |
2502 | 2563 |
2503 case ObjectLiteral::Property::GETTER: | 2564 case ObjectLiteral::Property::GETTER: |
2504 __ CallRuntime(Runtime::kDefineClassGetter, 3); | 2565 __ CallRuntime(Runtime::kDefineGetterPropertyUnchecked, 3); |
2505 break; | 2566 break; |
2506 | 2567 |
2507 case ObjectLiteral::Property::SETTER: | 2568 case ObjectLiteral::Property::SETTER: |
2508 __ CallRuntime(Runtime::kDefineClassSetter, 3); | 2569 __ CallRuntime(Runtime::kDefineSetterPropertyUnchecked, 3); |
2509 break; | 2570 break; |
2510 | 2571 |
2511 default: | 2572 default: |
2512 UNREACHABLE(); | 2573 UNREACHABLE(); |
2513 } | 2574 } |
2514 } | 2575 } |
2515 | 2576 |
2516 // prototype | 2577 // prototype |
2517 __ CallRuntime(Runtime::kToFastProperties, 1); | 2578 __ CallRuntime(Runtime::kToFastProperties, 1); |
2518 | 2579 |
(...skipping 2781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5300 | 5361 |
5301 DCHECK(interrupt_address == | 5362 DCHECK(interrupt_address == |
5302 isolate->builtins()->OsrAfterStackCheck()->entry()); | 5363 isolate->builtins()->OsrAfterStackCheck()->entry()); |
5303 return OSR_AFTER_STACK_CHECK; | 5364 return OSR_AFTER_STACK_CHECK; |
5304 } | 5365 } |
5305 | 5366 |
5306 | 5367 |
5307 } } // namespace v8::internal | 5368 } } // namespace v8::internal |
5308 | 5369 |
5309 #endif // V8_TARGET_ARCH_ARM | 5370 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |