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

Side by Side Diff: src/mips64/full-codegen-mips64.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/mips/full-codegen-mips.cc ('k') | src/parser.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_MIPS64 7 #if V8_TARGET_ARCH_MIPS64
8 8
9 // Note on Mips implementation: 9 // Note on Mips implementation:
10 // 10 //
(...skipping 1858 matching lines...) Expand 10 before | Expand all | Expand 10 after
1869 __ CallStub(&stub); 1869 __ CallStub(&stub);
1870 } 1870 }
1871 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); 1871 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG);
1872 1872
1873 bool result_saved = false; // Is the result saved to the stack? 1873 bool result_saved = false; // Is the result saved to the stack?
1874 ZoneList<Expression*>* subexprs = expr->values(); 1874 ZoneList<Expression*>* subexprs = expr->values();
1875 int length = subexprs->length(); 1875 int length = subexprs->length();
1876 1876
1877 // Emit code to evaluate all the non-constant subexpressions and to store 1877 // Emit code to evaluate all the non-constant subexpressions and to store
1878 // them into the newly cloned array. 1878 // them into the newly cloned array.
1879 for (int i = 0; i < length; i++) { 1879 int array_index = 0;
1880 Expression* subexpr = subexprs->at(i); 1880 for (; array_index < length; array_index++) {
1881 Expression* subexpr = subexprs->at(array_index);
1882 if (subexpr->IsSpread()) break;
1883
1881 // If the subexpression is a literal or a simple materialized literal it 1884 // If the subexpression is a literal or a simple materialized literal it
1882 // is already set in the cloned array. 1885 // is already set in the cloned array.
1883 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; 1886 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue;
1884 1887
1885 if (!result_saved) { 1888 if (!result_saved) {
1886 __ push(v0); // array literal 1889 __ push(v0); // array literal
1887 __ Push(Smi::FromInt(expr->literal_index())); 1890 __ Push(Smi::FromInt(expr->literal_index()));
1888 result_saved = true; 1891 result_saved = true;
1889 } 1892 }
1890 1893
1891 VisitForAccumulatorValue(subexpr); 1894 VisitForAccumulatorValue(subexpr);
1892 1895
1893 if (has_fast_elements) { 1896 if (has_fast_elements) {
1894 int offset = FixedArray::kHeaderSize + (i * kPointerSize); 1897 int offset = FixedArray::kHeaderSize + (array_index * kPointerSize);
1895 __ ld(a6, MemOperand(sp, kPointerSize)); // Copy of array literal. 1898 __ ld(a6, MemOperand(sp, kPointerSize)); // Copy of array literal.
1896 __ ld(a1, FieldMemOperand(a6, JSObject::kElementsOffset)); 1899 __ ld(a1, FieldMemOperand(a6, JSObject::kElementsOffset));
1897 __ sd(result_register(), FieldMemOperand(a1, offset)); 1900 __ sd(result_register(), FieldMemOperand(a1, offset));
1898 // Update the write barrier for the array store. 1901 // Update the write barrier for the array store.
1899 __ RecordWriteField(a1, offset, result_register(), a2, 1902 __ RecordWriteField(a1, offset, result_register(), a2,
1900 kRAHasBeenSaved, kDontSaveFPRegs, 1903 kRAHasBeenSaved, kDontSaveFPRegs,
1901 EMIT_REMEMBERED_SET, INLINE_SMI_CHECK); 1904 EMIT_REMEMBERED_SET, INLINE_SMI_CHECK);
1902 } else { 1905 } else {
1903 __ li(a3, Operand(Smi::FromInt(i))); 1906 __ li(a3, Operand(Smi::FromInt(array_index)));
1904 __ mov(a0, result_register()); 1907 __ mov(a0, result_register());
1905 StoreArrayLiteralElementStub stub(isolate()); 1908 StoreArrayLiteralElementStub stub(isolate());
1906 __ CallStub(&stub); 1909 __ CallStub(&stub);
1907 } 1910 }
1908 1911
1909 PrepareForBailoutForId(expr->GetIdForElement(i), NO_REGISTERS); 1912 PrepareForBailoutForId(expr->GetIdForElement(array_index), NO_REGISTERS);
1910 } 1913 }
1914
1915 // In case the array literal contains spread expressions it has two parts. The
1916 // first part is the "static" array which has a literal index is handled
1917 // above. The second part is the part after the first spread expression
1918 // (inclusive) and these elements gets appended to the array. Note that the
1919 // number elements an iterable produces is unknown ahead of time.
1920 if (array_index < length && result_saved) {
1921 __ Pop(); // literal index
1922 __ Pop(v0);
1923 result_saved = false;
1924 }
1925 for (; array_index < length; array_index++) {
1926 Expression* subexpr = subexprs->at(array_index);
1927
1928 __ Push(v0);
1929 if (subexpr->IsSpread()) {
1930 VisitForStackValue(subexpr->AsSpread()->expression());
1931 __ InvokeBuiltin(Builtins::CONCAT_ITERABLE_TO_ARRAY, CALL_FUNCTION);
1932 } else {
1933 VisitForStackValue(subexpr);
1934 __ CallRuntime(Runtime::kAppendElement, 2);
1935 }
1936
1937 PrepareForBailoutForId(expr->GetIdForElement(array_index), NO_REGISTERS);
1938 }
1939
1911 if (result_saved) { 1940 if (result_saved) {
1912 __ Pop(); // literal index 1941 __ Pop(); // literal index
1913 context()->PlugTOS(); 1942 context()->PlugTOS();
1914 } else { 1943 } else {
1915 context()->Plug(v0); 1944 context()->Plug(v0);
1916 } 1945 }
1917 } 1946 }
1918 1947
1919 1948
1920 void FullCodeGenerator::VisitAssignment(Assignment* expr) { 1949 void FullCodeGenerator::VisitAssignment(Assignment* expr) {
(...skipping 3509 matching lines...) Expand 10 before | Expand all | Expand 10 after
5430 Assembler::target_address_at(pc_immediate_load_address)) == 5459 Assembler::target_address_at(pc_immediate_load_address)) ==
5431 reinterpret_cast<uint64_t>( 5460 reinterpret_cast<uint64_t>(
5432 isolate->builtins()->OsrAfterStackCheck()->entry())); 5461 isolate->builtins()->OsrAfterStackCheck()->entry()));
5433 return OSR_AFTER_STACK_CHECK; 5462 return OSR_AFTER_STACK_CHECK;
5434 } 5463 }
5435 5464
5436 5465
5437 } } // namespace v8::internal 5466 } } // namespace v8::internal
5438 5467
5439 #endif // V8_TARGET_ARCH_MIPS64 5468 #endif // V8_TARGET_ARCH_MIPS64
OLDNEW
« no previous file with comments | « src/mips/full-codegen-mips.cc ('k') | src/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698