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

Side by Side Diff: src/arm/full-codegen-arm.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 | « no previous file | src/arm64/full-codegen-arm64.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_ARM 7 #if V8_TARGET_ARCH_ARM
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 1875 matching lines...) Expand 10 before | Expand all | Expand 10 after
1886 __ CallStub(&stub); 1886 __ CallStub(&stub);
1887 } 1887 }
1888 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); 1888 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG);
1889 1889
1890 bool result_saved = false; // Is the result saved to the stack? 1890 bool result_saved = false; // Is the result saved to the stack?
1891 ZoneList<Expression*>* subexprs = expr->values(); 1891 ZoneList<Expression*>* subexprs = expr->values();
1892 int length = subexprs->length(); 1892 int length = subexprs->length();
1893 1893
1894 // Emit code to evaluate all the non-constant subexpressions and to store 1894 // Emit code to evaluate all the non-constant subexpressions and to store
1895 // them into the newly cloned array. 1895 // them into the newly cloned array.
1896 for (int i = 0; i < length; i++) { 1896 int array_index = 0;
1897 Expression* subexpr = subexprs->at(i); 1897 for (; array_index < length; array_index++) {
1898 Expression* subexpr = subexprs->at(array_index);
1899 if (subexpr->IsSpread()) break;
1900
1898 // If the subexpression is a literal or a simple materialized literal it 1901 // If the subexpression is a literal or a simple materialized literal it
1899 // is already set in the cloned array. 1902 // is already set in the cloned array.
1900 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; 1903 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue;
1901 1904
1902 if (!result_saved) { 1905 if (!result_saved) {
1903 __ push(r0); 1906 __ push(r0);
1904 __ Push(Smi::FromInt(expr->literal_index())); 1907 __ Push(Smi::FromInt(expr->literal_index()));
1905 result_saved = true; 1908 result_saved = true;
1906 } 1909 }
1907 VisitForAccumulatorValue(subexpr); 1910 VisitForAccumulatorValue(subexpr);
1908 1911
1909 if (has_fast_elements) { 1912 if (has_fast_elements) {
1910 int offset = FixedArray::kHeaderSize + (i * kPointerSize); 1913 int offset = FixedArray::kHeaderSize + (array_index * kPointerSize);
1911 __ ldr(r6, MemOperand(sp, kPointerSize)); // Copy of array literal. 1914 __ ldr(r6, MemOperand(sp, kPointerSize)); // Copy of array literal.
1912 __ ldr(r1, FieldMemOperand(r6, JSObject::kElementsOffset)); 1915 __ ldr(r1, FieldMemOperand(r6, JSObject::kElementsOffset));
1913 __ str(result_register(), FieldMemOperand(r1, offset)); 1916 __ str(result_register(), FieldMemOperand(r1, offset));
1914 // Update the write barrier for the array store. 1917 // Update the write barrier for the array store.
1915 __ RecordWriteField(r1, offset, result_register(), r2, 1918 __ RecordWriteField(r1, offset, result_register(), r2,
1916 kLRHasBeenSaved, kDontSaveFPRegs, 1919 kLRHasBeenSaved, kDontSaveFPRegs,
1917 EMIT_REMEMBERED_SET, INLINE_SMI_CHECK); 1920 EMIT_REMEMBERED_SET, INLINE_SMI_CHECK);
1918 } else { 1921 } else {
1919 __ mov(r3, Operand(Smi::FromInt(i))); 1922 __ mov(r3, Operand(Smi::FromInt(array_index)));
1920 StoreArrayLiteralElementStub stub(isolate()); 1923 StoreArrayLiteralElementStub stub(isolate());
1921 __ CallStub(&stub); 1924 __ CallStub(&stub);
1922 } 1925 }
1923 1926
1924 PrepareForBailoutForId(expr->GetIdForElement(i), NO_REGISTERS); 1927 PrepareForBailoutForId(expr->GetIdForElement(array_index), NO_REGISTERS);
1928 }
1929
1930 // In case the array literal contains spread expressions it has two parts. The
1931 // first part is the "static" array which has a literal index is handled
1932 // above. The second part is the part after the first spread expression
1933 // (inclusive) and these elements gets appended to the array. Note that the
1934 // number elements an iterable produces is unknown ahead of time.
1935 if (array_index < length && result_saved) {
1936 __ pop(); // literal index
1937 __ Pop(r0);
1938 result_saved = false;
1939 }
1940 for (; array_index < length; array_index++) {
1941 Expression* subexpr = subexprs->at(array_index);
1942
1943 __ Push(r0);
1944 if (subexpr->IsSpread()) {
1945 VisitForStackValue(subexpr->AsSpread()->expression());
1946 __ InvokeBuiltin(Builtins::CONCAT_ITERABLE_TO_ARRAY, CALL_FUNCTION);
1947 } else {
1948 VisitForStackValue(subexpr);
1949 __ CallRuntime(Runtime::kAppendElement, 2);
1950 }
1951
1952 PrepareForBailoutForId(expr->GetIdForElement(array_index), NO_REGISTERS);
1925 } 1953 }
1926 1954
1927 if (result_saved) { 1955 if (result_saved) {
1928 __ pop(); // literal index 1956 __ pop(); // literal index
1929 context()->PlugTOS(); 1957 context()->PlugTOS();
1930 } else { 1958 } else {
1931 context()->Plug(r0); 1959 context()->Plug(r0);
1932 } 1960 }
1933 } 1961 }
1934 1962
(...skipping 3549 matching lines...) Expand 10 before | Expand all | Expand 10 after
5484 5512
5485 DCHECK(interrupt_address == 5513 DCHECK(interrupt_address ==
5486 isolate->builtins()->OsrAfterStackCheck()->entry()); 5514 isolate->builtins()->OsrAfterStackCheck()->entry());
5487 return OSR_AFTER_STACK_CHECK; 5515 return OSR_AFTER_STACK_CHECK;
5488 } 5516 }
5489 5517
5490 5518
5491 } } // namespace v8::internal 5519 } } // namespace v8::internal
5492 5520
5493 #endif // V8_TARGET_ARCH_ARM 5521 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/arm64/full-codegen-arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698