OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1781 for (int i = 0; i < length; i++) { | 1781 for (int i = 0; i < length; i++) { |
1782 Expression* subexpr = subexprs->at(i); | 1782 Expression* subexpr = subexprs->at(i); |
1783 // If the subexpression is a literal or a simple materialized literal it | 1783 // If the subexpression is a literal or a simple materialized literal it |
1784 // is already set in the cloned array. | 1784 // is already set in the cloned array. |
1785 if (subexpr->AsLiteral() != NULL || | 1785 if (subexpr->AsLiteral() != NULL || |
1786 CompileTimeValue::IsCompileTimeValue(subexpr)) { | 1786 CompileTimeValue::IsCompileTimeValue(subexpr)) { |
1787 continue; | 1787 continue; |
1788 } | 1788 } |
1789 | 1789 |
1790 if (!result_saved) { | 1790 if (!result_saved) { |
1791 __ push(eax); | 1791 __ push(eax); // array literal. |
| 1792 __ push(Immediate(Smi::FromInt(expr->literal_index()))); |
1792 result_saved = true; | 1793 result_saved = true; |
1793 } | 1794 } |
1794 VisitForAccumulatorValue(subexpr); | 1795 VisitForAccumulatorValue(subexpr); |
1795 | 1796 |
1796 if (IsFastObjectElementsKind(constant_elements_kind)) { | 1797 if (IsFastObjectElementsKind(constant_elements_kind)) { |
1797 // Fast-case array literal with ElementsKind of FAST_*_ELEMENTS, they | 1798 // Fast-case array literal with ElementsKind of FAST_*_ELEMENTS, they |
1798 // cannot transition and don't need to call the runtime stub. | 1799 // cannot transition and don't need to call the runtime stub. |
1799 int offset = FixedArray::kHeaderSize + (i * kPointerSize); | 1800 int offset = FixedArray::kHeaderSize + (i * kPointerSize); |
1800 __ mov(ebx, Operand(esp, 0)); // Copy of array literal. | 1801 __ mov(ebx, Operand(esp, kPointerSize)); // Copy of array literal. |
1801 __ mov(ebx, FieldOperand(ebx, JSObject::kElementsOffset)); | 1802 __ mov(ebx, FieldOperand(ebx, JSObject::kElementsOffset)); |
1802 // Store the subexpression value in the array's elements. | 1803 // Store the subexpression value in the array's elements. |
1803 __ mov(FieldOperand(ebx, offset), result_register()); | 1804 __ mov(FieldOperand(ebx, offset), result_register()); |
1804 // Update the write barrier for the array store. | 1805 // Update the write barrier for the array store. |
1805 __ RecordWriteField(ebx, offset, result_register(), ecx, | 1806 __ RecordWriteField(ebx, offset, result_register(), ecx, |
1806 kDontSaveFPRegs, | 1807 kDontSaveFPRegs, |
1807 EMIT_REMEMBERED_SET, | 1808 EMIT_REMEMBERED_SET, |
1808 INLINE_SMI_CHECK); | 1809 INLINE_SMI_CHECK); |
1809 } else { | 1810 } else { |
1810 // Store the subexpression value in the array's elements. | 1811 // Store the subexpression value in the array's elements. |
1811 __ mov(ebx, Operand(esp, 0)); // Copy of array literal. | |
1812 __ mov(edi, FieldOperand(ebx, JSObject::kMapOffset)); | |
1813 __ mov(ecx, Immediate(Smi::FromInt(i))); | 1812 __ mov(ecx, Immediate(Smi::FromInt(i))); |
1814 __ mov(edx, Immediate(Smi::FromInt(expr->literal_index()))); | |
1815 StoreArrayLiteralElementStub stub; | 1813 StoreArrayLiteralElementStub stub; |
1816 __ CallStub(&stub); | 1814 __ CallStub(&stub); |
1817 } | 1815 } |
1818 | 1816 |
1819 PrepareForBailoutForId(expr->GetIdForElement(i), NO_REGISTERS); | 1817 PrepareForBailoutForId(expr->GetIdForElement(i), NO_REGISTERS); |
1820 } | 1818 } |
1821 | 1819 |
1822 if (result_saved) { | 1820 if (result_saved) { |
| 1821 __ add(esp, Immediate(kPointerSize)); // literal index |
1823 context()->PlugTOS(); | 1822 context()->PlugTOS(); |
1824 } else { | 1823 } else { |
1825 context()->Plug(eax); | 1824 context()->Plug(eax); |
1826 } | 1825 } |
1827 } | 1826 } |
1828 | 1827 |
1829 | 1828 |
1830 void FullCodeGenerator::VisitAssignment(Assignment* expr) { | 1829 void FullCodeGenerator::VisitAssignment(Assignment* expr) { |
1831 Comment cmnt(masm_, "[ Assignment"); | 1830 Comment cmnt(masm_, "[ Assignment"); |
1832 // Invalid left-hand sides are rewritten to have a 'throw ReferenceError' | 1831 // Invalid left-hand sides are rewritten to have a 'throw ReferenceError' |
(...skipping 3061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4894 *stack_depth = 0; | 4893 *stack_depth = 0; |
4895 *context_length = 0; | 4894 *context_length = 0; |
4896 return previous_; | 4895 return previous_; |
4897 } | 4896 } |
4898 | 4897 |
4899 #undef __ | 4898 #undef __ |
4900 | 4899 |
4901 } } // namespace v8::internal | 4900 } } // namespace v8::internal |
4902 | 4901 |
4903 #endif // V8_TARGET_ARCH_IA32 | 4902 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |