| 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_X87 | 7 #if V8_TARGET_ARCH_X87 |
| 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 1790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1801 __ CallStub(&stub); | 1801 __ CallStub(&stub); |
| 1802 } | 1802 } |
| 1803 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); | 1803 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); |
| 1804 | 1804 |
| 1805 bool result_saved = false; // Is the result saved to the stack? | 1805 bool result_saved = false; // Is the result saved to the stack? |
| 1806 ZoneList<Expression*>* subexprs = expr->values(); | 1806 ZoneList<Expression*>* subexprs = expr->values(); |
| 1807 int length = subexprs->length(); | 1807 int length = subexprs->length(); |
| 1808 | 1808 |
| 1809 // Emit code to evaluate all the non-constant subexpressions and to store | 1809 // Emit code to evaluate all the non-constant subexpressions and to store |
| 1810 // them into the newly cloned array. | 1810 // them into the newly cloned array. |
| 1811 for (int i = 0; i < length; i++) { | 1811 int array_index = 0; |
| 1812 Expression* subexpr = subexprs->at(i); | 1812 for (; array_index < length; array_index++) { |
| 1813 Expression* subexpr = subexprs->at(array_index); |
| 1814 if (subexpr->IsSpread()) break; |
| 1815 |
| 1813 // If the subexpression is a literal or a simple materialized literal it | 1816 // If the subexpression is a literal or a simple materialized literal it |
| 1814 // is already set in the cloned array. | 1817 // is already set in the cloned array. |
| 1815 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; | 1818 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; |
| 1816 | 1819 |
| 1817 if (!result_saved) { | 1820 if (!result_saved) { |
| 1818 __ push(eax); // array literal. | 1821 __ push(eax); // array literal. |
| 1819 __ push(Immediate(Smi::FromInt(expr->literal_index()))); | 1822 __ push(Immediate(Smi::FromInt(expr->literal_index()))); |
| 1820 result_saved = true; | 1823 result_saved = true; |
| 1821 } | 1824 } |
| 1822 VisitForAccumulatorValue(subexpr); | 1825 VisitForAccumulatorValue(subexpr); |
| 1823 | 1826 |
| 1824 if (has_constant_fast_elements) { | 1827 if (has_constant_fast_elements) { |
| 1825 // Fast-case array literal with ElementsKind of FAST_*_ELEMENTS, they | 1828 // Fast-case array literal with ElementsKind of FAST_*_ELEMENTS, they |
| 1826 // cannot transition and don't need to call the runtime stub. | 1829 // cannot transition and don't need to call the runtime stub. |
| 1827 int offset = FixedArray::kHeaderSize + (i * kPointerSize); | 1830 int offset = FixedArray::kHeaderSize + (array_index * kPointerSize); |
| 1828 __ mov(ebx, Operand(esp, kPointerSize)); // Copy of array literal. | 1831 __ mov(ebx, Operand(esp, kPointerSize)); // Copy of array literal. |
| 1829 __ mov(ebx, FieldOperand(ebx, JSObject::kElementsOffset)); | 1832 __ mov(ebx, FieldOperand(ebx, JSObject::kElementsOffset)); |
| 1830 // Store the subexpression value in the array's elements. | 1833 // Store the subexpression value in the array's elements. |
| 1831 __ mov(FieldOperand(ebx, offset), result_register()); | 1834 __ mov(FieldOperand(ebx, offset), result_register()); |
| 1832 // Update the write barrier for the array store. | 1835 // Update the write barrier for the array store. |
| 1833 __ RecordWriteField(ebx, offset, result_register(), ecx, kDontSaveFPRegs, | 1836 __ RecordWriteField(ebx, offset, result_register(), ecx, kDontSaveFPRegs, |
| 1834 EMIT_REMEMBERED_SET, INLINE_SMI_CHECK); | 1837 EMIT_REMEMBERED_SET, INLINE_SMI_CHECK); |
| 1835 } else { | 1838 } else { |
| 1836 // Store the subexpression value in the array's elements. | 1839 // Store the subexpression value in the array's elements. |
| 1837 __ mov(ecx, Immediate(Smi::FromInt(i))); | 1840 __ mov(ecx, Immediate(Smi::FromInt(array_index))); |
| 1838 StoreArrayLiteralElementStub stub(isolate()); | 1841 StoreArrayLiteralElementStub stub(isolate()); |
| 1839 __ CallStub(&stub); | 1842 __ CallStub(&stub); |
| 1840 } | 1843 } |
| 1841 | 1844 |
| 1842 PrepareForBailoutForId(expr->GetIdForElement(i), NO_REGISTERS); | 1845 PrepareForBailoutForId(expr->GetIdForElement(array_index), NO_REGISTERS); |
| 1846 } |
| 1847 |
| 1848 // In case the array literal contains spread expressions it has two parts. The |
| 1849 // first part is the "static" array which has a literal index is handled |
| 1850 // above. The second part is the part after the first spread expression |
| 1851 // (inclusive) and these elements gets appended to the array. Note that the |
| 1852 // number elements an iterable produces is unknown ahead of time. |
| 1853 if (array_index < length && result_saved) { |
| 1854 __ Drop(1); // literal index |
| 1855 __ Pop(eax); |
| 1856 result_saved = false; |
| 1857 } |
| 1858 for (; array_index < length; array_index++) { |
| 1859 Expression* subexpr = subexprs->at(array_index); |
| 1860 |
| 1861 __ Push(eax); |
| 1862 if (subexpr->IsSpread()) { |
| 1863 VisitForStackValue(subexpr->AsSpread()->expression()); |
| 1864 __ InvokeBuiltin(Builtins::CONCAT_ITERABLE_TO_ARRAY, CALL_FUNCTION); |
| 1865 } else { |
| 1866 VisitForStackValue(subexpr); |
| 1867 __ CallRuntime(Runtime::kAppendElement, 2); |
| 1868 } |
| 1869 |
| 1870 PrepareForBailoutForId(expr->GetIdForElement(array_index), NO_REGISTERS); |
| 1843 } | 1871 } |
| 1844 | 1872 |
| 1845 if (result_saved) { | 1873 if (result_saved) { |
| 1846 __ add(esp, Immediate(kPointerSize)); // literal index | 1874 __ Drop(1); // literal index |
| 1847 context()->PlugTOS(); | 1875 context()->PlugTOS(); |
| 1848 } else { | 1876 } else { |
| 1849 context()->Plug(eax); | 1877 context()->Plug(eax); |
| 1850 } | 1878 } |
| 1851 } | 1879 } |
| 1852 | 1880 |
| 1853 | 1881 |
| 1854 void FullCodeGenerator::VisitAssignment(Assignment* expr) { | 1882 void FullCodeGenerator::VisitAssignment(Assignment* expr) { |
| 1855 DCHECK(expr->target()->IsValidReferenceExpression()); | 1883 DCHECK(expr->target()->IsValidReferenceExpression()); |
| 1856 | 1884 |
| (...skipping 3482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5339 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 5367 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
| 5340 Assembler::target_address_at(call_target_address, | 5368 Assembler::target_address_at(call_target_address, |
| 5341 unoptimized_code)); | 5369 unoptimized_code)); |
| 5342 return OSR_AFTER_STACK_CHECK; | 5370 return OSR_AFTER_STACK_CHECK; |
| 5343 } | 5371 } |
| 5344 | 5372 |
| 5345 | 5373 |
| 5346 } } // namespace v8::internal | 5374 } } // namespace v8::internal |
| 5347 | 5375 |
| 5348 #endif // V8_TARGET_ARCH_X87 | 5376 #endif // V8_TARGET_ARCH_X87 |
| OLD | NEW |