OLD | NEW |
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 1659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1670 | 1670 |
1671 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { | 1671 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { |
1672 Comment cmnt(masm_, "[ ObjectLiteral"); | 1672 Comment cmnt(masm_, "[ ObjectLiteral"); |
1673 | 1673 |
1674 expr->BuildConstantProperties(isolate()); | 1674 expr->BuildConstantProperties(isolate()); |
1675 Handle<FixedArray> constant_properties = expr->constant_properties(); | 1675 Handle<FixedArray> constant_properties = expr->constant_properties(); |
1676 __ lw(a3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 1676 __ lw(a3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
1677 __ lw(a3, FieldMemOperand(a3, JSFunction::kLiteralsOffset)); | 1677 __ lw(a3, FieldMemOperand(a3, JSFunction::kLiteralsOffset)); |
1678 __ li(a2, Operand(Smi::FromInt(expr->literal_index()))); | 1678 __ li(a2, Operand(Smi::FromInt(expr->literal_index()))); |
1679 __ li(a1, Operand(constant_properties)); | 1679 __ li(a1, Operand(constant_properties)); |
1680 int flags = expr->fast_elements() | 1680 __ li(a0, Operand(Smi::FromInt(expr->ComputeFlags()))); |
1681 ? ObjectLiteral::kFastElements | 1681 if (MustCreateObjectLiteralWithRuntime(expr)) { |
1682 : ObjectLiteral::kNoFlags; | |
1683 flags |= expr->has_function() | |
1684 ? ObjectLiteral::kHasFunction | |
1685 : ObjectLiteral::kNoFlags; | |
1686 __ li(a0, Operand(Smi::FromInt(flags))); | |
1687 int properties_count = constant_properties->length() / 2; | |
1688 if (expr->may_store_doubles() || expr->depth() > 1 || | |
1689 masm()->serializer_enabled() || flags != ObjectLiteral::kFastElements || | |
1690 properties_count > FastCloneShallowObjectStub::kMaximumClonedProperties) { | |
1691 __ Push(a3, a2, a1, a0); | 1682 __ Push(a3, a2, a1, a0); |
1692 __ CallRuntime(Runtime::kCreateObjectLiteral, 4); | 1683 __ CallRuntime(Runtime::kCreateObjectLiteral, 4); |
1693 } else { | 1684 } else { |
1694 FastCloneShallowObjectStub stub(isolate(), properties_count); | 1685 FastCloneShallowObjectStub stub(isolate(), expr->properties_count()); |
1695 __ CallStub(&stub); | 1686 __ CallStub(&stub); |
1696 } | 1687 } |
1697 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); | 1688 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); |
1698 | 1689 |
1699 // If result_saved is true the result is on top of the stack. If | 1690 // If result_saved is true the result is on top of the stack. If |
1700 // result_saved is false the result is in v0. | 1691 // result_saved is false the result is in v0. |
1701 bool result_saved = false; | 1692 bool result_saved = false; |
1702 | 1693 |
1703 // Mark all computed expressions that are bound to a key that | 1694 // Mark all computed expressions that are bound to a key that |
1704 // is shadowed by a later occurrence of the same key. For the | 1695 // is shadowed by a later occurrence of the same key. For the |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1876 } else { | 1867 } else { |
1877 context()->Plug(v0); | 1868 context()->Plug(v0); |
1878 } | 1869 } |
1879 } | 1870 } |
1880 | 1871 |
1881 | 1872 |
1882 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { | 1873 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { |
1883 Comment cmnt(masm_, "[ ArrayLiteral"); | 1874 Comment cmnt(masm_, "[ ArrayLiteral"); |
1884 | 1875 |
1885 expr->BuildConstantElements(isolate()); | 1876 expr->BuildConstantElements(isolate()); |
1886 int flags = expr->depth() == 1 | |
1887 ? ArrayLiteral::kShallowElements | |
1888 : ArrayLiteral::kNoFlags; | |
1889 | |
1890 ZoneList<Expression*>* subexprs = expr->values(); | |
1891 int length = subexprs->length(); | |
1892 | 1877 |
1893 Handle<FixedArray> constant_elements = expr->constant_elements(); | 1878 Handle<FixedArray> constant_elements = expr->constant_elements(); |
1894 DCHECK_EQ(2, constant_elements->length()); | |
1895 ElementsKind constant_elements_kind = | |
1896 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value()); | |
1897 bool has_fast_elements = | 1879 bool has_fast_elements = |
1898 IsFastObjectElementsKind(constant_elements_kind); | 1880 IsFastObjectElementsKind(expr->constant_elements_kind()); |
1899 Handle<FixedArrayBase> constant_elements_values( | |
1900 FixedArrayBase::cast(constant_elements->get(1))); | |
1901 | 1881 |
1902 AllocationSiteMode allocation_site_mode = TRACK_ALLOCATION_SITE; | 1882 AllocationSiteMode allocation_site_mode = TRACK_ALLOCATION_SITE; |
1903 if (has_fast_elements && !FLAG_allocation_site_pretenuring) { | 1883 if (has_fast_elements && !FLAG_allocation_site_pretenuring) { |
1904 // If the only customer of allocation sites is transitioning, then | 1884 // If the only customer of allocation sites is transitioning, then |
1905 // we can turn it off if we don't have anywhere else to transition to. | 1885 // we can turn it off if we don't have anywhere else to transition to. |
1906 allocation_site_mode = DONT_TRACK_ALLOCATION_SITE; | 1886 allocation_site_mode = DONT_TRACK_ALLOCATION_SITE; |
1907 } | 1887 } |
1908 | 1888 |
1909 __ mov(a0, result_register()); | 1889 __ mov(a0, result_register()); |
1910 __ lw(a3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 1890 __ lw(a3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
1911 __ lw(a3, FieldMemOperand(a3, JSFunction::kLiteralsOffset)); | 1891 __ lw(a3, FieldMemOperand(a3, JSFunction::kLiteralsOffset)); |
1912 __ li(a2, Operand(Smi::FromInt(expr->literal_index()))); | 1892 __ li(a2, Operand(Smi::FromInt(expr->literal_index()))); |
1913 __ li(a1, Operand(constant_elements)); | 1893 __ li(a1, Operand(constant_elements)); |
1914 if (expr->depth() > 1 || length > JSObject::kInitialMaxFastElementArray) { | 1894 if (MustCreateArrayLiteralWithRuntime(expr)) { |
1915 __ li(a0, Operand(Smi::FromInt(flags))); | 1895 __ li(a0, Operand(Smi::FromInt(expr->ComputeFlags()))); |
1916 __ Push(a3, a2, a1, a0); | 1896 __ Push(a3, a2, a1, a0); |
1917 __ CallRuntime(Runtime::kCreateArrayLiteral, 4); | 1897 __ CallRuntime(Runtime::kCreateArrayLiteral, 4); |
1918 } else { | 1898 } else { |
1919 FastCloneShallowArrayStub stub(isolate(), allocation_site_mode); | 1899 FastCloneShallowArrayStub stub(isolate(), allocation_site_mode); |
1920 __ CallStub(&stub); | 1900 __ CallStub(&stub); |
1921 } | 1901 } |
1922 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); | 1902 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); |
1923 | 1903 |
1924 bool result_saved = false; // Is the result saved to the stack? | 1904 bool result_saved = false; // Is the result saved to the stack? |
| 1905 ZoneList<Expression*>* subexprs = expr->values(); |
| 1906 int length = subexprs->length(); |
1925 | 1907 |
1926 // Emit code to evaluate all the non-constant subexpressions and to store | 1908 // Emit code to evaluate all the non-constant subexpressions and to store |
1927 // them into the newly cloned array. | 1909 // them into the newly cloned array. |
1928 for (int i = 0; i < length; i++) { | 1910 for (int i = 0; i < length; i++) { |
1929 Expression* subexpr = subexprs->at(i); | 1911 Expression* subexpr = subexprs->at(i); |
1930 // If the subexpression is a literal or a simple materialized literal it | 1912 // If the subexpression is a literal or a simple materialized literal it |
1931 // is already set in the cloned array. | 1913 // is already set in the cloned array. |
1932 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; | 1914 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; |
1933 | 1915 |
1934 if (!result_saved) { | 1916 if (!result_saved) { |
1935 __ push(v0); // array literal | 1917 __ push(v0); // array literal |
1936 __ Push(Smi::FromInt(expr->literal_index())); | 1918 __ Push(Smi::FromInt(expr->literal_index())); |
1937 result_saved = true; | 1919 result_saved = true; |
1938 } | 1920 } |
1939 | 1921 |
1940 VisitForAccumulatorValue(subexpr); | 1922 VisitForAccumulatorValue(subexpr); |
1941 | 1923 |
1942 if (IsFastObjectElementsKind(constant_elements_kind)) { | 1924 if (has_fast_elements) { |
1943 int offset = FixedArray::kHeaderSize + (i * kPointerSize); | 1925 int offset = FixedArray::kHeaderSize + (i * kPointerSize); |
1944 __ lw(t2, MemOperand(sp, kPointerSize)); // Copy of array literal. | 1926 __ lw(t2, MemOperand(sp, kPointerSize)); // Copy of array literal. |
1945 __ lw(a1, FieldMemOperand(t2, JSObject::kElementsOffset)); | 1927 __ lw(a1, FieldMemOperand(t2, JSObject::kElementsOffset)); |
1946 __ sw(result_register(), FieldMemOperand(a1, offset)); | 1928 __ sw(result_register(), FieldMemOperand(a1, offset)); |
1947 // Update the write barrier for the array store. | 1929 // Update the write barrier for the array store. |
1948 __ RecordWriteField(a1, offset, result_register(), a2, | 1930 __ RecordWriteField(a1, offset, result_register(), a2, |
1949 kRAHasBeenSaved, kDontSaveFPRegs, | 1931 kRAHasBeenSaved, kDontSaveFPRegs, |
1950 EMIT_REMEMBERED_SET, INLINE_SMI_CHECK); | 1932 EMIT_REMEMBERED_SET, INLINE_SMI_CHECK); |
1951 } else { | 1933 } else { |
1952 __ li(a3, Operand(Smi::FromInt(i))); | 1934 __ li(a3, Operand(Smi::FromInt(i))); |
(...skipping 3491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5444 Assembler::target_address_at(pc_immediate_load_address)) == | 5426 Assembler::target_address_at(pc_immediate_load_address)) == |
5445 reinterpret_cast<uint32_t>( | 5427 reinterpret_cast<uint32_t>( |
5446 isolate->builtins()->OsrAfterStackCheck()->entry())); | 5428 isolate->builtins()->OsrAfterStackCheck()->entry())); |
5447 return OSR_AFTER_STACK_CHECK; | 5429 return OSR_AFTER_STACK_CHECK; |
5448 } | 5430 } |
5449 | 5431 |
5450 | 5432 |
5451 } } // namespace v8::internal | 5433 } } // namespace v8::internal |
5452 | 5434 |
5453 #endif // V8_TARGET_ARCH_MIPS | 5435 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |