OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_PPC | 7 #if V8_TARGET_ARCH_PPC |
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 1830 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1841 __ CallStub(&stub); | 1841 __ CallStub(&stub); |
1842 } | 1842 } |
1843 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); | 1843 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); |
1844 | 1844 |
1845 bool result_saved = false; // Is the result saved to the stack? | 1845 bool result_saved = false; // Is the result saved to the stack? |
1846 ZoneList<Expression*>* subexprs = expr->values(); | 1846 ZoneList<Expression*>* subexprs = expr->values(); |
1847 int length = subexprs->length(); | 1847 int length = subexprs->length(); |
1848 | 1848 |
1849 // Emit code to evaluate all the non-constant subexpressions and to store | 1849 // Emit code to evaluate all the non-constant subexpressions and to store |
1850 // them into the newly cloned array. | 1850 // them into the newly cloned array. |
1851 for (int i = 0; i < length; i++) { | 1851 int array_index = 0; |
1852 Expression* subexpr = subexprs->at(i); | 1852 for (; array_index < length; array_index++) { |
| 1853 Expression* subexpr = subexprs->at(array_index); |
| 1854 if (subexpr->IsSpread()) break; |
1853 // If the subexpression is a literal or a simple materialized literal it | 1855 // If the subexpression is a literal or a simple materialized literal it |
1854 // is already set in the cloned array. | 1856 // is already set in the cloned array. |
1855 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; | 1857 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; |
1856 | 1858 |
1857 if (!result_saved) { | 1859 if (!result_saved) { |
1858 __ push(r3); | 1860 __ push(r3); |
1859 __ Push(Smi::FromInt(expr->literal_index())); | 1861 __ Push(Smi::FromInt(expr->literal_index())); |
1860 result_saved = true; | 1862 result_saved = true; |
1861 } | 1863 } |
1862 VisitForAccumulatorValue(subexpr); | 1864 VisitForAccumulatorValue(subexpr); |
1863 | 1865 |
1864 if (has_fast_elements) { | 1866 if (has_fast_elements) { |
1865 int offset = FixedArray::kHeaderSize + (i * kPointerSize); | 1867 int offset = FixedArray::kHeaderSize + (array_index * kPointerSize); |
1866 __ LoadP(r8, MemOperand(sp, kPointerSize)); // Copy of array literal. | 1868 __ LoadP(r8, MemOperand(sp, kPointerSize)); // Copy of array literal. |
1867 __ LoadP(r4, FieldMemOperand(r8, JSObject::kElementsOffset)); | 1869 __ LoadP(r4, FieldMemOperand(r8, JSObject::kElementsOffset)); |
1868 __ StoreP(result_register(), FieldMemOperand(r4, offset), r0); | 1870 __ StoreP(result_register(), FieldMemOperand(r4, offset), r0); |
1869 // Update the write barrier for the array store. | 1871 // Update the write barrier for the array store. |
1870 __ RecordWriteField(r4, offset, result_register(), r5, kLRHasBeenSaved, | 1872 __ RecordWriteField(r4, offset, result_register(), r5, kLRHasBeenSaved, |
1871 kDontSaveFPRegs, EMIT_REMEMBERED_SET, | 1873 kDontSaveFPRegs, EMIT_REMEMBERED_SET, |
1872 INLINE_SMI_CHECK); | 1874 INLINE_SMI_CHECK); |
1873 } else { | 1875 } else { |
1874 __ LoadSmiLiteral(r6, Smi::FromInt(i)); | 1876 __ LoadSmiLiteral(r6, Smi::FromInt(array_index)); |
1875 StoreArrayLiteralElementStub stub(isolate()); | 1877 StoreArrayLiteralElementStub stub(isolate()); |
1876 __ CallStub(&stub); | 1878 __ CallStub(&stub); |
1877 } | 1879 } |
1878 | 1880 |
1879 PrepareForBailoutForId(expr->GetIdForElement(i), NO_REGISTERS); | 1881 PrepareForBailoutForId(expr->GetIdForElement(array_index), NO_REGISTERS); |
| 1882 } |
| 1883 |
| 1884 // In case the array literal contains spread expressions it has two parts. The |
| 1885 // first part is the "static" array which has a literal index is handled |
| 1886 // above. The second part is the part after the first spread expression |
| 1887 // (inclusive) and these elements gets appended to the array. Note that the |
| 1888 // number elements an iterable produces is unknown ahead of time. |
| 1889 if (array_index < length && result_saved) { |
| 1890 __ Drop(1); // literal index |
| 1891 __ Pop(r3); |
| 1892 result_saved = false; |
| 1893 } |
| 1894 for (; array_index < length; array_index++) { |
| 1895 Expression* subexpr = subexprs->at(array_index); |
| 1896 |
| 1897 __ Push(r3); |
| 1898 if (subexpr->IsSpread()) { |
| 1899 VisitForStackValue(subexpr->AsSpread()->expression()); |
| 1900 __ InvokeBuiltin(Builtins::CONCAT_ITERABLE_TO_ARRAY, CALL_FUNCTION); |
| 1901 } else { |
| 1902 VisitForStackValue(subexpr); |
| 1903 __ CallRuntime(Runtime::kAppendElement, 2); |
| 1904 } |
| 1905 |
| 1906 PrepareForBailoutForId(expr->GetIdForElement(array_index), NO_REGISTERS); |
1880 } | 1907 } |
1881 | 1908 |
1882 if (result_saved) { | 1909 if (result_saved) { |
1883 __ pop(); // literal index | 1910 __ Drop(1); // literal index |
1884 context()->PlugTOS(); | 1911 context()->PlugTOS(); |
1885 } else { | 1912 } else { |
1886 context()->Plug(r3); | 1913 context()->Plug(r3); |
1887 } | 1914 } |
1888 } | 1915 } |
1889 | 1916 |
1890 | 1917 |
1891 void FullCodeGenerator::VisitAssignment(Assignment* expr) { | 1918 void FullCodeGenerator::VisitAssignment(Assignment* expr) { |
1892 DCHECK(expr->target()->IsValidReferenceExpression()); | 1919 DCHECK(expr->target()->IsValidReferenceExpression()); |
1893 | 1920 |
(...skipping 3533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5427 return ON_STACK_REPLACEMENT; | 5454 return ON_STACK_REPLACEMENT; |
5428 } | 5455 } |
5429 | 5456 |
5430 DCHECK(interrupt_address == | 5457 DCHECK(interrupt_address == |
5431 isolate->builtins()->OsrAfterStackCheck()->entry()); | 5458 isolate->builtins()->OsrAfterStackCheck()->entry()); |
5432 return OSR_AFTER_STACK_CHECK; | 5459 return OSR_AFTER_STACK_CHECK; |
5433 } | 5460 } |
5434 } | 5461 } |
5435 } // namespace v8::internal | 5462 } // namespace v8::internal |
5436 #endif // V8_TARGET_ARCH_PPC | 5463 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |