OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_ARM64 | 7 #if V8_TARGET_ARCH_ARM64 |
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 1652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1663 | 1663 |
1664 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { | 1664 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { |
1665 Comment cmnt(masm_, "[ ObjectLiteral"); | 1665 Comment cmnt(masm_, "[ ObjectLiteral"); |
1666 | 1666 |
1667 expr->BuildConstantProperties(isolate()); | 1667 expr->BuildConstantProperties(isolate()); |
1668 Handle<FixedArray> constant_properties = expr->constant_properties(); | 1668 Handle<FixedArray> constant_properties = expr->constant_properties(); |
1669 __ Ldr(x3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 1669 __ Ldr(x3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
1670 __ Ldr(x3, FieldMemOperand(x3, JSFunction::kLiteralsOffset)); | 1670 __ Ldr(x3, FieldMemOperand(x3, JSFunction::kLiteralsOffset)); |
1671 __ Mov(x2, Smi::FromInt(expr->literal_index())); | 1671 __ Mov(x2, Smi::FromInt(expr->literal_index())); |
1672 __ Mov(x1, Operand(constant_properties)); | 1672 __ Mov(x1, Operand(constant_properties)); |
1673 int flags = expr->fast_elements() | 1673 int flags = expr->ComputeFlags(); |
1674 ? ObjectLiteral::kFastElements | |
1675 : ObjectLiteral::kNoFlags; | |
1676 flags |= expr->has_function() | |
1677 ? ObjectLiteral::kHasFunction | |
1678 : ObjectLiteral::kNoFlags; | |
1679 __ Mov(x0, Smi::FromInt(flags)); | 1674 __ Mov(x0, Smi::FromInt(flags)); |
1680 int properties_count = constant_properties->length() / 2; | 1675 if (MustCreateObjectLiteralWithRuntime(expr)) { |
1681 const int max_cloned_properties = | |
1682 FastCloneShallowObjectStub::kMaximumClonedProperties; | |
1683 if (expr->may_store_doubles() || expr->depth() > 1 || | |
1684 masm()->serializer_enabled() || flags != ObjectLiteral::kFastElements || | |
1685 properties_count > max_cloned_properties) { | |
1686 __ Push(x3, x2, x1, x0); | 1676 __ Push(x3, x2, x1, x0); |
1687 __ CallRuntime(Runtime::kCreateObjectLiteral, 4); | 1677 __ CallRuntime(Runtime::kCreateObjectLiteral, 4); |
1688 } else { | 1678 } else { |
1689 FastCloneShallowObjectStub stub(isolate(), properties_count); | 1679 FastCloneShallowObjectStub stub(isolate(), expr->properties_count()); |
1690 __ CallStub(&stub); | 1680 __ CallStub(&stub); |
1691 } | 1681 } |
1692 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); | 1682 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); |
1693 | 1683 |
1694 // If result_saved is true the result is on top of the stack. If | 1684 // If result_saved is true the result is on top of the stack. If |
1695 // result_saved is false the result is in x0. | 1685 // result_saved is false the result is in x0. |
1696 bool result_saved = false; | 1686 bool result_saved = false; |
1697 | 1687 |
1698 // Mark all computed expressions that are bound to a key that | 1688 // Mark all computed expressions that are bound to a key that |
1699 // is shadowed by a later occurrence of the same key. For the | 1689 // 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... |
1871 } else { | 1861 } else { |
1872 context()->Plug(x0); | 1862 context()->Plug(x0); |
1873 } | 1863 } |
1874 } | 1864 } |
1875 | 1865 |
1876 | 1866 |
1877 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { | 1867 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { |
1878 Comment cmnt(masm_, "[ ArrayLiteral"); | 1868 Comment cmnt(masm_, "[ ArrayLiteral"); |
1879 | 1869 |
1880 expr->BuildConstantElements(isolate()); | 1870 expr->BuildConstantElements(isolate()); |
1881 int flags = (expr->depth() == 1) ? ArrayLiteral::kShallowElements | |
1882 : ArrayLiteral::kNoFlags; | |
1883 | |
1884 ZoneList<Expression*>* subexprs = expr->values(); | |
1885 int length = subexprs->length(); | |
1886 Handle<FixedArray> constant_elements = expr->constant_elements(); | 1871 Handle<FixedArray> constant_elements = expr->constant_elements(); |
1887 DCHECK_EQ(2, constant_elements->length()); | 1872 bool has_fast_elements = |
1888 ElementsKind constant_elements_kind = | 1873 IsFastObjectElementsKind(expr->constant_elements_kind()); |
1889 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value()); | |
1890 bool has_fast_elements = IsFastObjectElementsKind(constant_elements_kind); | |
1891 Handle<FixedArrayBase> constant_elements_values( | |
1892 FixedArrayBase::cast(constant_elements->get(1))); | |
1893 | 1874 |
1894 AllocationSiteMode allocation_site_mode = TRACK_ALLOCATION_SITE; | 1875 AllocationSiteMode allocation_site_mode = TRACK_ALLOCATION_SITE; |
1895 if (has_fast_elements && !FLAG_allocation_site_pretenuring) { | 1876 if (has_fast_elements && !FLAG_allocation_site_pretenuring) { |
1896 // If the only customer of allocation sites is transitioning, then | 1877 // If the only customer of allocation sites is transitioning, then |
1897 // we can turn it off if we don't have anywhere else to transition to. | 1878 // we can turn it off if we don't have anywhere else to transition to. |
1898 allocation_site_mode = DONT_TRACK_ALLOCATION_SITE; | 1879 allocation_site_mode = DONT_TRACK_ALLOCATION_SITE; |
1899 } | 1880 } |
1900 | 1881 |
1901 __ Ldr(x3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 1882 __ Ldr(x3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
1902 __ Ldr(x3, FieldMemOperand(x3, JSFunction::kLiteralsOffset)); | 1883 __ Ldr(x3, FieldMemOperand(x3, JSFunction::kLiteralsOffset)); |
1903 __ Mov(x2, Smi::FromInt(expr->literal_index())); | 1884 __ Mov(x2, Smi::FromInt(expr->literal_index())); |
1904 __ Mov(x1, Operand(constant_elements)); | 1885 __ Mov(x1, Operand(constant_elements)); |
1905 if (expr->depth() > 1 || length > JSObject::kInitialMaxFastElementArray) { | 1886 if (MustCreateArrayLiteralWithRuntime(expr)) { |
1906 __ Mov(x0, Smi::FromInt(flags)); | 1887 __ Mov(x0, Smi::FromInt(expr->ComputeFlags())); |
1907 __ Push(x3, x2, x1, x0); | 1888 __ Push(x3, x2, x1, x0); |
1908 __ CallRuntime(Runtime::kCreateArrayLiteral, 4); | 1889 __ CallRuntime(Runtime::kCreateArrayLiteral, 4); |
1909 } else { | 1890 } else { |
1910 FastCloneShallowArrayStub stub(isolate(), allocation_site_mode); | 1891 FastCloneShallowArrayStub stub(isolate(), allocation_site_mode); |
1911 __ CallStub(&stub); | 1892 __ CallStub(&stub); |
1912 } | 1893 } |
1913 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); | 1894 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); |
1914 | 1895 |
1915 bool result_saved = false; // Is the result saved to the stack? | 1896 bool result_saved = false; // Is the result saved to the stack? |
| 1897 ZoneList<Expression*>* subexprs = expr->values(); |
| 1898 int length = subexprs->length(); |
1916 | 1899 |
1917 // Emit code to evaluate all the non-constant subexpressions and to store | 1900 // Emit code to evaluate all the non-constant subexpressions and to store |
1918 // them into the newly cloned array. | 1901 // them into the newly cloned array. |
1919 for (int i = 0; i < length; i++) { | 1902 for (int i = 0; i < length; i++) { |
1920 Expression* subexpr = subexprs->at(i); | 1903 Expression* subexpr = subexprs->at(i); |
1921 // If the subexpression is a literal or a simple materialized literal it | 1904 // If the subexpression is a literal or a simple materialized literal it |
1922 // is already set in the cloned array. | 1905 // is already set in the cloned array. |
1923 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; | 1906 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; |
1924 | 1907 |
1925 if (!result_saved) { | 1908 if (!result_saved) { |
1926 __ Mov(x1, Smi::FromInt(expr->literal_index())); | 1909 __ Mov(x1, Smi::FromInt(expr->literal_index())); |
1927 __ Push(x0, x1); | 1910 __ Push(x0, x1); |
1928 result_saved = true; | 1911 result_saved = true; |
1929 } | 1912 } |
1930 VisitForAccumulatorValue(subexpr); | 1913 VisitForAccumulatorValue(subexpr); |
1931 | 1914 |
1932 if (IsFastObjectElementsKind(constant_elements_kind)) { | 1915 if (has_fast_elements) { |
1933 int offset = FixedArray::kHeaderSize + (i * kPointerSize); | 1916 int offset = FixedArray::kHeaderSize + (i * kPointerSize); |
1934 __ Peek(x6, kPointerSize); // Copy of array literal. | 1917 __ Peek(x6, kPointerSize); // Copy of array literal. |
1935 __ Ldr(x1, FieldMemOperand(x6, JSObject::kElementsOffset)); | 1918 __ Ldr(x1, FieldMemOperand(x6, JSObject::kElementsOffset)); |
1936 __ Str(result_register(), FieldMemOperand(x1, offset)); | 1919 __ Str(result_register(), FieldMemOperand(x1, offset)); |
1937 // Update the write barrier for the array store. | 1920 // Update the write barrier for the array store. |
1938 __ RecordWriteField(x1, offset, result_register(), x10, | 1921 __ RecordWriteField(x1, offset, result_register(), x10, |
1939 kLRHasBeenSaved, kDontSaveFPRegs, | 1922 kLRHasBeenSaved, kDontSaveFPRegs, |
1940 EMIT_REMEMBERED_SET, INLINE_SMI_CHECK); | 1923 EMIT_REMEMBERED_SET, INLINE_SMI_CHECK); |
1941 } else { | 1924 } else { |
1942 __ Mov(x3, Smi::FromInt(i)); | 1925 __ Mov(x3, Smi::FromInt(i)); |
(...skipping 3538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5481 return previous_; | 5464 return previous_; |
5482 } | 5465 } |
5483 | 5466 |
5484 | 5467 |
5485 #undef __ | 5468 #undef __ |
5486 | 5469 |
5487 | 5470 |
5488 } } // namespace v8::internal | 5471 } } // namespace v8::internal |
5489 | 5472 |
5490 #endif // V8_TARGET_ARCH_ARM64 | 5473 #endif // V8_TARGET_ARCH_ARM64 |
OLD | NEW |