Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Side by Side Diff: src/mips/full-codegen-mips.cc

Issue 1125183008: [es6] Spread in array literals (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: cleanup Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/ia32/full-codegen-ia32.cc ('k') | src/mips64/full-codegen-mips64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_MIPS 7 #if V8_TARGET_ARCH_MIPS
8 8
9 // Note on Mips implementation: 9 // Note on Mips implementation:
10 // 10 //
(...skipping 1859 matching lines...) Expand 10 before | Expand all | Expand 10 after
1870 __ CallStub(&stub); 1870 __ CallStub(&stub);
1871 } 1871 }
1872 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); 1872 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG);
1873 1873
1874 bool result_saved = false; // Is the result saved to the stack? 1874 bool result_saved = false; // Is the result saved to the stack?
1875 ZoneList<Expression*>* subexprs = expr->values(); 1875 ZoneList<Expression*>* subexprs = expr->values();
1876 int length = subexprs->length(); 1876 int length = subexprs->length();
1877 1877
1878 // Emit code to evaluate all the non-constant subexpressions and to store 1878 // Emit code to evaluate all the non-constant subexpressions and to store
1879 // them into the newly cloned array. 1879 // them into the newly cloned array.
1880 for (int i = 0; i < length; i++) { 1880 int array_index = 0;
1881 Expression* subexpr = subexprs->at(i); 1881 for (; array_index < length; array_index++) {
1882 Expression* subexpr = subexprs->at(array_index);
1883 if (subexpr->IsSpread()) break;
1884
1882 // If the subexpression is a literal or a simple materialized literal it 1885 // If the subexpression is a literal or a simple materialized literal it
1883 // is already set in the cloned array. 1886 // is already set in the cloned array.
1884 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; 1887 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue;
1885 1888
1886 if (!result_saved) { 1889 if (!result_saved) {
1887 __ push(v0); // array literal 1890 __ push(v0); // array literal
1888 __ Push(Smi::FromInt(expr->literal_index())); 1891 __ Push(Smi::FromInt(expr->literal_index()));
1889 result_saved = true; 1892 result_saved = true;
1890 } 1893 }
1891 1894
1892 VisitForAccumulatorValue(subexpr); 1895 VisitForAccumulatorValue(subexpr);
1893 1896
1894 if (has_fast_elements) { 1897 if (has_fast_elements) {
1895 int offset = FixedArray::kHeaderSize + (i * kPointerSize); 1898 int offset = FixedArray::kHeaderSize + (array_index * kPointerSize);
1896 __ lw(t2, MemOperand(sp, kPointerSize)); // Copy of array literal. 1899 __ lw(t2, MemOperand(sp, kPointerSize)); // Copy of array literal.
1897 __ lw(a1, FieldMemOperand(t2, JSObject::kElementsOffset)); 1900 __ lw(a1, FieldMemOperand(t2, JSObject::kElementsOffset));
1898 __ sw(result_register(), FieldMemOperand(a1, offset)); 1901 __ sw(result_register(), FieldMemOperand(a1, offset));
1899 // Update the write barrier for the array store. 1902 // Update the write barrier for the array store.
1900 __ RecordWriteField(a1, offset, result_register(), a2, 1903 __ RecordWriteField(a1, offset, result_register(), a2,
1901 kRAHasBeenSaved, kDontSaveFPRegs, 1904 kRAHasBeenSaved, kDontSaveFPRegs,
1902 EMIT_REMEMBERED_SET, INLINE_SMI_CHECK); 1905 EMIT_REMEMBERED_SET, INLINE_SMI_CHECK);
1903 } else { 1906 } else {
1904 __ li(a3, Operand(Smi::FromInt(i))); 1907 __ li(a3, Operand(Smi::FromInt(array_index)));
1905 __ mov(a0, result_register()); 1908 __ mov(a0, result_register());
1906 StoreArrayLiteralElementStub stub(isolate()); 1909 StoreArrayLiteralElementStub stub(isolate());
1907 __ CallStub(&stub); 1910 __ CallStub(&stub);
1908 } 1911 }
1909 1912
1910 PrepareForBailoutForId(expr->GetIdForElement(i), NO_REGISTERS); 1913 PrepareForBailoutForId(expr->GetIdForElement(array_index), NO_REGISTERS);
1911 } 1914 }
1915
1916 // In case the array literal contains spread expressions it has two parts. The
1917 // first part is the "static" array which has a literal index is handled
1918 // above. The second part is the part after the first spread expression
1919 // (inclusive) and these elements gets appended to the array. Note that the
1920 // number elements an iterable produces is unknown ahead of time.
1921 if (array_index < length && result_saved) {
1922 __ Pop(); // literal index
1923 __ Pop(v0);
1924 result_saved = false;
1925 }
1926 for (; array_index < length; array_index++) {
1927 Expression* subexpr = subexprs->at(array_index);
1928
1929 __ Push(v0);
1930 if (subexpr->IsSpread()) {
1931 VisitForStackValue(subexpr->AsSpread()->expression());
1932 __ InvokeBuiltin(Builtins::CONCAT_ITERABLE_TO_ARRAY, CALL_FUNCTION);
1933 } else {
1934 VisitForStackValue(subexpr);
1935 __ CallRuntime(Runtime::kAppendElement, 2);
1936 }
1937
1938 PrepareForBailoutForId(expr->GetIdForElement(array_index), NO_REGISTERS);
1939 }
1940
1912 if (result_saved) { 1941 if (result_saved) {
1913 __ Pop(); // literal index 1942 __ Pop(); // literal index
1914 context()->PlugTOS(); 1943 context()->PlugTOS();
1915 } else { 1944 } else {
1916 context()->Plug(v0); 1945 context()->Plug(v0);
1917 } 1946 }
1918 } 1947 }
1919 1948
1920 1949
1921 void FullCodeGenerator::VisitAssignment(Assignment* expr) { 1950 void FullCodeGenerator::VisitAssignment(Assignment* expr) {
(...skipping 3501 matching lines...) Expand 10 before | Expand all | Expand 10 after
5423 Assembler::target_address_at(pc_immediate_load_address)) == 5452 Assembler::target_address_at(pc_immediate_load_address)) ==
5424 reinterpret_cast<uint32_t>( 5453 reinterpret_cast<uint32_t>(
5425 isolate->builtins()->OsrAfterStackCheck()->entry())); 5454 isolate->builtins()->OsrAfterStackCheck()->entry()));
5426 return OSR_AFTER_STACK_CHECK; 5455 return OSR_AFTER_STACK_CHECK;
5427 } 5456 }
5428 5457
5429 5458
5430 } } // namespace v8::internal 5459 } } // namespace v8::internal
5431 5460
5432 #endif // V8_TARGET_ARCH_MIPS 5461 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/ia32/full-codegen-ia32.cc ('k') | src/mips64/full-codegen-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698