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_X64 | 5 #if V8_TARGET_ARCH_X64 |
6 | 6 |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
9 #include "src/deoptimizer.h" | 9 #include "src/deoptimizer.h" |
10 #include "src/full-codegen/full-codegen.h" | 10 #include "src/full-codegen/full-codegen.h" |
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 // Drop receiver + arguments and return. | 764 // Drop receiver + arguments and return. |
765 __ movl(rbx, FieldOperand(kInterpreterBytecodeArrayRegister, | 765 __ movl(rbx, FieldOperand(kInterpreterBytecodeArrayRegister, |
766 BytecodeArray::kParameterSizeOffset)); | 766 BytecodeArray::kParameterSizeOffset)); |
767 __ PopReturnAddressTo(rcx); | 767 __ PopReturnAddressTo(rcx); |
768 __ addp(rsp, rbx); | 768 __ addp(rsp, rbx); |
769 __ PushReturnAddressFrom(rcx); | 769 __ PushReturnAddressFrom(rcx); |
770 __ ret(0); | 770 __ ret(0); |
771 } | 771 } |
772 | 772 |
773 | 773 |
| 774 // static |
| 775 void Builtins::Generate_InterpreterPushArgsAndCall(MacroAssembler* masm) { |
| 776 // ----------- S t a t e ------------- |
| 777 // -- rax : the number of arguments (not including the receiver) |
| 778 // -- rbx : the address of the first argument to be pushed. Subsequent |
| 779 // arguments should be consecutive above this, in the same order as |
| 780 // they are to be pushed onto the stack. |
| 781 // -- rdi : the target to call (can be any Object). |
| 782 |
| 783 // Pop return address to allow tail-call after pushing arguments. |
| 784 __ Pop(rdx); |
| 785 |
| 786 // Find the address of the last argument. |
| 787 __ movp(rcx, rax); |
| 788 __ addp(rcx, Immediate(1)); // Add one for receiver. |
| 789 __ shlp(rcx, Immediate(kPointerSizeLog2)); |
| 790 __ negp(rcx); |
| 791 __ addp(rcx, rbx); |
| 792 |
| 793 // Push the arguments. |
| 794 Label loop_header, loop_check; |
| 795 __ j(always, &loop_check); |
| 796 __ bind(&loop_header); |
| 797 __ Push(Operand(rbx, 0)); |
| 798 __ subp(rbx, Immediate(kPointerSize)); |
| 799 __ bind(&loop_check); |
| 800 __ cmpp(rbx, rcx); |
| 801 __ j(greater, &loop_header, Label::kNear); |
| 802 |
| 803 // Call the target. |
| 804 __ Push(rdx); // Re-push return address. |
| 805 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); |
| 806 } |
| 807 |
| 808 |
774 void Builtins::Generate_CompileLazy(MacroAssembler* masm) { | 809 void Builtins::Generate_CompileLazy(MacroAssembler* masm) { |
775 CallRuntimePassFunction(masm, Runtime::kCompileLazy); | 810 CallRuntimePassFunction(masm, Runtime::kCompileLazy); |
776 GenerateTailCallToReturnedCode(masm); | 811 GenerateTailCallToReturnedCode(masm); |
777 } | 812 } |
778 | 813 |
779 | 814 |
780 static void CallCompileOptimized(MacroAssembler* masm, | 815 static void CallCompileOptimized(MacroAssembler* masm, |
781 bool concurrent) { | 816 bool concurrent) { |
782 FrameScope scope(masm, StackFrame::INTERNAL); | 817 FrameScope scope(masm, StackFrame::INTERNAL); |
783 // Push a copy of the function onto the stack. | 818 // Push a copy of the function onto the stack. |
(...skipping 1041 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1825 // method. | 1860 // method. |
1826 __ bind(&non_constructor); | 1861 __ bind(&non_constructor); |
1827 { | 1862 { |
1828 FrameScope scope(masm, StackFrame::INTERNAL); | 1863 FrameScope scope(masm, StackFrame::INTERNAL); |
1829 __ Push(rdi); | 1864 __ Push(rdi); |
1830 __ CallRuntime(Runtime::kThrowCalledNonCallable, 1); | 1865 __ CallRuntime(Runtime::kThrowCalledNonCallable, 1); |
1831 } | 1866 } |
1832 } | 1867 } |
1833 | 1868 |
1834 | 1869 |
1835 // static | |
1836 void Builtins::Generate_PushArgsAndCall(MacroAssembler* masm) { | |
1837 // ----------- S t a t e ------------- | |
1838 // -- rax : the number of arguments (not including the receiver) | |
1839 // -- rbx : the address of the first argument to be pushed. Subsequent | |
1840 // arguments should be consecutive above this, in the same order as | |
1841 // they are to be pushed onto the stack. | |
1842 // -- rdi : the target to call (can be any Object). | |
1843 | |
1844 // Pop return address to allow tail-call after pushing arguments. | |
1845 __ Pop(rdx); | |
1846 | |
1847 // Find the address of the last argument. | |
1848 __ movp(rcx, rax); | |
1849 __ addp(rcx, Immediate(1)); // Add one for receiver. | |
1850 __ shlp(rcx, Immediate(kPointerSizeLog2)); | |
1851 __ negp(rcx); | |
1852 __ addp(rcx, rbx); | |
1853 | |
1854 // Push the arguments. | |
1855 Label loop_header, loop_check; | |
1856 __ j(always, &loop_check); | |
1857 __ bind(&loop_header); | |
1858 __ Push(Operand(rbx, 0)); | |
1859 __ subp(rbx, Immediate(kPointerSize)); | |
1860 __ bind(&loop_check); | |
1861 __ cmpp(rbx, rcx); | |
1862 __ j(greater, &loop_header, Label::kNear); | |
1863 | |
1864 // Call the target. | |
1865 __ Push(rdx); // Re-push return address. | |
1866 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); | |
1867 } | |
1868 | |
1869 | |
1870 void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) { | 1870 void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) { |
1871 // Lookup the function in the JavaScript frame. | 1871 // Lookup the function in the JavaScript frame. |
1872 __ movp(rax, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); | 1872 __ movp(rax, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); |
1873 { | 1873 { |
1874 FrameScope scope(masm, StackFrame::INTERNAL); | 1874 FrameScope scope(masm, StackFrame::INTERNAL); |
1875 // Pass function as argument. | 1875 // Pass function as argument. |
1876 __ Push(rax); | 1876 __ Push(rax); |
1877 __ CallRuntime(Runtime::kCompileForOnStackReplacement, 1); | 1877 __ CallRuntime(Runtime::kCompileForOnStackReplacement, 1); |
1878 } | 1878 } |
1879 | 1879 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1919 __ ret(0); | 1919 __ ret(0); |
1920 } | 1920 } |
1921 | 1921 |
1922 | 1922 |
1923 #undef __ | 1923 #undef __ |
1924 | 1924 |
1925 } // namespace internal | 1925 } // namespace internal |
1926 } // namespace v8 | 1926 } // namespace v8 |
1927 | 1927 |
1928 #endif // V8_TARGET_ARCH_X64 | 1928 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |