| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_PPC | 7 #if V8_TARGET_ARCH_PPC |
| 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 1601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1612 | 1612 |
| 1613 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { | 1613 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { |
| 1614 Comment cmnt(masm_, "[ ObjectLiteral"); | 1614 Comment cmnt(masm_, "[ ObjectLiteral"); |
| 1615 | 1615 |
| 1616 expr->BuildConstantProperties(isolate()); | 1616 expr->BuildConstantProperties(isolate()); |
| 1617 Handle<FixedArray> constant_properties = expr->constant_properties(); | 1617 Handle<FixedArray> constant_properties = expr->constant_properties(); |
| 1618 __ LoadP(r6, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 1618 __ LoadP(r6, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
| 1619 __ LoadP(r6, FieldMemOperand(r6, JSFunction::kLiteralsOffset)); | 1619 __ LoadP(r6, FieldMemOperand(r6, JSFunction::kLiteralsOffset)); |
| 1620 __ LoadSmiLiteral(r5, Smi::FromInt(expr->literal_index())); | 1620 __ LoadSmiLiteral(r5, Smi::FromInt(expr->literal_index())); |
| 1621 __ mov(r4, Operand(constant_properties)); | 1621 __ mov(r4, Operand(constant_properties)); |
| 1622 int flags = expr->fast_elements() ? ObjectLiteral::kFastElements | 1622 int flags = expr->ComputeFlags(); |
| 1623 : ObjectLiteral::kNoFlags; | |
| 1624 flags |= expr->has_function() ? ObjectLiteral::kHasFunction | |
| 1625 : ObjectLiteral::kNoFlags; | |
| 1626 __ LoadSmiLiteral(r3, Smi::FromInt(flags)); | 1623 __ LoadSmiLiteral(r3, Smi::FromInt(flags)); |
| 1627 int properties_count = constant_properties->length() / 2; | 1624 if (MustCreateObjectLiteralWithRuntime(expr)) { |
| 1628 if (expr->may_store_doubles() || expr->depth() > 1 || | |
| 1629 masm()->serializer_enabled() || flags != ObjectLiteral::kFastElements || | |
| 1630 properties_count > FastCloneShallowObjectStub::kMaximumClonedProperties) { | |
| 1631 __ Push(r6, r5, r4, r3); | 1625 __ Push(r6, r5, r4, r3); |
| 1632 __ CallRuntime(Runtime::kCreateObjectLiteral, 4); | 1626 __ CallRuntime(Runtime::kCreateObjectLiteral, 4); |
| 1633 } else { | 1627 } else { |
| 1634 FastCloneShallowObjectStub stub(isolate(), properties_count); | 1628 FastCloneShallowObjectStub stub(isolate(), expr->properties_count()); |
| 1635 __ CallStub(&stub); | 1629 __ CallStub(&stub); |
| 1636 } | 1630 } |
| 1637 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); | 1631 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); |
| 1638 | 1632 |
| 1639 // If result_saved is true the result is on top of the stack. If | 1633 // If result_saved is true the result is on top of the stack. If |
| 1640 // result_saved is false the result is in r3. | 1634 // result_saved is false the result is in r3. |
| 1641 bool result_saved = false; | 1635 bool result_saved = false; |
| 1642 | 1636 |
| 1643 // Mark all computed expressions that are bound to a key that | 1637 // Mark all computed expressions that are bound to a key that |
| 1644 // is shadowed by a later occurrence of the same key. For the | 1638 // is shadowed by a later occurrence of the same key. For the |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1814 } else { | 1808 } else { |
| 1815 context()->Plug(r3); | 1809 context()->Plug(r3); |
| 1816 } | 1810 } |
| 1817 } | 1811 } |
| 1818 | 1812 |
| 1819 | 1813 |
| 1820 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { | 1814 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { |
| 1821 Comment cmnt(masm_, "[ ArrayLiteral"); | 1815 Comment cmnt(masm_, "[ ArrayLiteral"); |
| 1822 | 1816 |
| 1823 expr->BuildConstantElements(isolate()); | 1817 expr->BuildConstantElements(isolate()); |
| 1824 int flags = expr->depth() == 1 ? ArrayLiteral::kShallowElements | |
| 1825 : ArrayLiteral::kNoFlags; | |
| 1826 | |
| 1827 ZoneList<Expression*>* subexprs = expr->values(); | |
| 1828 int length = subexprs->length(); | |
| 1829 Handle<FixedArray> constant_elements = expr->constant_elements(); | 1818 Handle<FixedArray> constant_elements = expr->constant_elements(); |
| 1830 DCHECK_EQ(2, constant_elements->length()); | 1819 bool has_fast_elements = |
| 1831 ElementsKind constant_elements_kind = | 1820 IsFastObjectElementsKind(expr->constant_elements_kind()); |
| 1832 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value()); | |
| 1833 bool has_fast_elements = IsFastObjectElementsKind(constant_elements_kind); | |
| 1834 Handle<FixedArrayBase> constant_elements_values( | 1821 Handle<FixedArrayBase> constant_elements_values( |
| 1835 FixedArrayBase::cast(constant_elements->get(1))); | 1822 FixedArrayBase::cast(constant_elements->get(1))); |
| 1836 | 1823 |
| 1837 AllocationSiteMode allocation_site_mode = TRACK_ALLOCATION_SITE; | 1824 AllocationSiteMode allocation_site_mode = TRACK_ALLOCATION_SITE; |
| 1838 if (has_fast_elements && !FLAG_allocation_site_pretenuring) { | 1825 if (has_fast_elements && !FLAG_allocation_site_pretenuring) { |
| 1839 // If the only customer of allocation sites is transitioning, then | 1826 // If the only customer of allocation sites is transitioning, then |
| 1840 // we can turn it off if we don't have anywhere else to transition to. | 1827 // we can turn it off if we don't have anywhere else to transition to. |
| 1841 allocation_site_mode = DONT_TRACK_ALLOCATION_SITE; | 1828 allocation_site_mode = DONT_TRACK_ALLOCATION_SITE; |
| 1842 } | 1829 } |
| 1843 | 1830 |
| 1844 __ LoadP(r6, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 1831 __ LoadP(r6, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
| 1845 __ LoadP(r6, FieldMemOperand(r6, JSFunction::kLiteralsOffset)); | 1832 __ LoadP(r6, FieldMemOperand(r6, JSFunction::kLiteralsOffset)); |
| 1846 __ LoadSmiLiteral(r5, Smi::FromInt(expr->literal_index())); | 1833 __ LoadSmiLiteral(r5, Smi::FromInt(expr->literal_index())); |
| 1847 __ mov(r4, Operand(constant_elements)); | 1834 __ mov(r4, Operand(constant_elements)); |
| 1848 if (expr->depth() > 1 || length > JSObject::kInitialMaxFastElementArray) { | 1835 if (MustCreateArrayLiteralWithRuntime(expr)) { |
| 1849 __ LoadSmiLiteral(r3, Smi::FromInt(flags)); | 1836 __ LoadSmiLiteral(r3, Smi::FromInt(expr->ComputeFlags())); |
| 1850 __ Push(r6, r5, r4, r3); | 1837 __ Push(r6, r5, r4, r3); |
| 1851 __ CallRuntime(Runtime::kCreateArrayLiteral, 4); | 1838 __ CallRuntime(Runtime::kCreateArrayLiteral, 4); |
| 1852 } else { | 1839 } else { |
| 1853 FastCloneShallowArrayStub stub(isolate(), allocation_site_mode); | 1840 FastCloneShallowArrayStub stub(isolate(), allocation_site_mode); |
| 1854 __ CallStub(&stub); | 1841 __ CallStub(&stub); |
| 1855 } | 1842 } |
| 1856 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); | 1843 PrepareForBailoutForId(expr->CreateLiteralId(), TOS_REG); |
| 1857 | 1844 |
| 1858 bool result_saved = false; // Is the result saved to the stack? | 1845 bool result_saved = false; // Is the result saved to the stack? |
| 1846 ZoneList<Expression*>* subexprs = expr->values(); |
| 1847 int length = subexprs->length(); |
| 1859 | 1848 |
| 1860 // Emit code to evaluate all the non-constant subexpressions and to store | 1849 // Emit code to evaluate all the non-constant subexpressions and to store |
| 1861 // them into the newly cloned array. | 1850 // them into the newly cloned array. |
| 1862 for (int i = 0; i < length; i++) { | 1851 for (int i = 0; i < length; i++) { |
| 1863 Expression* subexpr = subexprs->at(i); | 1852 Expression* subexpr = subexprs->at(i); |
| 1864 // If the subexpression is a literal or a simple materialized literal it | 1853 // If the subexpression is a literal or a simple materialized literal it |
| 1865 // is already set in the cloned array. | 1854 // is already set in the cloned array. |
| 1866 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; | 1855 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; |
| 1867 | 1856 |
| 1868 if (!result_saved) { | 1857 if (!result_saved) { |
| 1869 __ push(r3); | 1858 __ push(r3); |
| 1870 __ Push(Smi::FromInt(expr->literal_index())); | 1859 __ Push(Smi::FromInt(expr->literal_index())); |
| 1871 result_saved = true; | 1860 result_saved = true; |
| 1872 } | 1861 } |
| 1873 VisitForAccumulatorValue(subexpr); | 1862 VisitForAccumulatorValue(subexpr); |
| 1874 | 1863 |
| 1875 if (IsFastObjectElementsKind(constant_elements_kind)) { | 1864 if (has_fast_elements) { |
| 1876 int offset = FixedArray::kHeaderSize + (i * kPointerSize); | 1865 int offset = FixedArray::kHeaderSize + (i * kPointerSize); |
| 1877 __ LoadP(r8, MemOperand(sp, kPointerSize)); // Copy of array literal. | 1866 __ LoadP(r8, MemOperand(sp, kPointerSize)); // Copy of array literal. |
| 1878 __ LoadP(r4, FieldMemOperand(r8, JSObject::kElementsOffset)); | 1867 __ LoadP(r4, FieldMemOperand(r8, JSObject::kElementsOffset)); |
| 1879 __ StoreP(result_register(), FieldMemOperand(r4, offset), r0); | 1868 __ StoreP(result_register(), FieldMemOperand(r4, offset), r0); |
| 1880 // Update the write barrier for the array store. | 1869 // Update the write barrier for the array store. |
| 1881 __ RecordWriteField(r4, offset, result_register(), r5, kLRHasBeenSaved, | 1870 __ RecordWriteField(r4, offset, result_register(), r5, kLRHasBeenSaved, |
| 1882 kDontSaveFPRegs, EMIT_REMEMBERED_SET, | 1871 kDontSaveFPRegs, EMIT_REMEMBERED_SET, |
| 1883 INLINE_SMI_CHECK); | 1872 INLINE_SMI_CHECK); |
| 1884 } else { | 1873 } else { |
| 1885 __ LoadSmiLiteral(r6, Smi::FromInt(i)); | 1874 __ LoadSmiLiteral(r6, Smi::FromInt(i)); |
| (...skipping 3475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5361 return ON_STACK_REPLACEMENT; | 5350 return ON_STACK_REPLACEMENT; |
| 5362 } | 5351 } |
| 5363 | 5352 |
| 5364 DCHECK(interrupt_address == | 5353 DCHECK(interrupt_address == |
| 5365 isolate->builtins()->OsrAfterStackCheck()->entry()); | 5354 isolate->builtins()->OsrAfterStackCheck()->entry()); |
| 5366 return OSR_AFTER_STACK_CHECK; | 5355 return OSR_AFTER_STACK_CHECK; |
| 5367 } | 5356 } |
| 5368 } | 5357 } |
| 5369 } // namespace v8::internal | 5358 } // namespace v8::internal |
| 5370 #endif // V8_TARGET_ARCH_PPC | 5359 #endif // V8_TARGET_ARCH_PPC |
| OLD | NEW |