| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_X64 | 5 #if V8_TARGET_ARCH_X64 |
| 6 | 6 |
| 7 #include "src/bootstrapper.h" | 7 #include "src/bootstrapper.h" |
| 8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
| 9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
| 10 #include "src/ic/handler-compiler.h" | 10 #include "src/ic/handler-compiler.h" |
| (...skipping 1800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1811 // We don't know if r11 is a WeakCell or a Symbol, but it's harmless to read | 1811 // We don't know if r11 is a WeakCell or a Symbol, but it's harmless to read |
| 1812 // at this position in a symbol (see static asserts in | 1812 // at this position in a symbol (see static asserts in |
| 1813 // type-feedback-vector.h). | 1813 // type-feedback-vector.h). |
| 1814 Label check_allocation_site; | 1814 Label check_allocation_site; |
| 1815 __ cmpp(rdi, FieldOperand(r11, WeakCell::kValueOffset)); | 1815 __ cmpp(rdi, FieldOperand(r11, WeakCell::kValueOffset)); |
| 1816 __ j(equal, &done, Label::kFar); | 1816 __ j(equal, &done, Label::kFar); |
| 1817 __ CompareRoot(r11, Heap::kmegamorphic_symbolRootIndex); | 1817 __ CompareRoot(r11, Heap::kmegamorphic_symbolRootIndex); |
| 1818 __ j(equal, &done, Label::kFar); | 1818 __ j(equal, &done, Label::kFar); |
| 1819 __ CompareRoot(FieldOperand(r11, HeapObject::kMapOffset), | 1819 __ CompareRoot(FieldOperand(r11, HeapObject::kMapOffset), |
| 1820 Heap::kWeakCellMapRootIndex); | 1820 Heap::kWeakCellMapRootIndex); |
| 1821 __ j(not_equal, FLAG_pretenuring_call_new ? &miss : &check_allocation_site); | 1821 __ j(not_equal, &check_allocation_site); |
| 1822 | 1822 |
| 1823 // If the weak cell is cleared, we have a new chance to become monomorphic. | 1823 // If the weak cell is cleared, we have a new chance to become monomorphic. |
| 1824 __ CheckSmi(FieldOperand(r11, WeakCell::kValueOffset)); | 1824 __ CheckSmi(FieldOperand(r11, WeakCell::kValueOffset)); |
| 1825 __ j(equal, &initialize); | 1825 __ j(equal, &initialize); |
| 1826 __ jmp(&megamorphic); | 1826 __ jmp(&megamorphic); |
| 1827 | 1827 |
| 1828 if (!FLAG_pretenuring_call_new) { | 1828 __ bind(&check_allocation_site); |
| 1829 __ bind(&check_allocation_site); | 1829 // If we came here, we need to see if we are the array function. |
| 1830 // If we came here, we need to see if we are the array function. | 1830 // If we didn't have a matching function, and we didn't find the megamorph |
| 1831 // If we didn't have a matching function, and we didn't find the megamorph | 1831 // sentinel, then we have in the slot either some other function or an |
| 1832 // sentinel, then we have in the slot either some other function or an | 1832 // AllocationSite. |
| 1833 // AllocationSite. | 1833 __ CompareRoot(FieldOperand(r11, 0), Heap::kAllocationSiteMapRootIndex); |
| 1834 __ CompareRoot(FieldOperand(r11, 0), Heap::kAllocationSiteMapRootIndex); | 1834 __ j(not_equal, &miss); |
| 1835 __ j(not_equal, &miss); | |
| 1836 | 1835 |
| 1837 // Make sure the function is the Array() function | 1836 // Make sure the function is the Array() function |
| 1838 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, r11); | 1837 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, r11); |
| 1839 __ cmpp(rdi, r11); | 1838 __ cmpp(rdi, r11); |
| 1840 __ j(not_equal, &megamorphic); | 1839 __ j(not_equal, &megamorphic); |
| 1841 __ jmp(&done); | 1840 __ jmp(&done); |
| 1842 } | |
| 1843 | 1841 |
| 1844 __ bind(&miss); | 1842 __ bind(&miss); |
| 1845 | 1843 |
| 1846 // A monomorphic miss (i.e, here the cache is not uninitialized) goes | 1844 // A monomorphic miss (i.e, here the cache is not uninitialized) goes |
| 1847 // megamorphic. | 1845 // megamorphic. |
| 1848 __ CompareRoot(r11, Heap::kuninitialized_symbolRootIndex); | 1846 __ CompareRoot(r11, Heap::kuninitialized_symbolRootIndex); |
| 1849 __ j(equal, &initialize); | 1847 __ j(equal, &initialize); |
| 1850 // MegamorphicSentinel is an immortal immovable object (undefined) so no | 1848 // MegamorphicSentinel is an immortal immovable object (undefined) so no |
| 1851 // write-barrier is needed. | 1849 // write-barrier is needed. |
| 1852 __ bind(&megamorphic); | 1850 __ bind(&megamorphic); |
| 1853 __ Move(FieldOperand(rbx, rdx, times_pointer_size, FixedArray::kHeaderSize), | 1851 __ Move(FieldOperand(rbx, rdx, times_pointer_size, FixedArray::kHeaderSize), |
| 1854 TypeFeedbackVector::MegamorphicSentinel(isolate)); | 1852 TypeFeedbackVector::MegamorphicSentinel(isolate)); |
| 1855 __ jmp(&done); | 1853 __ jmp(&done); |
| 1856 | 1854 |
| 1857 // An uninitialized cache is patched with the function or sentinel to | 1855 // An uninitialized cache is patched with the function or sentinel to |
| 1858 // indicate the ElementsKind if function is the Array constructor. | 1856 // indicate the ElementsKind if function is the Array constructor. |
| 1859 __ bind(&initialize); | 1857 __ bind(&initialize); |
| 1860 | 1858 |
| 1861 if (!FLAG_pretenuring_call_new) { | 1859 // Make sure the function is the Array() function |
| 1862 // Make sure the function is the Array() function | 1860 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, r11); |
| 1863 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, r11); | 1861 __ cmpp(rdi, r11); |
| 1864 __ cmpp(rdi, r11); | 1862 __ j(not_equal, ¬_array_function); |
| 1865 __ j(not_equal, ¬_array_function); | |
| 1866 | 1863 |
| 1867 CreateAllocationSiteStub create_stub(isolate); | 1864 CreateAllocationSiteStub create_stub(isolate); |
| 1868 CallStubInRecordCallTarget(masm, &create_stub, is_super); | 1865 CallStubInRecordCallTarget(masm, &create_stub, is_super); |
| 1869 __ jmp(&done_no_smi_convert); | 1866 __ jmp(&done_no_smi_convert); |
| 1870 | 1867 |
| 1871 __ bind(¬_array_function); | 1868 __ bind(¬_array_function); |
| 1872 } | 1869 CreateWeakCellStub weak_cell_stub(isolate); |
| 1873 | 1870 CallStubInRecordCallTarget(masm, &weak_cell_stub, is_super); |
| 1874 CreateWeakCellStub create_stub(isolate); | |
| 1875 CallStubInRecordCallTarget(masm, &create_stub, is_super); | |
| 1876 __ jmp(&done_no_smi_convert); | 1871 __ jmp(&done_no_smi_convert); |
| 1877 | 1872 |
| 1878 __ bind(&done); | 1873 __ bind(&done); |
| 1879 __ Integer32ToSmi(rdx, rdx); | 1874 __ Integer32ToSmi(rdx, rdx); |
| 1880 | 1875 |
| 1881 __ bind(&done_no_smi_convert); | 1876 __ bind(&done_no_smi_convert); |
| 1882 } | 1877 } |
| 1883 | 1878 |
| 1884 | 1879 |
| 1885 static void EmitContinueIfStrictOrNative(MacroAssembler* masm, Label* cont) { | 1880 static void EmitContinueIfStrictOrNative(MacroAssembler* masm, Label* cont) { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1991 // Check that function is not a smi. | 1986 // Check that function is not a smi. |
| 1992 __ JumpIfSmi(rdi, &non_function_call); | 1987 __ JumpIfSmi(rdi, &non_function_call); |
| 1993 // Check that function is a JSFunction. | 1988 // Check that function is a JSFunction. |
| 1994 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, r11); | 1989 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, r11); |
| 1995 __ j(not_equal, &slow); | 1990 __ j(not_equal, &slow); |
| 1996 | 1991 |
| 1997 if (RecordCallTarget()) { | 1992 if (RecordCallTarget()) { |
| 1998 GenerateRecordCallTarget(masm, IsSuperConstructorCall()); | 1993 GenerateRecordCallTarget(masm, IsSuperConstructorCall()); |
| 1999 | 1994 |
| 2000 __ SmiToInteger32(rdx, rdx); | 1995 __ SmiToInteger32(rdx, rdx); |
| 2001 if (FLAG_pretenuring_call_new) { | 1996 Label feedback_register_initialized; |
| 2002 // Put the AllocationSite from the feedback vector into ebx. | 1997 // Put the AllocationSite from the feedback vector into rbx, or undefined. |
| 2003 // By adding kPointerSize we encode that we know the AllocationSite | 1998 __ movp(rbx, FieldOperand(rbx, rdx, times_pointer_size, |
| 2004 // entry is at the feedback vector slot given by rdx + 1. | 1999 FixedArray::kHeaderSize)); |
| 2005 __ movp(rbx, FieldOperand(rbx, rdx, times_pointer_size, | 2000 __ CompareRoot(FieldOperand(rbx, 0), Heap::kAllocationSiteMapRootIndex); |
| 2006 FixedArray::kHeaderSize + kPointerSize)); | 2001 __ j(equal, &feedback_register_initialized); |
| 2007 } else { | 2002 __ LoadRoot(rbx, Heap::kUndefinedValueRootIndex); |
| 2008 Label feedback_register_initialized; | 2003 __ bind(&feedback_register_initialized); |
| 2009 // Put the AllocationSite from the feedback vector into rbx, or undefined. | |
| 2010 __ movp(rbx, FieldOperand(rbx, rdx, times_pointer_size, | |
| 2011 FixedArray::kHeaderSize)); | |
| 2012 __ CompareRoot(FieldOperand(rbx, 0), Heap::kAllocationSiteMapRootIndex); | |
| 2013 __ j(equal, &feedback_register_initialized); | |
| 2014 __ LoadRoot(rbx, Heap::kUndefinedValueRootIndex); | |
| 2015 __ bind(&feedback_register_initialized); | |
| 2016 } | |
| 2017 | 2004 |
| 2018 __ AssertUndefinedOrAllocationSite(rbx); | 2005 __ AssertUndefinedOrAllocationSite(rbx); |
| 2019 } | 2006 } |
| 2020 | 2007 |
| 2021 // Pass original constructor to construct stub. | 2008 // Pass original constructor to construct stub. |
| 2022 if (IsSuperConstructorCall()) { | 2009 if (IsSuperConstructorCall()) { |
| 2023 __ movp(rdx, rcx); | 2010 __ movp(rdx, rcx); |
| 2024 } else { | 2011 } else { |
| 2025 __ movp(rdx, rdi); | 2012 __ movp(rdx, rdi); |
| 2026 } | 2013 } |
| (...skipping 3551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5578 kStackSpace, nullptr, return_value_operand, NULL); | 5565 kStackSpace, nullptr, return_value_operand, NULL); |
| 5579 } | 5566 } |
| 5580 | 5567 |
| 5581 | 5568 |
| 5582 #undef __ | 5569 #undef __ |
| 5583 | 5570 |
| 5584 } // namespace internal | 5571 } // namespace internal |
| 5585 } // namespace v8 | 5572 } // namespace v8 |
| 5586 | 5573 |
| 5587 #endif // V8_TARGET_ARCH_X64 | 5574 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |