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

Side by Side Diff: src/mips/full-codegen-mips.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 | « src/ia32/full-codegen-ia32.cc ('k') | src/runtime/runtime-literals.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 1666 matching lines...) Expand 10 before | Expand all | Expand 10 after
1677 1677
1678 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { 1678 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
1679 Comment cmnt(masm_, "[ ObjectLiteral"); 1679 Comment cmnt(masm_, "[ ObjectLiteral");
1680 1680
1681 expr->BuildConstantProperties(isolate()); 1681 expr->BuildConstantProperties(isolate());
1682 Handle<FixedArray> constant_properties = expr->constant_properties(); 1682 Handle<FixedArray> constant_properties = expr->constant_properties();
1683 __ lw(a3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); 1683 __ lw(a3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
1684 __ lw(a3, FieldMemOperand(a3, JSFunction::kLiteralsOffset)); 1684 __ lw(a3, FieldMemOperand(a3, JSFunction::kLiteralsOffset));
1685 __ li(a2, Operand(Smi::FromInt(expr->literal_index()))); 1685 __ li(a2, Operand(Smi::FromInt(expr->literal_index())));
1686 __ li(a1, Operand(constant_properties)); 1686 __ li(a1, Operand(constant_properties));
1687 int flags = expr->fast_elements() 1687 __ li(a0, Operand(Smi::FromInt(expr->ComputeFlags())));
1688 ? ObjectLiteral::kFastElements 1688 if (MustCreateObjectLiteralWithRuntime(expr)) {
1689 : ObjectLiteral::kNoFlags;
1690 flags |= expr->has_function()
1691 ? ObjectLiteral::kHasFunction
1692 : ObjectLiteral::kNoFlags;
1693 __ li(a0, Operand(Smi::FromInt(flags)));
1694 int properties_count = constant_properties->length() / 2;
1695 if (expr->may_store_doubles() || expr->depth() > 1 ||
1696 masm()->serializer_enabled() || flags != ObjectLiteral::kFastElements ||
1697 properties_count > FastCloneShallowObjectStub::kMaximumClonedProperties) {
1698 __ Push(a3, a2, a1, a0); 1689 __ Push(a3, a2, a1, a0);
1699 __ CallRuntime(Runtime::kCreateObjectLiteral, 4); 1690 __ CallRuntime(Runtime::kCreateObjectLiteral, 4);
1700 } else { 1691 } else {
1701 FastCloneShallowObjectStub stub(isolate(), properties_count); 1692 FastCloneShallowObjectStub stub(isolate(), expr->properties_count());
1702 __ CallStub(&stub); 1693 __ CallStub(&stub);
1703 } 1694 }
1704 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); 1695 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG);
1705 1696
1706 // If result_saved is true the result is on top of the stack. If 1697 // If result_saved is true the result is on top of the stack. If
1707 // result_saved is false the result is in v0. 1698 // result_saved is false the result is in v0.
1708 bool result_saved = false; 1699 bool result_saved = false;
1709 1700
1710 // Mark all computed expressions that are bound to a key that 1701 // Mark all computed expressions that are bound to a key that
1711 // is shadowed by a later occurrence of the same key. For the 1702 // is shadowed by a later occurrence of the same key. For the
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1883 } else { 1874 } else {
1884 context()->Plug(v0); 1875 context()->Plug(v0);
1885 } 1876 }
1886 } 1877 }
1887 1878
1888 1879
1889 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { 1880 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
1890 Comment cmnt(masm_, "[ ArrayLiteral"); 1881 Comment cmnt(masm_, "[ ArrayLiteral");
1891 1882
1892 expr->BuildConstantElements(isolate()); 1883 expr->BuildConstantElements(isolate());
1893 int flags = expr->depth() == 1
1894 ? ArrayLiteral::kShallowElements
1895 : ArrayLiteral::kNoFlags;
1896
1897 ZoneList<Expression*>* subexprs = expr->values();
1898 int length = subexprs->length();
1899 1884
1900 Handle<FixedArray> constant_elements = expr->constant_elements(); 1885 Handle<FixedArray> constant_elements = expr->constant_elements();
1901 DCHECK_EQ(2, constant_elements->length());
1902 ElementsKind constant_elements_kind =
1903 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value());
1904 bool has_fast_elements = 1886 bool has_fast_elements =
1905 IsFastObjectElementsKind(constant_elements_kind); 1887 IsFastObjectElementsKind(expr->constant_elements_kind());
1906 Handle<FixedArrayBase> constant_elements_values(
1907 FixedArrayBase::cast(constant_elements->get(1)));
1908 1888
1909 AllocationSiteMode allocation_site_mode = TRACK_ALLOCATION_SITE; 1889 AllocationSiteMode allocation_site_mode = TRACK_ALLOCATION_SITE;
1910 if (has_fast_elements && !FLAG_allocation_site_pretenuring) { 1890 if (has_fast_elements && !FLAG_allocation_site_pretenuring) {
1911 // If the only customer of allocation sites is transitioning, then 1891 // If the only customer of allocation sites is transitioning, then
1912 // we can turn it off if we don't have anywhere else to transition to. 1892 // we can turn it off if we don't have anywhere else to transition to.
1913 allocation_site_mode = DONT_TRACK_ALLOCATION_SITE; 1893 allocation_site_mode = DONT_TRACK_ALLOCATION_SITE;
1914 } 1894 }
1915 1895
1916 __ mov(a0, result_register()); 1896 __ mov(a0, result_register());
1917 __ lw(a3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); 1897 __ lw(a3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
1918 __ lw(a3, FieldMemOperand(a3, JSFunction::kLiteralsOffset)); 1898 __ lw(a3, FieldMemOperand(a3, JSFunction::kLiteralsOffset));
1919 __ li(a2, Operand(Smi::FromInt(expr->literal_index()))); 1899 __ li(a2, Operand(Smi::FromInt(expr->literal_index())));
1920 __ li(a1, Operand(constant_elements)); 1900 __ li(a1, Operand(constant_elements));
1921 if (expr->depth() > 1 || length > JSObject::kInitialMaxFastElementArray) { 1901 if (MustCreateArrayLiteralWithRuntime(expr)) {
1922 __ li(a0, Operand(Smi::FromInt(flags))); 1902 __ li(a0, Operand(Smi::FromInt(expr->ComputeFlags())));
1923 __ Push(a3, a2, a1, a0); 1903 __ Push(a3, a2, a1, a0);
1924 __ CallRuntime(Runtime::kCreateArrayLiteral, 4); 1904 __ CallRuntime(Runtime::kCreateArrayLiteral, 4);
1925 } else { 1905 } else {
1926 FastCloneShallowArrayStub stub(isolate(), allocation_site_mode); 1906 FastCloneShallowArrayStub stub(isolate(), allocation_site_mode);
1927 __ CallStub(&stub); 1907 __ CallStub(&stub);
1928 } 1908 }
1929 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); 1909 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG);
1930 1910
1931 bool result_saved = false; // Is the result saved to the stack? 1911 bool result_saved = false; // Is the result saved to the stack?
1912 ZoneList<Expression*>* subexprs = expr->values();
1913 int length = subexprs->length();
1932 1914
1933 // Emit code to evaluate all the non-constant subexpressions and to store 1915 // Emit code to evaluate all the non-constant subexpressions and to store
1934 // them into the newly cloned array. 1916 // them into the newly cloned array.
1935 for (int i = 0; i < length; i++) { 1917 for (int i = 0; i < length; i++) {
1936 Expression* subexpr = subexprs->at(i); 1918 Expression* subexpr = subexprs->at(i);
1937 // If the subexpression is a literal or a simple materialized literal it 1919 // If the subexpression is a literal or a simple materialized literal it
1938 // is already set in the cloned array. 1920 // is already set in the cloned array.
1939 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; 1921 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue;
1940 1922
1941 if (!result_saved) { 1923 if (!result_saved) {
1942 __ push(v0); // array literal 1924 __ push(v0); // array literal
1943 __ Push(Smi::FromInt(expr->literal_index())); 1925 __ Push(Smi::FromInt(expr->literal_index()));
1944 result_saved = true; 1926 result_saved = true;
1945 } 1927 }
1946 1928
1947 VisitForAccumulatorValue(subexpr); 1929 VisitForAccumulatorValue(subexpr);
1948 1930
1949 if (IsFastObjectElementsKind(constant_elements_kind)) { 1931 if (has_fast_elements) {
1950 int offset = FixedArray::kHeaderSize + (i * kPointerSize); 1932 int offset = FixedArray::kHeaderSize + (i * kPointerSize);
1951 __ lw(t2, MemOperand(sp, kPointerSize)); // Copy of array literal. 1933 __ lw(t2, MemOperand(sp, kPointerSize)); // Copy of array literal.
1952 __ lw(a1, FieldMemOperand(t2, JSObject::kElementsOffset)); 1934 __ lw(a1, FieldMemOperand(t2, JSObject::kElementsOffset));
1953 __ sw(result_register(), FieldMemOperand(a1, offset)); 1935 __ sw(result_register(), FieldMemOperand(a1, offset));
1954 // Update the write barrier for the array store. 1936 // Update the write barrier for the array store.
1955 __ RecordWriteField(a1, offset, result_register(), a2, 1937 __ RecordWriteField(a1, offset, result_register(), a2,
1956 kRAHasBeenSaved, kDontSaveFPRegs, 1938 kRAHasBeenSaved, kDontSaveFPRegs,
1957 EMIT_REMEMBERED_SET, INLINE_SMI_CHECK); 1939 EMIT_REMEMBERED_SET, INLINE_SMI_CHECK);
1958 } else { 1940 } else {
1959 __ li(a3, Operand(Smi::FromInt(i))); 1941 __ li(a3, Operand(Smi::FromInt(i)));
(...skipping 3475 matching lines...) Expand 10 before | Expand all | Expand 10 after
5435 Assembler::target_address_at(pc_immediate_load_address)) == 5417 Assembler::target_address_at(pc_immediate_load_address)) ==
5436 reinterpret_cast<uint32_t>( 5418 reinterpret_cast<uint32_t>(
5437 isolate->builtins()->OsrAfterStackCheck()->entry())); 5419 isolate->builtins()->OsrAfterStackCheck()->entry()));
5438 return OSR_AFTER_STACK_CHECK; 5420 return OSR_AFTER_STACK_CHECK;
5439 } 5421 }
5440 5422
5441 5423
5442 } } // namespace v8::internal 5424 } } // namespace v8::internal
5443 5425
5444 #endif // V8_TARGET_ARCH_MIPS 5426 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/ia32/full-codegen-ia32.cc ('k') | src/runtime/runtime-literals.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698