| 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 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 __ Ldr(x3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 1676 __ Ldr(x3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
| 1677 __ Ldr(x3, FieldMemOperand(x3, JSFunction::kLiteralsOffset)); | 1677 __ Ldr(x3, FieldMemOperand(x3, JSFunction::kLiteralsOffset)); |
| 1678 __ Mov(x2, Smi::FromInt(expr->literal_index())); | 1678 __ Mov(x2, Smi::FromInt(expr->literal_index())); |
| 1679 __ Mov(x1, Operand(constant_properties)); | 1679 __ Mov(x1, Operand(constant_properties)); |
| 1680 int flags = expr->fast_elements() | 1680 int flags = expr->ComputeFlags(); |
| 1681 ? ObjectLiteral::kFastElements | |
| 1682 : ObjectLiteral::kNoFlags; | |
| 1683 flags |= expr->has_function() | |
| 1684 ? ObjectLiteral::kHasFunction | |
| 1685 : ObjectLiteral::kNoFlags; | |
| 1686 __ Mov(x0, Smi::FromInt(flags)); | 1681 __ Mov(x0, Smi::FromInt(flags)); |
| 1687 int properties_count = constant_properties->length() / 2; | 1682 if (MustCreateObjectLiteralWithRuntime(expr)) { |
| 1688 const int max_cloned_properties = | |
| 1689 FastCloneShallowObjectStub::kMaximumClonedProperties; | |
| 1690 if (expr->may_store_doubles() || expr->depth() > 1 || | |
| 1691 masm()->serializer_enabled() || flags != ObjectLiteral::kFastElements || | |
| 1692 properties_count > max_cloned_properties) { | |
| 1693 __ Push(x3, x2, x1, x0); | 1683 __ Push(x3, x2, x1, x0); |
| 1694 __ CallRuntime(Runtime::kCreateObjectLiteral, 4); | 1684 __ CallRuntime(Runtime::kCreateObjectLiteral, 4); |
| 1695 } else { | 1685 } else { |
| 1696 FastCloneShallowObjectStub stub(isolate(), properties_count); | 1686 FastCloneShallowObjectStub stub(isolate(), expr->properties_count()); |
| 1697 __ CallStub(&stub); | 1687 __ CallStub(&stub); |
| 1698 } | 1688 } |
| 1699 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); | 1689 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); |
| 1700 | 1690 |
| 1701 // If result_saved is true the result is on top of the stack. If | 1691 // If result_saved is true the result is on top of the stack. If |
| 1702 // result_saved is false the result is in x0. | 1692 // result_saved is false the result is in x0. |
| 1703 bool result_saved = false; | 1693 bool result_saved = false; |
| 1704 | 1694 |
| 1705 // Mark all computed expressions that are bound to a key that | 1695 // Mark all computed expressions that are bound to a key that |
| 1706 // is shadowed by a later occurrence of the same key. For the | 1696 // 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... |
| 1878 } else { | 1868 } else { |
| 1879 context()->Plug(x0); | 1869 context()->Plug(x0); |
| 1880 } | 1870 } |
| 1881 } | 1871 } |
| 1882 | 1872 |
| 1883 | 1873 |
| 1884 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { | 1874 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { |
| 1885 Comment cmnt(masm_, "[ ArrayLiteral"); | 1875 Comment cmnt(masm_, "[ ArrayLiteral"); |
| 1886 | 1876 |
| 1887 expr->BuildConstantElements(isolate()); | 1877 expr->BuildConstantElements(isolate()); |
| 1888 int flags = (expr->depth() == 1) ? ArrayLiteral::kShallowElements | |
| 1889 : ArrayLiteral::kNoFlags; | |
| 1890 | |
| 1891 ZoneList<Expression*>* subexprs = expr->values(); | |
| 1892 int length = subexprs->length(); | |
| 1893 Handle<FixedArray> constant_elements = expr->constant_elements(); | 1878 Handle<FixedArray> constant_elements = expr->constant_elements(); |
| 1894 DCHECK_EQ(2, constant_elements->length()); | 1879 bool has_fast_elements = |
| 1895 ElementsKind constant_elements_kind = | 1880 IsFastObjectElementsKind(expr->constant_elements_kind()); |
| 1896 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value()); | |
| 1897 bool has_fast_elements = IsFastObjectElementsKind(constant_elements_kind); | |
| 1898 Handle<FixedArrayBase> constant_elements_values( | |
| 1899 FixedArrayBase::cast(constant_elements->get(1))); | |
| 1900 | 1881 |
| 1901 AllocationSiteMode allocation_site_mode = TRACK_ALLOCATION_SITE; | 1882 AllocationSiteMode allocation_site_mode = TRACK_ALLOCATION_SITE; |
| 1902 if (has_fast_elements && !FLAG_allocation_site_pretenuring) { | 1883 if (has_fast_elements && !FLAG_allocation_site_pretenuring) { |
| 1903 // If the only customer of allocation sites is transitioning, then | 1884 // If the only customer of allocation sites is transitioning, then |
| 1904 // 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. |
| 1905 allocation_site_mode = DONT_TRACK_ALLOCATION_SITE; | 1886 allocation_site_mode = DONT_TRACK_ALLOCATION_SITE; |
| 1906 } | 1887 } |
| 1907 | 1888 |
| 1908 __ Ldr(x3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 1889 __ Ldr(x3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
| 1909 __ Ldr(x3, FieldMemOperand(x3, JSFunction::kLiteralsOffset)); | 1890 __ Ldr(x3, FieldMemOperand(x3, JSFunction::kLiteralsOffset)); |
| 1910 __ Mov(x2, Smi::FromInt(expr->literal_index())); | 1891 __ Mov(x2, Smi::FromInt(expr->literal_index())); |
| 1911 __ Mov(x1, Operand(constant_elements)); | 1892 __ Mov(x1, Operand(constant_elements)); |
| 1912 if (expr->depth() > 1 || length > JSObject::kInitialMaxFastElementArray) { | 1893 if (MustCreateArrayLiteralWithRuntime(expr)) { |
| 1913 __ Mov(x0, Smi::FromInt(flags)); | 1894 __ Mov(x0, Smi::FromInt(expr->ComputeFlags())); |
| 1914 __ Push(x3, x2, x1, x0); | 1895 __ Push(x3, x2, x1, x0); |
| 1915 __ CallRuntime(Runtime::kCreateArrayLiteral, 4); | 1896 __ CallRuntime(Runtime::kCreateArrayLiteral, 4); |
| 1916 } else { | 1897 } else { |
| 1917 FastCloneShallowArrayStub stub(isolate(), allocation_site_mode); | 1898 FastCloneShallowArrayStub stub(isolate(), allocation_site_mode); |
| 1918 __ CallStub(&stub); | 1899 __ CallStub(&stub); |
| 1919 } | 1900 } |
| 1920 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); | 1901 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); |
| 1921 | 1902 |
| 1922 bool result_saved = false; // Is the result saved to the stack? | 1903 bool result_saved = false; // Is the result saved to the stack? |
| 1904 ZoneList<Expression*>* subexprs = expr->values(); |
| 1905 int length = subexprs->length(); |
| 1923 | 1906 |
| 1924 // Emit code to evaluate all the non-constant subexpressions and to store | 1907 // Emit code to evaluate all the non-constant subexpressions and to store |
| 1925 // them into the newly cloned array. | 1908 // them into the newly cloned array. |
| 1926 for (int i = 0; i < length; i++) { | 1909 for (int i = 0; i < length; i++) { |
| 1927 Expression* subexpr = subexprs->at(i); | 1910 Expression* subexpr = subexprs->at(i); |
| 1928 // If the subexpression is a literal or a simple materialized literal it | 1911 // If the subexpression is a literal or a simple materialized literal it |
| 1929 // is already set in the cloned array. | 1912 // is already set in the cloned array. |
| 1930 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; | 1913 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; |
| 1931 | 1914 |
| 1932 if (!result_saved) { | 1915 if (!result_saved) { |
| 1933 __ Mov(x1, Smi::FromInt(expr->literal_index())); | 1916 __ Mov(x1, Smi::FromInt(expr->literal_index())); |
| 1934 __ Push(x0, x1); | 1917 __ Push(x0, x1); |
| 1935 result_saved = true; | 1918 result_saved = true; |
| 1936 } | 1919 } |
| 1937 VisitForAccumulatorValue(subexpr); | 1920 VisitForAccumulatorValue(subexpr); |
| 1938 | 1921 |
| 1939 if (IsFastObjectElementsKind(constant_elements_kind)) { | 1922 if (has_fast_elements) { |
| 1940 int offset = FixedArray::kHeaderSize + (i * kPointerSize); | 1923 int offset = FixedArray::kHeaderSize + (i * kPointerSize); |
| 1941 __ Peek(x6, kPointerSize); // Copy of array literal. | 1924 __ Peek(x6, kPointerSize); // Copy of array literal. |
| 1942 __ Ldr(x1, FieldMemOperand(x6, JSObject::kElementsOffset)); | 1925 __ Ldr(x1, FieldMemOperand(x6, JSObject::kElementsOffset)); |
| 1943 __ Str(result_register(), FieldMemOperand(x1, offset)); | 1926 __ Str(result_register(), FieldMemOperand(x1, offset)); |
| 1944 // Update the write barrier for the array store. | 1927 // Update the write barrier for the array store. |
| 1945 __ RecordWriteField(x1, offset, result_register(), x10, | 1928 __ RecordWriteField(x1, offset, result_register(), x10, |
| 1946 kLRHasBeenSaved, kDontSaveFPRegs, | 1929 kLRHasBeenSaved, kDontSaveFPRegs, |
| 1947 EMIT_REMEMBERED_SET, INLINE_SMI_CHECK); | 1930 EMIT_REMEMBERED_SET, INLINE_SMI_CHECK); |
| 1948 } else { | 1931 } else { |
| 1949 __ Mov(x3, Smi::FromInt(i)); | 1932 __ Mov(x3, Smi::FromInt(i)); |
| (...skipping 3521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5471 } | 5454 } |
| 5472 } | 5455 } |
| 5473 | 5456 |
| 5474 return INTERRUPT; | 5457 return INTERRUPT; |
| 5475 } | 5458 } |
| 5476 | 5459 |
| 5477 | 5460 |
| 5478 } } // namespace v8::internal | 5461 } } // namespace v8::internal |
| 5479 | 5462 |
| 5480 #endif // V8_TARGET_ARCH_ARM64 | 5463 #endif // V8_TARGET_ARCH_ARM64 |
| OLD | NEW |