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 1739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1750 | 1750 |
1751 __ bind(&miss); | 1751 __ bind(&miss); |
1752 GenerateMiss(masm); | 1752 GenerateMiss(masm); |
1753 } | 1753 } |
1754 | 1754 |
1755 | 1755 |
1756 static void CallStubInRecordCallTarget(MacroAssembler* masm, CodeStub* stub, | 1756 static void CallStubInRecordCallTarget(MacroAssembler* masm, CodeStub* stub, |
1757 bool is_super) { | 1757 bool is_super) { |
1758 // rax : number of arguments to the construct function | 1758 // rax : number of arguments to the construct function |
1759 // rbx : feedback vector | 1759 // rbx : feedback vector |
1760 // rcx : original constructor (for IsSuperConstructorCall) | 1760 // rcx : new target (for IsSuperConstructorCall) |
1761 // rdx : slot in feedback vector (Smi) | 1761 // rdx : slot in feedback vector (Smi) |
1762 // rdi : the function to call | 1762 // rdi : the function to call |
1763 FrameScope scope(masm, StackFrame::INTERNAL); | 1763 FrameScope scope(masm, StackFrame::INTERNAL); |
1764 | 1764 |
1765 // Number-of-arguments register must be smi-tagged to call out. | 1765 // Number-of-arguments register must be smi-tagged to call out. |
1766 __ Integer32ToSmi(rax, rax); | 1766 __ Integer32ToSmi(rax, rax); |
1767 __ Push(rax); | 1767 __ Push(rax); |
1768 __ Push(rdi); | 1768 __ Push(rdi); |
1769 __ Integer32ToSmi(rdx, rdx); | 1769 __ Integer32ToSmi(rdx, rdx); |
1770 __ Push(rdx); | 1770 __ Push(rdx); |
(...skipping 14 matching lines...) Expand all Loading... |
1785 __ SmiToInteger32(rax, rax); | 1785 __ SmiToInteger32(rax, rax); |
1786 } | 1786 } |
1787 | 1787 |
1788 | 1788 |
1789 static void GenerateRecordCallTarget(MacroAssembler* masm, bool is_super) { | 1789 static void GenerateRecordCallTarget(MacroAssembler* masm, bool is_super) { |
1790 // Cache the called function in a feedback vector slot. Cache states | 1790 // Cache the called function in a feedback vector slot. Cache states |
1791 // are uninitialized, monomorphic (indicated by a JSFunction), and | 1791 // are uninitialized, monomorphic (indicated by a JSFunction), and |
1792 // megamorphic. | 1792 // megamorphic. |
1793 // rax : number of arguments to the construct function | 1793 // rax : number of arguments to the construct function |
1794 // rbx : feedback vector | 1794 // rbx : feedback vector |
1795 // rcx : original constructor (for IsSuperConstructorCall) | 1795 // rcx : new target (for IsSuperConstructorCall) |
1796 // rdx : slot in feedback vector (Smi) | 1796 // rdx : slot in feedback vector (Smi) |
1797 // rdi : the function to call | 1797 // rdi : the function to call |
1798 Isolate* isolate = masm->isolate(); | 1798 Isolate* isolate = masm->isolate(); |
1799 Label initialize, done, miss, megamorphic, not_array_function, | 1799 Label initialize, done, miss, megamorphic, not_array_function, |
1800 done_no_smi_convert; | 1800 done_no_smi_convert; |
1801 | 1801 |
1802 // Load the cache state into r11. | 1802 // Load the cache state into r11. |
1803 __ SmiToInteger32(rdx, rdx); | 1803 __ SmiToInteger32(rdx, rdx); |
1804 __ movp(r11, | 1804 __ movp(r11, |
1805 FieldOperand(rbx, rdx, times_pointer_size, FixedArray::kHeaderSize)); | 1805 FieldOperand(rbx, rdx, times_pointer_size, FixedArray::kHeaderSize)); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1871 __ bind(&done); | 1871 __ bind(&done); |
1872 __ Integer32ToSmi(rdx, rdx); | 1872 __ Integer32ToSmi(rdx, rdx); |
1873 | 1873 |
1874 __ bind(&done_no_smi_convert); | 1874 __ bind(&done_no_smi_convert); |
1875 } | 1875 } |
1876 | 1876 |
1877 | 1877 |
1878 void CallConstructStub::Generate(MacroAssembler* masm) { | 1878 void CallConstructStub::Generate(MacroAssembler* masm) { |
1879 // rax : number of arguments | 1879 // rax : number of arguments |
1880 // rbx : feedback vector | 1880 // rbx : feedback vector |
1881 // rcx : original constructor (for IsSuperConstructorCall) | 1881 // rcx : new target (for IsSuperConstructorCall) |
1882 // rdx : slot in feedback vector (Smi, for RecordCallTarget) | 1882 // rdx : slot in feedback vector (Smi, for RecordCallTarget) |
1883 // rdi : constructor function | 1883 // rdi : constructor function |
1884 | 1884 |
1885 Label non_function; | 1885 Label non_function; |
1886 // Check that the constructor is not a smi. | 1886 // Check that the constructor is not a smi. |
1887 __ JumpIfSmi(rdi, &non_function); | 1887 __ JumpIfSmi(rdi, &non_function); |
1888 // Check that constructor is a JSFunction. | 1888 // Check that constructor is a JSFunction. |
1889 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, r11); | 1889 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, r11); |
1890 __ j(not_equal, &non_function); | 1890 __ j(not_equal, &non_function); |
1891 | 1891 |
1892 if (RecordCallTarget()) { | 1892 if (RecordCallTarget()) { |
1893 GenerateRecordCallTarget(masm, IsSuperConstructorCall()); | 1893 GenerateRecordCallTarget(masm, IsSuperConstructorCall()); |
1894 | 1894 |
1895 __ SmiToInteger32(rdx, rdx); | 1895 __ SmiToInteger32(rdx, rdx); |
1896 Label feedback_register_initialized; | 1896 Label feedback_register_initialized; |
1897 // Put the AllocationSite from the feedback vector into rbx, or undefined. | 1897 // Put the AllocationSite from the feedback vector into rbx, or undefined. |
1898 __ movp(rbx, FieldOperand(rbx, rdx, times_pointer_size, | 1898 __ movp(rbx, FieldOperand(rbx, rdx, times_pointer_size, |
1899 FixedArray::kHeaderSize)); | 1899 FixedArray::kHeaderSize)); |
1900 __ CompareRoot(FieldOperand(rbx, 0), Heap::kAllocationSiteMapRootIndex); | 1900 __ CompareRoot(FieldOperand(rbx, 0), Heap::kAllocationSiteMapRootIndex); |
1901 __ j(equal, &feedback_register_initialized); | 1901 __ j(equal, &feedback_register_initialized); |
1902 __ LoadRoot(rbx, Heap::kUndefinedValueRootIndex); | 1902 __ LoadRoot(rbx, Heap::kUndefinedValueRootIndex); |
1903 __ bind(&feedback_register_initialized); | 1903 __ bind(&feedback_register_initialized); |
1904 | 1904 |
1905 __ AssertUndefinedOrAllocationSite(rbx); | 1905 __ AssertUndefinedOrAllocationSite(rbx); |
1906 } | 1906 } |
1907 | 1907 |
1908 // Pass original constructor to construct stub. | 1908 // Pass new target to construct stub. |
1909 if (IsSuperConstructorCall()) { | 1909 if (IsSuperConstructorCall()) { |
1910 __ movp(rdx, rcx); | 1910 __ movp(rdx, rcx); |
1911 } else { | 1911 } else { |
1912 __ movp(rdx, rdi); | 1912 __ movp(rdx, rdi); |
1913 } | 1913 } |
1914 | 1914 |
1915 // Tail call to the function-specific construct stub (still in the caller | 1915 // Tail call to the function-specific construct stub (still in the caller |
1916 // context at this point). | 1916 // context at this point). |
1917 __ movp(rcx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); | 1917 __ movp(rcx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); |
1918 __ movp(rcx, FieldOperand(rcx, SharedFunctionInfo::kConstructStubOffset)); | 1918 __ movp(rcx, FieldOperand(rcx, SharedFunctionInfo::kConstructStubOffset)); |
(...skipping 2844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4763 UNREACHABLE(); | 4763 UNREACHABLE(); |
4764 } | 4764 } |
4765 } | 4765 } |
4766 | 4766 |
4767 | 4767 |
4768 void ArrayConstructorStub::Generate(MacroAssembler* masm) { | 4768 void ArrayConstructorStub::Generate(MacroAssembler* masm) { |
4769 // ----------- S t a t e ------------- | 4769 // ----------- S t a t e ------------- |
4770 // -- rax : argc | 4770 // -- rax : argc |
4771 // -- rbx : AllocationSite or undefined | 4771 // -- rbx : AllocationSite or undefined |
4772 // -- rdi : constructor | 4772 // -- rdi : constructor |
4773 // -- rdx : original constructor | 4773 // -- rdx : new target |
4774 // -- rsp[0] : return address | 4774 // -- rsp[0] : return address |
4775 // -- rsp[8] : last argument | 4775 // -- rsp[8] : last argument |
4776 // ----------------------------------- | 4776 // ----------------------------------- |
4777 if (FLAG_debug_code) { | 4777 if (FLAG_debug_code) { |
4778 // The array construct code is only set for the global and natives | 4778 // The array construct code is only set for the global and natives |
4779 // builtin Array functions which always have maps. | 4779 // builtin Array functions which always have maps. |
4780 | 4780 |
4781 // Initial map for the builtin Array function should be a map. | 4781 // Initial map for the builtin Array function should be a map. |
4782 __ movp(rcx, FieldOperand(rdi, JSFunction::kPrototypeOrInitialMapOffset)); | 4782 __ movp(rcx, FieldOperand(rdi, JSFunction::kPrototypeOrInitialMapOffset)); |
4783 // Will both indicate a NULL and a Smi. | 4783 // Will both indicate a NULL and a Smi. |
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5476 kStackSpace, nullptr, return_value_operand, NULL); | 5476 kStackSpace, nullptr, return_value_operand, NULL); |
5477 } | 5477 } |
5478 | 5478 |
5479 | 5479 |
5480 #undef __ | 5480 #undef __ |
5481 | 5481 |
5482 } // namespace internal | 5482 } // namespace internal |
5483 } // namespace v8 | 5483 } // namespace v8 |
5484 | 5484 |
5485 #endif // V8_TARGET_ARCH_X64 | 5485 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |