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

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

Issue 1037273002: Ensure object literal element boilerplates aren't modified. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Added comment and REBASE. Created 5 years, 8 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 1680 matching lines...) Expand 10 before | Expand all | Expand 10 after
1691 1691
1692 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { 1692 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
1693 Comment cmnt(masm_, "[ ObjectLiteral"); 1693 Comment cmnt(masm_, "[ ObjectLiteral");
1694 1694
1695 expr->BuildConstantProperties(isolate()); 1695 expr->BuildConstantProperties(isolate());
1696 Handle<FixedArray> constant_properties = expr->constant_properties(); 1696 Handle<FixedArray> constant_properties = expr->constant_properties();
1697 __ ldr(r3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); 1697 __ ldr(r3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
1698 __ ldr(r3, FieldMemOperand(r3, JSFunction::kLiteralsOffset)); 1698 __ ldr(r3, FieldMemOperand(r3, JSFunction::kLiteralsOffset));
1699 __ mov(r2, Operand(Smi::FromInt(expr->literal_index()))); 1699 __ mov(r2, Operand(Smi::FromInt(expr->literal_index())));
1700 __ mov(r1, Operand(constant_properties)); 1700 __ mov(r1, Operand(constant_properties));
1701 int flags = expr->fast_elements() 1701 int flags = expr->ComputeFlags();
1702 ? ObjectLiteral::kFastElements
1703 : ObjectLiteral::kNoFlags;
1704 flags |= expr->has_function()
1705 ? ObjectLiteral::kHasFunction
1706 : ObjectLiteral::kNoFlags;
1707 __ mov(r0, Operand(Smi::FromInt(flags))); 1702 __ mov(r0, Operand(Smi::FromInt(flags)));
1708 int properties_count = constant_properties->length() / 2; 1703 if (MustCreateObjectLiteralWithRuntime(expr)) {
1709 if (expr->may_store_doubles() || expr->depth() > 1 ||
1710 masm()->serializer_enabled() || flags != ObjectLiteral::kFastElements ||
1711 properties_count > FastCloneShallowObjectStub::kMaximumClonedProperties) {
1712 __ Push(r3, r2, r1, r0); 1704 __ Push(r3, r2, r1, r0);
1713 __ CallRuntime(Runtime::kCreateObjectLiteral, 4); 1705 __ CallRuntime(Runtime::kCreateObjectLiteral, 4);
1714 } else { 1706 } else {
1715 FastCloneShallowObjectStub stub(isolate(), properties_count); 1707 FastCloneShallowObjectStub stub(isolate(), expr->properties_count());
1716 __ CallStub(&stub); 1708 __ CallStub(&stub);
1717 } 1709 }
1718 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); 1710 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG);
1719 1711
1720 // If result_saved is true the result is on top of the stack. If 1712 // If result_saved is true the result is on top of the stack. If
1721 // result_saved is false the result is in r0. 1713 // result_saved is false the result is in r0.
1722 bool result_saved = false; 1714 bool result_saved = false;
1723 1715
1724 // Mark all computed expressions that are bound to a key that 1716 // Mark all computed expressions that are bound to a key that
1725 // is shadowed by a later occurrence of the same key. For the 1717 // is shadowed by a later occurrence of the same key. For the
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1897 } else { 1889 } else {
1898 context()->Plug(r0); 1890 context()->Plug(r0);
1899 } 1891 }
1900 } 1892 }
1901 1893
1902 1894
1903 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { 1895 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
1904 Comment cmnt(masm_, "[ ArrayLiteral"); 1896 Comment cmnt(masm_, "[ ArrayLiteral");
1905 1897
1906 expr->BuildConstantElements(isolate()); 1898 expr->BuildConstantElements(isolate());
1907 int flags = expr->depth() == 1
1908 ? ArrayLiteral::kShallowElements
1909 : ArrayLiteral::kNoFlags;
1910 1899
1911 ZoneList<Expression*>* subexprs = expr->values();
1912 int length = subexprs->length();
1913 Handle<FixedArray> constant_elements = expr->constant_elements(); 1900 Handle<FixedArray> constant_elements = expr->constant_elements();
1914 DCHECK_EQ(2, constant_elements->length()); 1901 bool has_fast_elements =
1915 ElementsKind constant_elements_kind = 1902 IsFastObjectElementsKind(expr->constant_elements_kind());
1916 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value());
1917 bool has_fast_elements = IsFastObjectElementsKind(constant_elements_kind);
1918 Handle<FixedArrayBase> constant_elements_values( 1903 Handle<FixedArrayBase> constant_elements_values(
1919 FixedArrayBase::cast(constant_elements->get(1))); 1904 FixedArrayBase::cast(constant_elements->get(1)));
1920 1905
1921 AllocationSiteMode allocation_site_mode = TRACK_ALLOCATION_SITE; 1906 AllocationSiteMode allocation_site_mode = TRACK_ALLOCATION_SITE;
1922 if (has_fast_elements && !FLAG_allocation_site_pretenuring) { 1907 if (has_fast_elements && !FLAG_allocation_site_pretenuring) {
1923 // If the only customer of allocation sites is transitioning, then 1908 // If the only customer of allocation sites is transitioning, then
1924 // we can turn it off if we don't have anywhere else to transition to. 1909 // we can turn it off if we don't have anywhere else to transition to.
1925 allocation_site_mode = DONT_TRACK_ALLOCATION_SITE; 1910 allocation_site_mode = DONT_TRACK_ALLOCATION_SITE;
1926 } 1911 }
1927 1912
1928 __ ldr(r3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); 1913 __ ldr(r3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
1929 __ ldr(r3, FieldMemOperand(r3, JSFunction::kLiteralsOffset)); 1914 __ ldr(r3, FieldMemOperand(r3, JSFunction::kLiteralsOffset));
1930 __ mov(r2, Operand(Smi::FromInt(expr->literal_index()))); 1915 __ mov(r2, Operand(Smi::FromInt(expr->literal_index())));
1931 __ mov(r1, Operand(constant_elements)); 1916 __ mov(r1, Operand(constant_elements));
1932 if (expr->depth() > 1 || length > JSObject::kInitialMaxFastElementArray) { 1917 if (MustCreateArrayLiteralWithRuntime(expr)) {
1933 __ mov(r0, Operand(Smi::FromInt(flags))); 1918 __ mov(r0, Operand(Smi::FromInt(expr->ComputeFlags())));
1934 __ Push(r3, r2, r1, r0); 1919 __ Push(r3, r2, r1, r0);
1935 __ CallRuntime(Runtime::kCreateArrayLiteral, 4); 1920 __ CallRuntime(Runtime::kCreateArrayLiteral, 4);
1936 } else { 1921 } else {
1937 FastCloneShallowArrayStub stub(isolate(), allocation_site_mode); 1922 FastCloneShallowArrayStub stub(isolate(), allocation_site_mode);
1938 __ CallStub(&stub); 1923 __ CallStub(&stub);
1939 } 1924 }
1940 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); 1925 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG);
1941 1926
1942 bool result_saved = false; // Is the result saved to the stack? 1927 bool result_saved = false; // Is the result saved to the stack?
1928 ZoneList<Expression*>* subexprs = expr->values();
1929 int length = subexprs->length();
1943 1930
1944 // Emit code to evaluate all the non-constant subexpressions and to store 1931 // Emit code to evaluate all the non-constant subexpressions and to store
1945 // them into the newly cloned array. 1932 // them into the newly cloned array.
1946 for (int i = 0; i < length; i++) { 1933 for (int i = 0; i < length; i++) {
1947 Expression* subexpr = subexprs->at(i); 1934 Expression* subexpr = subexprs->at(i);
1948 // If the subexpression is a literal or a simple materialized literal it 1935 // If the subexpression is a literal or a simple materialized literal it
1949 // is already set in the cloned array. 1936 // is already set in the cloned array.
1950 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; 1937 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue;
1951 1938
1952 if (!result_saved) { 1939 if (!result_saved) {
1953 __ push(r0); 1940 __ push(r0);
1954 __ Push(Smi::FromInt(expr->literal_index())); 1941 __ Push(Smi::FromInt(expr->literal_index()));
1955 result_saved = true; 1942 result_saved = true;
1956 } 1943 }
1957 VisitForAccumulatorValue(subexpr); 1944 VisitForAccumulatorValue(subexpr);
1958 1945
1959 if (IsFastObjectElementsKind(constant_elements_kind)) { 1946 if (has_fast_elements) {
1960 int offset = FixedArray::kHeaderSize + (i * kPointerSize); 1947 int offset = FixedArray::kHeaderSize + (i * kPointerSize);
1961 __ ldr(r6, MemOperand(sp, kPointerSize)); // Copy of array literal. 1948 __ ldr(r6, MemOperand(sp, kPointerSize)); // Copy of array literal.
1962 __ ldr(r1, FieldMemOperand(r6, JSObject::kElementsOffset)); 1949 __ ldr(r1, FieldMemOperand(r6, JSObject::kElementsOffset));
1963 __ str(result_register(), FieldMemOperand(r1, offset)); 1950 __ str(result_register(), FieldMemOperand(r1, offset));
1964 // Update the write barrier for the array store. 1951 // Update the write barrier for the array store.
1965 __ RecordWriteField(r1, offset, result_register(), r2, 1952 __ RecordWriteField(r1, offset, result_register(), r2,
1966 kLRHasBeenSaved, kDontSaveFPRegs, 1953 kLRHasBeenSaved, kDontSaveFPRegs,
1967 EMIT_REMEMBERED_SET, INLINE_SMI_CHECK); 1954 EMIT_REMEMBERED_SET, INLINE_SMI_CHECK);
1968 } else { 1955 } else {
1969 __ mov(r3, Operand(Smi::FromInt(i))); 1956 __ mov(r3, Operand(Smi::FromInt(i)));
(...skipping 3521 matching lines...) Expand 10 before | Expand all | Expand 10 after
5491 5478
5492 DCHECK(interrupt_address == 5479 DCHECK(interrupt_address ==
5493 isolate->builtins()->OsrAfterStackCheck()->entry()); 5480 isolate->builtins()->OsrAfterStackCheck()->entry());
5494 return OSR_AFTER_STACK_CHECK; 5481 return OSR_AFTER_STACK_CHECK;
5495 } 5482 }
5496 5483
5497 5484
5498 } } // namespace v8::internal 5485 } } // namespace v8::internal
5499 5486
5500 #endif // V8_TARGET_ARCH_ARM 5487 #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