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

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

Issue 1491063003: X87: Provide call counts for constructor calls, surface them as a vector IC. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years 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/full-codegen/x87/full-codegen-x87.cc ('k') | src/x87/interface-descriptors-x87.cc » ('j') | no next file with comments »
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_X87 5 #if V8_TARGET_ARCH_X87
6 6
7 #include "src/base/bits.h" 7 #include "src/base/bits.h"
8 #include "src/bootstrapper.h" 8 #include "src/bootstrapper.h"
9 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 1626 matching lines...) Expand 10 before | Expand all | Expand 10 after
1637 static void GenerateRecordCallTarget(MacroAssembler* masm) { 1637 static void GenerateRecordCallTarget(MacroAssembler* masm) {
1638 // Cache the called function in a feedback vector slot. Cache states 1638 // Cache the called function in a feedback vector slot. Cache states
1639 // are uninitialized, monomorphic (indicated by a JSFunction), and 1639 // are uninitialized, monomorphic (indicated by a JSFunction), and
1640 // megamorphic. 1640 // megamorphic.
1641 // eax : number of arguments to the construct function 1641 // eax : number of arguments to the construct function
1642 // ebx : feedback vector 1642 // ebx : feedback vector
1643 // edx : slot in feedback vector (Smi) 1643 // edx : slot in feedback vector (Smi)
1644 // edi : the function to call 1644 // edi : the function to call
1645 Isolate* isolate = masm->isolate(); 1645 Isolate* isolate = masm->isolate();
1646 Label initialize, done, miss, megamorphic, not_array_function; 1646 Label initialize, done, miss, megamorphic, not_array_function;
1647 Label done_increment_count;
1647 1648
1648 // Load the cache state into ecx. 1649 // Load the cache state into ecx.
1649 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size, 1650 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size,
1650 FixedArray::kHeaderSize)); 1651 FixedArray::kHeaderSize));
1651 1652
1652 // A monomorphic cache hit or an already megamorphic state: invoke the 1653 // A monomorphic cache hit or an already megamorphic state: invoke the
1653 // function without changing the state. 1654 // function without changing the state.
1654 // We don't know if ecx is a WeakCell or a Symbol, but it's harmless to read 1655 // We don't know if ecx is a WeakCell or a Symbol, but it's harmless to read
1655 // at this position in a symbol (see static asserts in 1656 // at this position in a symbol (see static asserts in
1656 // type-feedback-vector.h). 1657 // type-feedback-vector.h).
1657 Label check_allocation_site; 1658 Label check_allocation_site;
1658 __ cmp(edi, FieldOperand(ecx, WeakCell::kValueOffset)); 1659 __ cmp(edi, FieldOperand(ecx, WeakCell::kValueOffset));
1659 __ j(equal, &done, Label::kFar); 1660 __ j(equal, &done_increment_count, Label::kFar);
1660 __ CompareRoot(ecx, Heap::kmegamorphic_symbolRootIndex); 1661 __ CompareRoot(ecx, Heap::kmegamorphic_symbolRootIndex);
1661 __ j(equal, &done, Label::kFar); 1662 __ j(equal, &done, Label::kFar);
1662 __ CompareRoot(FieldOperand(ecx, HeapObject::kMapOffset), 1663 __ CompareRoot(FieldOperand(ecx, HeapObject::kMapOffset),
1663 Heap::kWeakCellMapRootIndex); 1664 Heap::kWeakCellMapRootIndex);
1664 __ j(not_equal, &check_allocation_site); 1665 __ j(not_equal, &check_allocation_site);
1665 1666
1666 // If the weak cell is cleared, we have a new chance to become monomorphic. 1667 // If the weak cell is cleared, we have a new chance to become monomorphic.
1667 __ JumpIfSmi(FieldOperand(ecx, WeakCell::kValueOffset), &initialize); 1668 __ JumpIfSmi(FieldOperand(ecx, WeakCell::kValueOffset), &initialize);
1668 __ jmp(&megamorphic); 1669 __ jmp(&megamorphic);
1669 1670
1670 __ bind(&check_allocation_site); 1671 __ bind(&check_allocation_site);
1671 // If we came here, we need to see if we are the array function. 1672 // If we came here, we need to see if we are the array function.
1672 // If we didn't have a matching function, and we didn't find the megamorph 1673 // If we didn't have a matching function, and we didn't find the megamorph
1673 // sentinel, then we have in the slot either some other function or an 1674 // sentinel, then we have in the slot either some other function or an
1674 // AllocationSite. 1675 // AllocationSite.
1675 __ CompareRoot(FieldOperand(ecx, 0), Heap::kAllocationSiteMapRootIndex); 1676 __ CompareRoot(FieldOperand(ecx, 0), Heap::kAllocationSiteMapRootIndex);
1676 __ j(not_equal, &miss); 1677 __ j(not_equal, &miss);
1677 1678
1678 // Make sure the function is the Array() function 1679 // Make sure the function is the Array() function
1679 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); 1680 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx);
1680 __ cmp(edi, ecx); 1681 __ cmp(edi, ecx);
1681 __ j(not_equal, &megamorphic); 1682 __ j(not_equal, &megamorphic);
1682 __ jmp(&done, Label::kFar); 1683 __ jmp(&done_increment_count, Label::kFar);
1683 1684
1684 __ bind(&miss); 1685 __ bind(&miss);
1685 1686
1686 // A monomorphic miss (i.e, here the cache is not uninitialized) goes 1687 // A monomorphic miss (i.e, here the cache is not uninitialized) goes
1687 // megamorphic. 1688 // megamorphic.
1688 __ CompareRoot(ecx, Heap::kuninitialized_symbolRootIndex); 1689 __ CompareRoot(ecx, Heap::kuninitialized_symbolRootIndex);
1689 __ j(equal, &initialize); 1690 __ j(equal, &initialize);
1690 // MegamorphicSentinel is an immortal immovable object (undefined) so no 1691 // MegamorphicSentinel is an immortal immovable object (undefined) so no
1691 // write-barrier is needed. 1692 // write-barrier is needed.
1692 __ bind(&megamorphic); 1693 __ bind(&megamorphic);
1693 __ mov( 1694 __ mov(
1694 FieldOperand(ebx, edx, times_half_pointer_size, FixedArray::kHeaderSize), 1695 FieldOperand(ebx, edx, times_half_pointer_size, FixedArray::kHeaderSize),
1695 Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate))); 1696 Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate)));
1696 __ jmp(&done, Label::kFar); 1697 __ jmp(&done, Label::kFar);
1697 1698
1698 // An uninitialized cache is patched with the function or sentinel to 1699 // An uninitialized cache is patched with the function or sentinel to
1699 // indicate the ElementsKind if function is the Array constructor. 1700 // indicate the ElementsKind if function is the Array constructor.
1700 __ bind(&initialize); 1701 __ bind(&initialize);
1702
1703 // Initialize the call counter.
1704 __ mov(FieldOperand(ebx, edx, times_half_pointer_size,
1705 FixedArray::kHeaderSize + kPointerSize),
1706 Immediate(Smi::FromInt(ConstructICNexus::kCallCountIncrement)));
1707
1701 // Make sure the function is the Array() function 1708 // Make sure the function is the Array() function
1702 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); 1709 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx);
1703 __ cmp(edi, ecx); 1710 __ cmp(edi, ecx);
1704 __ j(not_equal, &not_array_function); 1711 __ j(not_equal, &not_array_function);
1705 1712
1706 // The target function is the Array constructor, 1713 // The target function is the Array constructor,
1707 // Create an AllocationSite if we don't already have it, store it in the 1714 // Create an AllocationSite if we don't already have it, store it in the
1708 // slot. 1715 // slot.
1709 CreateAllocationSiteStub create_stub(isolate); 1716 CreateAllocationSiteStub create_stub(isolate);
1710 CallStubInRecordCallTarget(masm, &create_stub); 1717 CallStubInRecordCallTarget(masm, &create_stub);
1711 __ jmp(&done); 1718 __ jmp(&done);
1712 1719
1713 __ bind(&not_array_function); 1720 __ bind(&not_array_function);
1714 CreateWeakCellStub weak_cell_stub(isolate); 1721 CreateWeakCellStub weak_cell_stub(isolate);
1715 CallStubInRecordCallTarget(masm, &weak_cell_stub); 1722 CallStubInRecordCallTarget(masm, &weak_cell_stub);
1723 __ jmp(&done);
1724
1725 __ bind(&done_increment_count);
1726 __ add(FieldOperand(ebx, edx, times_half_pointer_size,
1727 FixedArray::kHeaderSize + kPointerSize),
1728 Immediate(Smi::FromInt(ConstructICNexus::kCallCountIncrement)));
1729
1716 __ bind(&done); 1730 __ bind(&done);
1717 } 1731 }
1718 1732
1719 1733
1720 void CallConstructStub::Generate(MacroAssembler* masm) { 1734 void ConstructICStub::Generate(MacroAssembler* masm) {
1721 // eax : number of arguments 1735 // eax : number of arguments
1722 // ebx : feedback vector 1736 // ebx : feedback vector
1723 // edx : slot in feedback vector (Smi, for RecordCallTarget) 1737 // edx : slot in feedback vector (Smi, for RecordCallTarget)
1724 // edi : constructor function 1738 // edi : constructor function
1725 1739
1726 Label non_function; 1740 Label non_function;
1727 // Check that function is not a smi. 1741 // Check that function is not a smi.
1728 __ JumpIfSmi(edi, &non_function); 1742 __ JumpIfSmi(edi, &non_function);
1729 // Check that function is a JSFunction. 1743 // Check that function is a JSFunction.
1730 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); 1744 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx);
(...skipping 3589 matching lines...) Expand 10 before | Expand all | Expand 10 after
5320 Operand(ebp, 7 * kPointerSize), NULL); 5334 Operand(ebp, 7 * kPointerSize), NULL);
5321 } 5335 }
5322 5336
5323 5337
5324 #undef __ 5338 #undef __
5325 5339
5326 } // namespace internal 5340 } // namespace internal
5327 } // namespace v8 5341 } // namespace v8
5328 5342
5329 #endif // V8_TARGET_ARCH_X87 5343 #endif // V8_TARGET_ARCH_X87
OLDNEW
« no previous file with comments | « src/full-codegen/x87/full-codegen-x87.cc ('k') | src/x87/interface-descriptors-x87.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698