| 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 #if V8_TARGET_ARCH_PPC | 5 #if V8_TARGET_ARCH_PPC |
| 6 | 6 |
| 7 #include "src/code-stubs.h" | 7 #include "src/code-stubs.h" |
| 8 #include "src/api-arguments.h" | 8 #include "src/api-arguments.h" |
| 9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
| (...skipping 1701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1712 | 1712 |
| 1713 static void GenerateRecordCallTarget(MacroAssembler* masm) { | 1713 static void GenerateRecordCallTarget(MacroAssembler* masm) { |
| 1714 // Cache the called function in a feedback vector slot. Cache states | 1714 // Cache the called function in a feedback vector slot. Cache states |
| 1715 // are uninitialized, monomorphic (indicated by a JSFunction), and | 1715 // are uninitialized, monomorphic (indicated by a JSFunction), and |
| 1716 // megamorphic. | 1716 // megamorphic. |
| 1717 // r3 : number of arguments to the construct function | 1717 // r3 : number of arguments to the construct function |
| 1718 // r4 : the function to call | 1718 // r4 : the function to call |
| 1719 // r5 : feedback vector | 1719 // r5 : feedback vector |
| 1720 // r6 : slot in feedback vector (Smi) | 1720 // r6 : slot in feedback vector (Smi) |
| 1721 Label initialize, done, miss, megamorphic, not_array_function; | 1721 Label initialize, done, miss, megamorphic, not_array_function; |
| 1722 Label done_initialize_count, done_increment_count; | |
| 1723 | 1722 |
| 1724 DCHECK_EQ(*TypeFeedbackVector::MegamorphicSentinel(masm->isolate()), | 1723 DCHECK_EQ(*TypeFeedbackVector::MegamorphicSentinel(masm->isolate()), |
| 1725 masm->isolate()->heap()->megamorphic_symbol()); | 1724 masm->isolate()->heap()->megamorphic_symbol()); |
| 1726 DCHECK_EQ(*TypeFeedbackVector::UninitializedSentinel(masm->isolate()), | 1725 DCHECK_EQ(*TypeFeedbackVector::UninitializedSentinel(masm->isolate()), |
| 1727 masm->isolate()->heap()->uninitialized_symbol()); | 1726 masm->isolate()->heap()->uninitialized_symbol()); |
| 1728 | 1727 |
| 1729 const int count_offset = FixedArray::kHeaderSize + kPointerSize; | 1728 const int count_offset = FixedArray::kHeaderSize + kPointerSize; |
| 1730 | 1729 |
| 1731 // Load the cache state into r8. | 1730 // Load the cache state into r8. |
| 1732 __ SmiToPtrArrayOffset(r8, r6); | 1731 __ SmiToPtrArrayOffset(r8, r6); |
| 1733 __ add(r8, r5, r8); | 1732 __ add(r8, r5, r8); |
| 1734 __ LoadP(r8, FieldMemOperand(r8, FixedArray::kHeaderSize)); | 1733 __ LoadP(r8, FieldMemOperand(r8, FixedArray::kHeaderSize)); |
| 1735 | 1734 |
| 1736 // A monomorphic cache hit or an already megamorphic state: invoke the | 1735 // A monomorphic cache hit or an already megamorphic state: invoke the |
| 1737 // function without changing the state. | 1736 // function without changing the state. |
| 1738 // We don't know if r8 is a WeakCell or a Symbol, but it's harmless to read at | 1737 // We don't know if r8 is a WeakCell or a Symbol, but it's harmless to read at |
| 1739 // this position in a symbol (see static asserts in type-feedback-vector.h). | 1738 // this position in a symbol (see static asserts in type-feedback-vector.h). |
| 1740 Label check_allocation_site; | 1739 Label check_allocation_site; |
| 1741 Register feedback_map = r9; | 1740 Register feedback_map = r9; |
| 1742 Register weak_value = r10; | 1741 Register weak_value = r10; |
| 1743 __ LoadP(weak_value, FieldMemOperand(r8, WeakCell::kValueOffset)); | 1742 __ LoadP(weak_value, FieldMemOperand(r8, WeakCell::kValueOffset)); |
| 1744 __ cmp(r4, weak_value); | 1743 __ cmp(r4, weak_value); |
| 1745 __ beq(&done_increment_count); | 1744 __ beq(&done); |
| 1746 __ CompareRoot(r8, Heap::kmegamorphic_symbolRootIndex); | 1745 __ CompareRoot(r8, Heap::kmegamorphic_symbolRootIndex); |
| 1747 __ beq(&done); | 1746 __ beq(&done); |
| 1748 __ LoadP(feedback_map, FieldMemOperand(r8, HeapObject::kMapOffset)); | 1747 __ LoadP(feedback_map, FieldMemOperand(r8, HeapObject::kMapOffset)); |
| 1749 __ CompareRoot(feedback_map, Heap::kWeakCellMapRootIndex); | 1748 __ CompareRoot(feedback_map, Heap::kWeakCellMapRootIndex); |
| 1750 __ bne(&check_allocation_site); | 1749 __ bne(&check_allocation_site); |
| 1751 | 1750 |
| 1752 // If the weak cell is cleared, we have a new chance to become monomorphic. | 1751 // If the weak cell is cleared, we have a new chance to become monomorphic. |
| 1753 __ JumpIfSmi(weak_value, &initialize); | 1752 __ JumpIfSmi(weak_value, &initialize); |
| 1754 __ b(&megamorphic); | 1753 __ b(&megamorphic); |
| 1755 | 1754 |
| 1756 __ bind(&check_allocation_site); | 1755 __ bind(&check_allocation_site); |
| 1757 // If we came here, we need to see if we are the array function. | 1756 // If we came here, we need to see if we are the array function. |
| 1758 // If we didn't have a matching function, and we didn't find the megamorph | 1757 // If we didn't have a matching function, and we didn't find the megamorph |
| 1759 // sentinel, then we have in the slot either some other function or an | 1758 // sentinel, then we have in the slot either some other function or an |
| 1760 // AllocationSite. | 1759 // AllocationSite. |
| 1761 __ CompareRoot(feedback_map, Heap::kAllocationSiteMapRootIndex); | 1760 __ CompareRoot(feedback_map, Heap::kAllocationSiteMapRootIndex); |
| 1762 __ bne(&miss); | 1761 __ bne(&miss); |
| 1763 | 1762 |
| 1764 // Make sure the function is the Array() function | 1763 // Make sure the function is the Array() function |
| 1765 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r8); | 1764 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r8); |
| 1766 __ cmp(r4, r8); | 1765 __ cmp(r4, r8); |
| 1767 __ bne(&megamorphic); | 1766 __ bne(&megamorphic); |
| 1768 __ b(&done_increment_count); | 1767 __ b(&done); |
| 1769 | 1768 |
| 1770 __ bind(&miss); | 1769 __ bind(&miss); |
| 1771 | 1770 |
| 1772 // A monomorphic miss (i.e, here the cache is not uninitialized) goes | 1771 // A monomorphic miss (i.e, here the cache is not uninitialized) goes |
| 1773 // megamorphic. | 1772 // megamorphic. |
| 1774 __ CompareRoot(r8, Heap::kuninitialized_symbolRootIndex); | 1773 __ CompareRoot(r8, Heap::kuninitialized_symbolRootIndex); |
| 1775 __ beq(&initialize); | 1774 __ beq(&initialize); |
| 1776 // MegamorphicSentinel is an immortal immovable object (undefined) so no | 1775 // MegamorphicSentinel is an immortal immovable object (undefined) so no |
| 1777 // write-barrier is needed. | 1776 // write-barrier is needed. |
| 1778 __ bind(&megamorphic); | 1777 __ bind(&megamorphic); |
| 1779 __ SmiToPtrArrayOffset(r8, r6); | 1778 __ SmiToPtrArrayOffset(r8, r6); |
| 1780 __ add(r8, r5, r8); | 1779 __ add(r8, r5, r8); |
| 1781 __ LoadRoot(ip, Heap::kmegamorphic_symbolRootIndex); | 1780 __ LoadRoot(ip, Heap::kmegamorphic_symbolRootIndex); |
| 1782 __ StoreP(ip, FieldMemOperand(r8, FixedArray::kHeaderSize), r0); | 1781 __ StoreP(ip, FieldMemOperand(r8, FixedArray::kHeaderSize), r0); |
| 1783 __ jmp(&done); | 1782 __ jmp(&done); |
| 1784 | 1783 |
| 1785 // An uninitialized cache is patched with the function | 1784 // An uninitialized cache is patched with the function |
| 1786 __ bind(&initialize); | 1785 __ bind(&initialize); |
| 1787 | 1786 |
| 1788 // Make sure the function is the Array() function. | 1787 // Make sure the function is the Array() function. |
| 1789 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r8); | 1788 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r8); |
| 1790 __ cmp(r4, r8); | 1789 __ cmp(r4, r8); |
| 1791 __ bne(¬_array_function); | 1790 __ bne(¬_array_function); |
| 1792 | 1791 |
| 1793 // The target function is the Array constructor, | 1792 // The target function is the Array constructor, |
| 1794 // Create an AllocationSite if we don't already have it, store it in the | 1793 // Create an AllocationSite if we don't already have it, store it in the |
| 1795 // slot. | 1794 // slot. |
| 1796 CreateAllocationSiteStub create_stub(masm->isolate()); | 1795 CreateAllocationSiteStub create_stub(masm->isolate()); |
| 1797 CallStubInRecordCallTarget(masm, &create_stub); | 1796 CallStubInRecordCallTarget(masm, &create_stub); |
| 1798 __ b(&done_initialize_count); | 1797 __ b(&done); |
| 1799 | 1798 |
| 1800 __ bind(¬_array_function); | 1799 __ bind(¬_array_function); |
| 1801 | 1800 |
| 1802 CreateWeakCellStub weak_cell_stub(masm->isolate()); | 1801 CreateWeakCellStub weak_cell_stub(masm->isolate()); |
| 1803 CallStubInRecordCallTarget(masm, &weak_cell_stub); | 1802 CallStubInRecordCallTarget(masm, &weak_cell_stub); |
| 1804 | 1803 |
| 1805 __ bind(&done_initialize_count); | 1804 __ bind(&done); |
| 1806 // Initialize the call counter. | |
| 1807 __ LoadSmiLiteral(r8, Smi::FromInt(1)); | |
| 1808 __ SmiToPtrArrayOffset(r7, r6); | |
| 1809 __ add(r7, r5, r7); | |
| 1810 __ StoreP(r8, FieldMemOperand(r7, count_offset), r0); | |
| 1811 __ b(&done); | |
| 1812 | 1805 |
| 1813 __ bind(&done_increment_count); | 1806 // Increment the call count for all function calls. |
| 1814 | |
| 1815 // Increment the call count for monomorphic function calls. | |
| 1816 __ SmiToPtrArrayOffset(r8, r6); | 1807 __ SmiToPtrArrayOffset(r8, r6); |
| 1817 __ add(r8, r5, r8); | 1808 __ add(r8, r5, r8); |
| 1818 | 1809 |
| 1819 __ LoadP(r7, FieldMemOperand(r8, count_offset)); | 1810 __ LoadP(r7, FieldMemOperand(r8, count_offset)); |
| 1820 __ AddSmiLiteral(r7, r7, Smi::FromInt(1), r0); | 1811 __ AddSmiLiteral(r7, r7, Smi::FromInt(1), r0); |
| 1821 __ StoreP(r7, FieldMemOperand(r8, count_offset), r0); | 1812 __ StoreP(r7, FieldMemOperand(r8, count_offset), r0); |
| 1822 | |
| 1823 __ bind(&done); | |
| 1824 } | 1813 } |
| 1825 | 1814 |
| 1826 | 1815 |
| 1827 void CallConstructStub::Generate(MacroAssembler* masm) { | 1816 void CallConstructStub::Generate(MacroAssembler* masm) { |
| 1828 // r3 : number of arguments | 1817 // r3 : number of arguments |
| 1829 // r4 : the function to call | 1818 // r4 : the function to call |
| 1830 // r5 : feedback vector | 1819 // r5 : feedback vector |
| 1831 // r6 : slot in feedback vector (Smi, for RecordCallTarget) | 1820 // r6 : slot in feedback vector (Smi, for RecordCallTarget) |
| 1832 | 1821 |
| 1833 Label non_function; | 1822 Label non_function; |
| (...skipping 3607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5441 fp, (PropertyCallbackArguments::kReturnValueOffset + 3) * kPointerSize); | 5430 fp, (PropertyCallbackArguments::kReturnValueOffset + 3) * kPointerSize); |
| 5442 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, | 5431 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, |
| 5443 kStackUnwindSpace, NULL, return_value_operand, NULL); | 5432 kStackUnwindSpace, NULL, return_value_operand, NULL); |
| 5444 } | 5433 } |
| 5445 | 5434 |
| 5446 #undef __ | 5435 #undef __ |
| 5447 } // namespace internal | 5436 } // namespace internal |
| 5448 } // namespace v8 | 5437 } // namespace v8 |
| 5449 | 5438 |
| 5450 #endif // V8_TARGET_ARCH_PPC | 5439 #endif // V8_TARGET_ARCH_PPC |
| OLD | NEW |