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

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

Issue 2333243004: CallConstruct also gets call count information if megamorphic. (Closed)
Patch Set: Compile/runtime fixes. 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 | « no previous file | src/arm64/code-stubs-arm64.cc » ('j') | src/compiler/js-call-reducer.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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_ARM 5 #if V8_TARGET_ARCH_ARM
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 1628 matching lines...) Expand 10 before | Expand all | Expand 10 after
1639 1639
1640 static void GenerateRecordCallTarget(MacroAssembler* masm) { 1640 static void GenerateRecordCallTarget(MacroAssembler* masm) {
1641 // Cache the called function in a feedback vector slot. Cache states 1641 // Cache the called function in a feedback vector slot. Cache states
1642 // are uninitialized, monomorphic (indicated by a JSFunction), and 1642 // are uninitialized, monomorphic (indicated by a JSFunction), and
1643 // megamorphic. 1643 // megamorphic.
1644 // r0 : number of arguments to the construct function 1644 // r0 : number of arguments to the construct function
1645 // r1 : the function to call 1645 // r1 : the function to call
1646 // r2 : feedback vector 1646 // r2 : feedback vector
1647 // r3 : slot in feedback vector (Smi) 1647 // r3 : slot in feedback vector (Smi)
1648 Label initialize, done, miss, megamorphic, not_array_function; 1648 Label initialize, done, miss, megamorphic, not_array_function;
1649 Label done_initialize_count, done_increment_count;
1650 1649
1651 DCHECK_EQ(*TypeFeedbackVector::MegamorphicSentinel(masm->isolate()), 1650 DCHECK_EQ(*TypeFeedbackVector::MegamorphicSentinel(masm->isolate()),
1652 masm->isolate()->heap()->megamorphic_symbol()); 1651 masm->isolate()->heap()->megamorphic_symbol());
1653 DCHECK_EQ(*TypeFeedbackVector::UninitializedSentinel(masm->isolate()), 1652 DCHECK_EQ(*TypeFeedbackVector::UninitializedSentinel(masm->isolate()),
1654 masm->isolate()->heap()->uninitialized_symbol()); 1653 masm->isolate()->heap()->uninitialized_symbol());
1655 1654
1656 // Load the cache state into r5. 1655 // Load the cache state into r5.
1657 __ add(r5, r2, Operand::PointerOffsetFromSmiKey(r3)); 1656 __ add(r5, r2, Operand::PointerOffsetFromSmiKey(r3));
1658 __ ldr(r5, FieldMemOperand(r5, FixedArray::kHeaderSize)); 1657 __ ldr(r5, FieldMemOperand(r5, FixedArray::kHeaderSize));
1659 1658
1660 // A monomorphic cache hit or an already megamorphic state: invoke the 1659 // A monomorphic cache hit or an already megamorphic state: invoke the
1661 // function without changing the state. 1660 // function without changing the state.
1662 // We don't know if r5 is a WeakCell or a Symbol, but it's harmless to read at 1661 // We don't know if r5 is a WeakCell or a Symbol, but it's harmless to read at
1663 // this position in a symbol (see static asserts in type-feedback-vector.h). 1662 // this position in a symbol (see static asserts in type-feedback-vector.h).
1664 Label check_allocation_site; 1663 Label check_allocation_site;
1665 Register feedback_map = r6; 1664 Register feedback_map = r6;
1666 Register weak_value = r9; 1665 Register weak_value = r9;
1667 __ ldr(weak_value, FieldMemOperand(r5, WeakCell::kValueOffset)); 1666 __ ldr(weak_value, FieldMemOperand(r5, WeakCell::kValueOffset));
1668 __ cmp(r1, weak_value); 1667 __ cmp(r1, weak_value);
1669 __ b(eq, &done_increment_count); 1668 __ b(eq, &done);
1670 __ CompareRoot(r5, Heap::kmegamorphic_symbolRootIndex); 1669 __ CompareRoot(r5, Heap::kmegamorphic_symbolRootIndex);
1671 __ b(eq, &done); 1670 __ b(eq, &done);
1672 __ ldr(feedback_map, FieldMemOperand(r5, HeapObject::kMapOffset)); 1671 __ ldr(feedback_map, FieldMemOperand(r5, HeapObject::kMapOffset));
1673 __ CompareRoot(feedback_map, Heap::kWeakCellMapRootIndex); 1672 __ CompareRoot(feedback_map, Heap::kWeakCellMapRootIndex);
1674 __ b(ne, &check_allocation_site); 1673 __ b(ne, &check_allocation_site);
1675 1674
1676 // If the weak cell is cleared, we have a new chance to become monomorphic. 1675 // If the weak cell is cleared, we have a new chance to become monomorphic.
1677 __ JumpIfSmi(weak_value, &initialize); 1676 __ JumpIfSmi(weak_value, &initialize);
1678 __ jmp(&megamorphic); 1677 __ jmp(&megamorphic);
1679 1678
1680 __ bind(&check_allocation_site); 1679 __ bind(&check_allocation_site);
1681 // If we came here, we need to see if we are the array function. 1680 // If we came here, we need to see if we are the array function.
1682 // If we didn't have a matching function, and we didn't find the megamorph 1681 // If we didn't have a matching function, and we didn't find the megamorph
1683 // sentinel, then we have in the slot either some other function or an 1682 // sentinel, then we have in the slot either some other function or an
1684 // AllocationSite. 1683 // AllocationSite.
1685 __ CompareRoot(feedback_map, Heap::kAllocationSiteMapRootIndex); 1684 __ CompareRoot(feedback_map, Heap::kAllocationSiteMapRootIndex);
1686 __ b(ne, &miss); 1685 __ b(ne, &miss);
1687 1686
1688 // Make sure the function is the Array() function 1687 // Make sure the function is the Array() function
1689 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r5); 1688 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r5);
1690 __ cmp(r1, r5); 1689 __ cmp(r1, r5);
1691 __ b(ne, &megamorphic); 1690 __ b(ne, &megamorphic);
1692 __ jmp(&done_increment_count); 1691 __ jmp(&done);
1693 1692
1694 __ bind(&miss); 1693 __ bind(&miss);
1695 1694
1696 // A monomorphic miss (i.e, here the cache is not uninitialized) goes 1695 // A monomorphic miss (i.e, here the cache is not uninitialized) goes
1697 // megamorphic. 1696 // megamorphic.
1698 __ CompareRoot(r5, Heap::kuninitialized_symbolRootIndex); 1697 __ CompareRoot(r5, Heap::kuninitialized_symbolRootIndex);
1699 __ b(eq, &initialize); 1698 __ b(eq, &initialize);
1700 // MegamorphicSentinel is an immortal immovable object (undefined) so no 1699 // MegamorphicSentinel is an immortal immovable object (undefined) so no
1701 // write-barrier is needed. 1700 // write-barrier is needed.
1702 __ bind(&megamorphic); 1701 __ bind(&megamorphic);
1703 __ add(r5, r2, Operand::PointerOffsetFromSmiKey(r3)); 1702 __ add(r5, r2, Operand::PointerOffsetFromSmiKey(r3));
1704 __ LoadRoot(ip, Heap::kmegamorphic_symbolRootIndex); 1703 __ LoadRoot(ip, Heap::kmegamorphic_symbolRootIndex);
1705 __ str(ip, FieldMemOperand(r5, FixedArray::kHeaderSize)); 1704 __ str(ip, FieldMemOperand(r5, FixedArray::kHeaderSize));
1706 __ jmp(&done); 1705 __ jmp(&done);
1707 1706
1708 // An uninitialized cache is patched with the function 1707 // An uninitialized cache is patched with the function
1709 __ bind(&initialize); 1708 __ bind(&initialize);
1710 1709
1711 // Make sure the function is the Array() function 1710 // Make sure the function is the Array() function
1712 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r5); 1711 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r5);
1713 __ cmp(r1, r5); 1712 __ cmp(r1, r5);
1714 __ b(ne, &not_array_function); 1713 __ b(ne, &not_array_function);
1715 1714
1716 // The target function is the Array constructor, 1715 // The target function is the Array constructor,
1717 // Create an AllocationSite if we don't already have it, store it in the 1716 // Create an AllocationSite if we don't already have it, store it in the
1718 // slot. 1717 // slot.
1719 CreateAllocationSiteStub create_stub(masm->isolate()); 1718 CreateAllocationSiteStub create_stub(masm->isolate());
1720 CallStubInRecordCallTarget(masm, &create_stub); 1719 CallStubInRecordCallTarget(masm, &create_stub);
1721 __ b(&done_initialize_count); 1720 __ b(&done);
1722 1721
1723 __ bind(&not_array_function); 1722 __ bind(&not_array_function);
1724 CreateWeakCellStub weak_cell_stub(masm->isolate()); 1723 CreateWeakCellStub weak_cell_stub(masm->isolate());
1725 CallStubInRecordCallTarget(masm, &weak_cell_stub); 1724 CallStubInRecordCallTarget(masm, &weak_cell_stub);
1726 1725
1727 __ bind(&done_initialize_count); 1726 __ bind(&done);
1728 // Initialize the call counter.
1729 __ Move(r5, Operand(Smi::FromInt(1)));
1730 __ add(r4, r2, Operand::PointerOffsetFromSmiKey(r3));
1731 __ str(r5, FieldMemOperand(r4, FixedArray::kHeaderSize + kPointerSize));
1732 __ b(&done);
1733 1727
1734 __ bind(&done_increment_count); 1728 // Increment the call count for all function calls.
1735
1736 // Increment the call count for monomorphic function calls.
1737 __ add(r5, r2, Operand::PointerOffsetFromSmiKey(r3)); 1729 __ add(r5, r2, Operand::PointerOffsetFromSmiKey(r3));
1738 __ add(r5, r5, Operand(FixedArray::kHeaderSize + kPointerSize)); 1730 __ add(r5, r5, Operand(FixedArray::kHeaderSize + kPointerSize));
1739 __ ldr(r4, FieldMemOperand(r5, 0)); 1731 __ ldr(r4, FieldMemOperand(r5, 0));
1740 __ add(r4, r4, Operand(Smi::FromInt(1))); 1732 __ add(r4, r4, Operand(Smi::FromInt(1)));
1741 __ str(r4, FieldMemOperand(r5, 0)); 1733 __ str(r4, FieldMemOperand(r5, 0));
1742
1743 __ bind(&done);
1744 } 1734 }
1745 1735
1746
1747 void CallConstructStub::Generate(MacroAssembler* masm) { 1736 void CallConstructStub::Generate(MacroAssembler* masm) {
1748 // r0 : number of arguments 1737 // r0 : number of arguments
1749 // r1 : the function to call 1738 // r1 : the function to call
1750 // r2 : feedback vector 1739 // r2 : feedback vector
1751 // r3 : slot in feedback vector (Smi, for RecordCallTarget) 1740 // r3 : slot in feedback vector (Smi, for RecordCallTarget)
1752 1741
1753 Label non_function; 1742 Label non_function;
1754 // Check that the function is not a smi. 1743 // Check that the function is not a smi.
1755 __ JumpIfSmi(r1, &non_function); 1744 __ JumpIfSmi(r1, &non_function);
1756 // Check that the function is a JSFunction. 1745 // Check that the function is a JSFunction.
(...skipping 3434 matching lines...) Expand 10 before | Expand all | Expand 10 after
5191 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, 5180 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref,
5192 kStackUnwindSpace, NULL, return_value_operand, NULL); 5181 kStackUnwindSpace, NULL, return_value_operand, NULL);
5193 } 5182 }
5194 5183
5195 #undef __ 5184 #undef __
5196 5185
5197 } // namespace internal 5186 } // namespace internal
5198 } // namespace v8 5187 } // namespace v8
5199 5188
5200 #endif // V8_TARGET_ARCH_ARM 5189 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/arm64/code-stubs-arm64.cc » ('j') | src/compiler/js-call-reducer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698