Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(736)

Side by Side Diff: src/s390/code-stubs-s390.cc

Issue 2330353005: PPC/s390: CallConstruct also gets call count information if megamorphic. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/ppc/code-stubs-ppc.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_S390 5 #if V8_TARGET_ARCH_S390
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 1708 matching lines...) Expand 10 before | Expand all | Expand 10 after
1719 1719
1720 static void GenerateRecordCallTarget(MacroAssembler* masm) { 1720 static void GenerateRecordCallTarget(MacroAssembler* masm) {
1721 // Cache the called function in a feedback vector slot. Cache states 1721 // Cache the called function in a feedback vector slot. Cache states
1722 // are uninitialized, monomorphic (indicated by a JSFunction), and 1722 // are uninitialized, monomorphic (indicated by a JSFunction), and
1723 // megamorphic. 1723 // megamorphic.
1724 // r2 : number of arguments to the construct function 1724 // r2 : number of arguments to the construct function
1725 // r3 : the function to call 1725 // r3 : the function to call
1726 // r4 : feedback vector 1726 // r4 : feedback vector
1727 // r5 : slot in feedback vector (Smi) 1727 // r5 : slot in feedback vector (Smi)
1728 Label initialize, done, miss, megamorphic, not_array_function; 1728 Label initialize, done, miss, megamorphic, not_array_function;
1729 Label done_initialize_count, done_increment_count;
1730 1729
1731 DCHECK_EQ(*TypeFeedbackVector::MegamorphicSentinel(masm->isolate()), 1730 DCHECK_EQ(*TypeFeedbackVector::MegamorphicSentinel(masm->isolate()),
1732 masm->isolate()->heap()->megamorphic_symbol()); 1731 masm->isolate()->heap()->megamorphic_symbol());
1733 DCHECK_EQ(*TypeFeedbackVector::UninitializedSentinel(masm->isolate()), 1732 DCHECK_EQ(*TypeFeedbackVector::UninitializedSentinel(masm->isolate()),
1734 masm->isolate()->heap()->uninitialized_symbol()); 1733 masm->isolate()->heap()->uninitialized_symbol());
1735 1734
1736 const int count_offset = FixedArray::kHeaderSize + kPointerSize; 1735 const int count_offset = FixedArray::kHeaderSize + kPointerSize;
1737 1736
1738 // Load the cache state into r7. 1737 // Load the cache state into r7.
1739 __ SmiToPtrArrayOffset(r7, r5); 1738 __ SmiToPtrArrayOffset(r7, r5);
1740 __ AddP(r7, r4, r7); 1739 __ AddP(r7, r4, r7);
1741 __ LoadP(r7, FieldMemOperand(r7, FixedArray::kHeaderSize)); 1740 __ LoadP(r7, FieldMemOperand(r7, FixedArray::kHeaderSize));
1742 1741
1743 // A monomorphic cache hit or an already megamorphic state: invoke the 1742 // A monomorphic cache hit or an already megamorphic state: invoke the
1744 // function without changing the state. 1743 // function without changing the state.
1745 // We don't know if r7 is a WeakCell or a Symbol, but it's harmless to read at 1744 // We don't know if r7 is a WeakCell or a Symbol, but it's harmless to read at
1746 // this position in a symbol (see static asserts in type-feedback-vector.h). 1745 // this position in a symbol (see static asserts in type-feedback-vector.h).
1747 Label check_allocation_site; 1746 Label check_allocation_site;
1748 Register feedback_map = r8; 1747 Register feedback_map = r8;
1749 Register weak_value = r9; 1748 Register weak_value = r9;
1750 __ LoadP(weak_value, FieldMemOperand(r7, WeakCell::kValueOffset)); 1749 __ LoadP(weak_value, FieldMemOperand(r7, WeakCell::kValueOffset));
1751 __ CmpP(r3, weak_value); 1750 __ CmpP(r3, weak_value);
1752 __ beq(&done_increment_count, Label::kNear); 1751 __ beq(&done, Label::kNear);
1753 __ CompareRoot(r7, Heap::kmegamorphic_symbolRootIndex); 1752 __ CompareRoot(r7, Heap::kmegamorphic_symbolRootIndex);
1754 __ beq(&done, Label::kNear); 1753 __ beq(&done, Label::kNear);
1755 __ LoadP(feedback_map, FieldMemOperand(r7, HeapObject::kMapOffset)); 1754 __ LoadP(feedback_map, FieldMemOperand(r7, HeapObject::kMapOffset));
1756 __ CompareRoot(feedback_map, Heap::kWeakCellMapRootIndex); 1755 __ CompareRoot(feedback_map, Heap::kWeakCellMapRootIndex);
1757 __ bne(&check_allocation_site); 1756 __ bne(&check_allocation_site);
1758 1757
1759 // If the weak cell is cleared, we have a new chance to become monomorphic. 1758 // If the weak cell is cleared, we have a new chance to become monomorphic.
1760 __ JumpIfSmi(weak_value, &initialize); 1759 __ JumpIfSmi(weak_value, &initialize);
1761 __ b(&megamorphic); 1760 __ b(&megamorphic);
1762 1761
1763 __ bind(&check_allocation_site); 1762 __ bind(&check_allocation_site);
1764 // If we came here, we need to see if we are the array function. 1763 // If we came here, we need to see if we are the array function.
1765 // If we didn't have a matching function, and we didn't find the megamorph 1764 // If we didn't have a matching function, and we didn't find the megamorph
1766 // sentinel, then we have in the slot either some other function or an 1765 // sentinel, then we have in the slot either some other function or an
1767 // AllocationSite. 1766 // AllocationSite.
1768 __ CompareRoot(feedback_map, Heap::kAllocationSiteMapRootIndex); 1767 __ CompareRoot(feedback_map, Heap::kAllocationSiteMapRootIndex);
1769 __ bne(&miss); 1768 __ bne(&miss);
1770 1769
1771 // Make sure the function is the Array() function 1770 // Make sure the function is the Array() function
1772 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r7); 1771 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r7);
1773 __ CmpP(r3, r7); 1772 __ CmpP(r3, r7);
1774 __ bne(&megamorphic); 1773 __ bne(&megamorphic);
1775 __ b(&done_increment_count, Label::kNear); 1774 __ b(&done, Label::kNear);
1776 1775
1777 __ bind(&miss); 1776 __ bind(&miss);
1778 1777
1779 // A monomorphic miss (i.e, here the cache is not uninitialized) goes 1778 // A monomorphic miss (i.e, here the cache is not uninitialized) goes
1780 // megamorphic. 1779 // megamorphic.
1781 __ CompareRoot(r7, Heap::kuninitialized_symbolRootIndex); 1780 __ CompareRoot(r7, Heap::kuninitialized_symbolRootIndex);
1782 __ beq(&initialize); 1781 __ beq(&initialize);
1783 // MegamorphicSentinel is an immortal immovable object (undefined) so no 1782 // MegamorphicSentinel is an immortal immovable object (undefined) so no
1784 // write-barrier is needed. 1783 // write-barrier is needed.
1785 __ bind(&megamorphic); 1784 __ bind(&megamorphic);
1786 __ SmiToPtrArrayOffset(r7, r5); 1785 __ SmiToPtrArrayOffset(r7, r5);
1787 __ AddP(r7, r4, r7); 1786 __ AddP(r7, r4, r7);
1788 __ LoadRoot(ip, Heap::kmegamorphic_symbolRootIndex); 1787 __ LoadRoot(ip, Heap::kmegamorphic_symbolRootIndex);
1789 __ StoreP(ip, FieldMemOperand(r7, FixedArray::kHeaderSize), r0); 1788 __ StoreP(ip, FieldMemOperand(r7, FixedArray::kHeaderSize), r0);
1790 __ jmp(&done); 1789 __ jmp(&done);
1791 1790
1792 // An uninitialized cache is patched with the function 1791 // An uninitialized cache is patched with the function
1793 __ bind(&initialize); 1792 __ bind(&initialize);
1794 1793
1795 // Make sure the function is the Array() function. 1794 // Make sure the function is the Array() function.
1796 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r7); 1795 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r7);
1797 __ CmpP(r3, r7); 1796 __ CmpP(r3, r7);
1798 __ bne(&not_array_function); 1797 __ bne(&not_array_function);
1799 1798
1800 // The target function is the Array constructor, 1799 // The target function is the Array constructor,
1801 // Create an AllocationSite if we don't already have it, store it in the 1800 // Create an AllocationSite if we don't already have it, store it in the
1802 // slot. 1801 // slot.
1803 CreateAllocationSiteStub create_stub(masm->isolate()); 1802 CreateAllocationSiteStub create_stub(masm->isolate());
1804 CallStubInRecordCallTarget(masm, &create_stub); 1803 CallStubInRecordCallTarget(masm, &create_stub);
1805 __ b(&done_initialize_count, Label::kNear); 1804 __ b(&done, Label::kNear);
1806 1805
1807 __ bind(&not_array_function); 1806 __ bind(&not_array_function);
1808 1807
1809 CreateWeakCellStub weak_cell_stub(masm->isolate()); 1808 CreateWeakCellStub weak_cell_stub(masm->isolate());
1810 CallStubInRecordCallTarget(masm, &weak_cell_stub); 1809 CallStubInRecordCallTarget(masm, &weak_cell_stub);
1811 1810
1812 __ bind(&done_initialize_count); 1811 __ bind(&done);
1813 // Initialize the call counter.
1814 __ LoadSmiLiteral(r7, Smi::FromInt(1));
1815 __ SmiToPtrArrayOffset(r6, r5);
1816 __ AddP(r6, r4, r6);
1817 __ StoreP(r7, FieldMemOperand(r6, count_offset), r0);
1818 __ b(&done, Label::kNear);
1819 1812
1820 __ bind(&done_increment_count); 1813 // Increment the call count for all function calls.
1821
1822 // Increment the call count for monomorphic function calls.
1823 __ SmiToPtrArrayOffset(r7, r5); 1814 __ SmiToPtrArrayOffset(r7, r5);
1824 __ AddP(r7, r4, r7); 1815 __ AddP(r7, r4, r7);
1825 1816
1826 __ LoadP(r6, FieldMemOperand(r7, count_offset)); 1817 __ LoadP(r6, FieldMemOperand(r7, count_offset));
1827 __ AddSmiLiteral(r6, r6, Smi::FromInt(1), r0); 1818 __ AddSmiLiteral(r6, r6, Smi::FromInt(1), r0);
1828 __ StoreP(r6, FieldMemOperand(r7, count_offset), r0); 1819 __ StoreP(r6, FieldMemOperand(r7, count_offset), r0);
1829
1830 __ bind(&done);
1831 } 1820 }
1832 1821
1833 void CallConstructStub::Generate(MacroAssembler* masm) { 1822 void CallConstructStub::Generate(MacroAssembler* masm) {
1834 // r2 : number of arguments 1823 // r2 : number of arguments
1835 // r3 : the function to call 1824 // r3 : the function to call
1836 // r4 : feedback vector 1825 // r4 : feedback vector
1837 // r5 : slot in feedback vector (Smi, for RecordCallTarget) 1826 // r5 : slot in feedback vector (Smi, for RecordCallTarget)
1838 1827
1839 Label non_function; 1828 Label non_function;
1840 // Check that the function is not a smi. 1829 // Check that the function is not a smi.
(...skipping 3516 matching lines...) Expand 10 before | Expand all | Expand 10 after
5357 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, 5346 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref,
5358 kStackUnwindSpace, NULL, return_value_operand, NULL); 5347 kStackUnwindSpace, NULL, return_value_operand, NULL);
5359 } 5348 }
5360 5349
5361 #undef __ 5350 #undef __
5362 5351
5363 } // namespace internal 5352 } // namespace internal
5364 } // namespace v8 5353 } // namespace v8
5365 5354
5366 #endif // V8_TARGET_ARCH_S390 5355 #endif // V8_TARGET_ARCH_S390
OLDNEW
« no previous file with comments | « src/ppc/code-stubs-ppc.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698