OLD | NEW |
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 1649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1660 // We don't know if ecx is a WeakCell or a Symbol, but it's harmless to read | 1660 // We don't know if ecx is a WeakCell or a Symbol, but it's harmless to read |
1661 // at this position in a symbol (see static asserts in | 1661 // at this position in a symbol (see static asserts in |
1662 // type-feedback-vector.h). | 1662 // type-feedback-vector.h). |
1663 Label check_allocation_site; | 1663 Label check_allocation_site; |
1664 __ cmp(edi, FieldOperand(ecx, WeakCell::kValueOffset)); | 1664 __ cmp(edi, FieldOperand(ecx, WeakCell::kValueOffset)); |
1665 __ j(equal, &done, Label::kFar); | 1665 __ j(equal, &done, Label::kFar); |
1666 __ CompareRoot(ecx, Heap::kmegamorphic_symbolRootIndex); | 1666 __ CompareRoot(ecx, Heap::kmegamorphic_symbolRootIndex); |
1667 __ j(equal, &done, Label::kFar); | 1667 __ j(equal, &done, Label::kFar); |
1668 __ CompareRoot(FieldOperand(ecx, HeapObject::kMapOffset), | 1668 __ CompareRoot(FieldOperand(ecx, HeapObject::kMapOffset), |
1669 Heap::kWeakCellMapRootIndex); | 1669 Heap::kWeakCellMapRootIndex); |
1670 __ j(not_equal, FLAG_pretenuring_call_new ? &miss : &check_allocation_site); | 1670 __ j(not_equal, &check_allocation_site); |
1671 | 1671 |
1672 // If the weak cell is cleared, we have a new chance to become monomorphic. | 1672 // If the weak cell is cleared, we have a new chance to become monomorphic. |
1673 __ JumpIfSmi(FieldOperand(ecx, WeakCell::kValueOffset), &initialize); | 1673 __ JumpIfSmi(FieldOperand(ecx, WeakCell::kValueOffset), &initialize); |
1674 __ jmp(&megamorphic); | 1674 __ jmp(&megamorphic); |
1675 | 1675 |
1676 if (!FLAG_pretenuring_call_new) { | 1676 __ bind(&check_allocation_site); |
1677 __ bind(&check_allocation_site); | 1677 // If we came here, we need to see if we are the array function. |
1678 // If we came here, we need to see if we are the array function. | 1678 // If we didn't have a matching function, and we didn't find the megamorph |
1679 // If we didn't have a matching function, and we didn't find the megamorph | 1679 // sentinel, then we have in the slot either some other function or an |
1680 // sentinel, then we have in the slot either some other function or an | 1680 // AllocationSite. |
1681 // AllocationSite. | 1681 __ CompareRoot(FieldOperand(ecx, 0), Heap::kAllocationSiteMapRootIndex); |
1682 __ CompareRoot(FieldOperand(ecx, 0), Heap::kAllocationSiteMapRootIndex); | 1682 __ j(not_equal, &miss); |
1683 __ j(not_equal, &miss); | |
1684 | 1683 |
1685 // Make sure the function is the Array() function | 1684 // Make sure the function is the Array() function |
1686 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); | 1685 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); |
1687 __ cmp(edi, ecx); | 1686 __ cmp(edi, ecx); |
1688 __ j(not_equal, &megamorphic); | 1687 __ j(not_equal, &megamorphic); |
1689 __ jmp(&done, Label::kFar); | 1688 __ jmp(&done, Label::kFar); |
1690 } | |
1691 | 1689 |
1692 __ bind(&miss); | 1690 __ bind(&miss); |
1693 | 1691 |
1694 // A monomorphic miss (i.e, here the cache is not uninitialized) goes | 1692 // A monomorphic miss (i.e, here the cache is not uninitialized) goes |
1695 // megamorphic. | 1693 // megamorphic. |
1696 __ CompareRoot(ecx, Heap::kuninitialized_symbolRootIndex); | 1694 __ CompareRoot(ecx, Heap::kuninitialized_symbolRootIndex); |
1697 __ j(equal, &initialize); | 1695 __ j(equal, &initialize); |
1698 // MegamorphicSentinel is an immortal immovable object (undefined) so no | 1696 // MegamorphicSentinel is an immortal immovable object (undefined) so no |
1699 // write-barrier is needed. | 1697 // write-barrier is needed. |
1700 __ bind(&megamorphic); | 1698 __ bind(&megamorphic); |
1701 __ mov( | 1699 __ mov( |
1702 FieldOperand(ebx, edx, times_half_pointer_size, FixedArray::kHeaderSize), | 1700 FieldOperand(ebx, edx, times_half_pointer_size, FixedArray::kHeaderSize), |
1703 Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate))); | 1701 Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate))); |
1704 __ jmp(&done, Label::kFar); | 1702 __ jmp(&done, Label::kFar); |
1705 | 1703 |
1706 // An uninitialized cache is patched with the function or sentinel to | 1704 // An uninitialized cache is patched with the function or sentinel to |
1707 // indicate the ElementsKind if function is the Array constructor. | 1705 // indicate the ElementsKind if function is the Array constructor. |
1708 __ bind(&initialize); | 1706 __ bind(&initialize); |
1709 if (!FLAG_pretenuring_call_new) { | 1707 // Make sure the function is the Array() function |
1710 // Make sure the function is the Array() function | 1708 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); |
1711 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); | 1709 __ cmp(edi, ecx); |
1712 __ cmp(edi, ecx); | 1710 __ j(not_equal, ¬_array_function); |
1713 __ j(not_equal, ¬_array_function); | |
1714 | 1711 |
1715 // The target function is the Array constructor, | 1712 // The target function is the Array constructor, |
1716 // Create an AllocationSite if we don't already have it, store it in the | 1713 // Create an AllocationSite if we don't already have it, store it in the |
1717 // slot. | 1714 // slot. |
1718 CreateAllocationSiteStub create_stub(isolate); | 1715 CreateAllocationSiteStub create_stub(isolate); |
1719 CallStubInRecordCallTarget(masm, &create_stub, is_super); | 1716 CallStubInRecordCallTarget(masm, &create_stub, is_super); |
1720 __ jmp(&done); | 1717 __ jmp(&done); |
1721 | 1718 |
1722 __ bind(¬_array_function); | 1719 __ bind(¬_array_function); |
1723 } | 1720 CreateWeakCellStub weak_cell_stub(isolate); |
1724 | 1721 CallStubInRecordCallTarget(masm, &weak_cell_stub, is_super); |
1725 CreateWeakCellStub create_stub(isolate); | |
1726 CallStubInRecordCallTarget(masm, &create_stub, is_super); | |
1727 __ bind(&done); | 1722 __ bind(&done); |
1728 } | 1723 } |
1729 | 1724 |
1730 | 1725 |
1731 static void EmitContinueIfStrictOrNative(MacroAssembler* masm, Label* cont) { | 1726 static void EmitContinueIfStrictOrNative(MacroAssembler* masm, Label* cont) { |
1732 // Do not transform the receiver for strict mode functions. | 1727 // Do not transform the receiver for strict mode functions. |
1733 __ mov(ecx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); | 1728 __ mov(ecx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); |
1734 __ test_b(FieldOperand(ecx, SharedFunctionInfo::kStrictModeByteOffset), | 1729 __ test_b(FieldOperand(ecx, SharedFunctionInfo::kStrictModeByteOffset), |
1735 1 << SharedFunctionInfo::kStrictModeBitWithinByte); | 1730 1 << SharedFunctionInfo::kStrictModeBitWithinByte); |
1736 __ j(not_equal, cont); | 1731 __ j(not_equal, cont); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1833 | 1828 |
1834 // Check that function is not a smi. | 1829 // Check that function is not a smi. |
1835 __ JumpIfSmi(edi, &non_function_call); | 1830 __ JumpIfSmi(edi, &non_function_call); |
1836 // Check that function is a JSFunction. | 1831 // Check that function is a JSFunction. |
1837 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); | 1832 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); |
1838 __ j(not_equal, &slow); | 1833 __ j(not_equal, &slow); |
1839 | 1834 |
1840 if (RecordCallTarget()) { | 1835 if (RecordCallTarget()) { |
1841 GenerateRecordCallTarget(masm, IsSuperConstructorCall()); | 1836 GenerateRecordCallTarget(masm, IsSuperConstructorCall()); |
1842 | 1837 |
1843 if (FLAG_pretenuring_call_new) { | 1838 Label feedback_register_initialized; |
1844 // Put the AllocationSite from the feedback vector into ebx. | 1839 // Put the AllocationSite from the feedback vector into ebx, or undefined. |
1845 // By adding kPointerSize we encode that we know the AllocationSite | 1840 __ mov(ebx, FieldOperand(ebx, edx, times_half_pointer_size, |
1846 // entry is at the feedback vector slot given by edx + 1. | 1841 FixedArray::kHeaderSize)); |
1847 __ mov(ebx, FieldOperand(ebx, edx, times_half_pointer_size, | 1842 Handle<Map> allocation_site_map = |
1848 FixedArray::kHeaderSize + kPointerSize)); | 1843 isolate()->factory()->allocation_site_map(); |
1849 } else { | 1844 __ cmp(FieldOperand(ebx, 0), Immediate(allocation_site_map)); |
1850 Label feedback_register_initialized; | 1845 __ j(equal, &feedback_register_initialized); |
1851 // Put the AllocationSite from the feedback vector into ebx, or undefined. | 1846 __ mov(ebx, isolate()->factory()->undefined_value()); |
1852 __ mov(ebx, FieldOperand(ebx, edx, times_half_pointer_size, | 1847 __ bind(&feedback_register_initialized); |
1853 FixedArray::kHeaderSize)); | |
1854 Handle<Map> allocation_site_map = | |
1855 isolate()->factory()->allocation_site_map(); | |
1856 __ cmp(FieldOperand(ebx, 0), Immediate(allocation_site_map)); | |
1857 __ j(equal, &feedback_register_initialized); | |
1858 __ mov(ebx, isolate()->factory()->undefined_value()); | |
1859 __ bind(&feedback_register_initialized); | |
1860 } | |
1861 | 1848 |
1862 __ AssertUndefinedOrAllocationSite(ebx); | 1849 __ AssertUndefinedOrAllocationSite(ebx); |
1863 } | 1850 } |
1864 | 1851 |
1865 if (IsSuperConstructorCall()) { | 1852 if (IsSuperConstructorCall()) { |
1866 __ pop(edx); | 1853 __ pop(edx); |
1867 } else { | 1854 } else { |
1868 // Pass original constructor to construct stub. | 1855 // Pass original constructor to construct stub. |
1869 __ mov(edx, edi); | 1856 __ mov(edx, edi); |
1870 } | 1857 } |
(...skipping 3621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5492 Operand(ebp, 7 * kPointerSize), NULL); | 5479 Operand(ebp, 7 * kPointerSize), NULL); |
5493 } | 5480 } |
5494 | 5481 |
5495 | 5482 |
5496 #undef __ | 5483 #undef __ |
5497 | 5484 |
5498 } // namespace internal | 5485 } // namespace internal |
5499 } // namespace v8 | 5486 } // namespace v8 |
5500 | 5487 |
5501 #endif // V8_TARGET_ARCH_X87 | 5488 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |