OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/globals.h" | 5 #include "vm/globals.h" |
6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
7 | 7 |
8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
(...skipping 1827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1838 // Return the current stack pointer address, used to stack alignment | 1838 // Return the current stack pointer address, used to stack alignment |
1839 // checks. | 1839 // checks. |
1840 // TOS + 0: return address | 1840 // TOS + 0: return address |
1841 // Result in RAX. | 1841 // Result in RAX. |
1842 void StubCode::GenerateGetStackPointerStub(Assembler* assembler) { | 1842 void StubCode::GenerateGetStackPointerStub(Assembler* assembler) { |
1843 __ leaq(RAX, Address(RSP, kWordSize)); | 1843 __ leaq(RAX, Address(RSP, kWordSize)); |
1844 __ ret(); | 1844 __ ret(); |
1845 } | 1845 } |
1846 | 1846 |
1847 | 1847 |
1848 // Jump to a frame on the call stack. | 1848 // Jump to the exception or error handler. |
1849 // TOS + 0: return address | 1849 // TOS + 0: return address |
1850 // Arg1: program counter | 1850 // Arg1: program counter |
1851 // Arg2: stack pointer | 1851 // Arg2: stack pointer |
1852 // Arg3: frame_pointer | 1852 // Arg3: frame_pointer |
1853 // Arg4: thread | 1853 // Arg4: exception object |
| 1854 // Arg5: stacktrace object |
| 1855 // Arg6: thread |
1854 // No Result. | 1856 // No Result. |
1855 void StubCode::GenerateJumpToFrameStub(Assembler* assembler) { | 1857 void StubCode::GenerateJumpToExceptionHandlerStub(Assembler* assembler) { |
1856 __ movq(THR, CallingConventions::kArg4Reg); | 1858 ASSERT(kExceptionObjectReg == RAX); |
| 1859 ASSERT(kStackTraceObjectReg == RDX); |
| 1860 ASSERT(CallingConventions::kArg4Reg != kStackTraceObjectReg); |
| 1861 ASSERT(CallingConventions::kArg1Reg != kStackTraceObjectReg); |
| 1862 |
| 1863 #if defined(_WIN64) |
| 1864 Register stacktrace_reg = RBX; |
| 1865 __ movq(stacktrace_reg, Address(RSP, 5 * kWordSize)); |
| 1866 __ movq(THR, Address(RSP, 6 * kWordSize)); |
| 1867 #else |
| 1868 Register stacktrace_reg = CallingConventions::kArg5Reg; |
| 1869 __ movq(THR, CallingConventions::kArg6Reg); |
| 1870 #endif |
1857 __ movq(RBP, CallingConventions::kArg3Reg); | 1871 __ movq(RBP, CallingConventions::kArg3Reg); |
1858 __ movq(RSP, CallingConventions::kArg2Reg); | 1872 __ movq(RSP, CallingConventions::kArg2Reg); |
| 1873 __ movq(kStackTraceObjectReg, stacktrace_reg); |
| 1874 __ movq(kExceptionObjectReg, CallingConventions::kArg4Reg); |
1859 // Set the tag. | 1875 // Set the tag. |
1860 __ movq(Assembler::VMTagAddress(), Immediate(VMTag::kDartTagId)); | 1876 __ movq(Assembler::VMTagAddress(), Immediate(VMTag::kDartTagId)); |
1861 // Clear top exit frame. | 1877 // Clear top exit frame. |
1862 __ movq(Address(THR, Thread::top_exit_frame_info_offset()), Immediate(0)); | 1878 __ movq(Address(THR, Thread::top_exit_frame_info_offset()), Immediate(0)); |
1863 // Restore the pool pointer. | 1879 // Restore the pool pointer. |
1864 __ RestoreCodePointer(); | 1880 __ RestoreCodePointer(); |
1865 __ LoadPoolPointer(PP); | 1881 __ LoadPoolPointer(PP); |
1866 __ jmp(CallingConventions::kArg1Reg); // Jump to program counter. | 1882 __ jmp(CallingConventions::kArg1Reg); // Jump to the exception handler code. |
1867 } | 1883 } |
1868 | 1884 |
1869 | 1885 |
1870 // Run an exception handler. Execution comes from JumpToFrame stub. | |
1871 // | |
1872 // The arguments are stored in the Thread object. | |
1873 // No result. | |
1874 void StubCode::GenerateRunExceptionHandlerStub(Assembler* assembler) { | |
1875 ASSERT(kExceptionObjectReg == RAX); | |
1876 ASSERT(kStackTraceObjectReg == RDX); | |
1877 __ movq(CallingConventions::kArg1Reg, | |
1878 Address(THR, Thread::resume_pc_offset())); | |
1879 | |
1880 // Load the exception from the current thread. | |
1881 Address exception_addr(THR, Thread::active_exception_offset()); | |
1882 __ movq(kExceptionObjectReg, exception_addr); | |
1883 __ movq(exception_addr, Immediate(0)); | |
1884 | |
1885 // Load the stacktrace from the current thread. | |
1886 Address stacktrace_addr(THR, Thread::active_stacktrace_offset()); | |
1887 __ movq(kStackTraceObjectReg, stacktrace_addr); | |
1888 __ movq(stacktrace_addr, Immediate(0)); | |
1889 | |
1890 __ jmp(CallingConventions::kArg1Reg); // Jump to continuation point. | |
1891 } | |
1892 | |
1893 | |
1894 // Calls to the runtime to optimize the given function. | 1886 // Calls to the runtime to optimize the given function. |
1895 // RDI: function to be reoptimized. | 1887 // RDI: function to be reoptimized. |
1896 // R10: argument descriptor (preserved). | 1888 // R10: argument descriptor (preserved). |
1897 void StubCode::GenerateOptimizeFunctionStub(Assembler* assembler) { | 1889 void StubCode::GenerateOptimizeFunctionStub(Assembler* assembler) { |
1898 __ EnterStubFrame(); | 1890 __ EnterStubFrame(); |
1899 __ pushq(R10); // Preserve args descriptor. | 1891 __ pushq(R10); // Preserve args descriptor. |
1900 __ pushq(Immediate(0)); // Result slot. | 1892 __ pushq(Immediate(0)); // Result slot. |
1901 __ pushq(RDI); // Arg0: function to optimize | 1893 __ pushq(RDI); // Arg0: function to optimize |
1902 __ CallRuntime(kOptimizeInvokedFunctionRuntimeEntry, 1); | 1894 __ CallRuntime(kOptimizeInvokedFunctionRuntimeEntry, 1); |
1903 __ popq(RAX); // Disard argument. | 1895 __ popq(RAX); // Disard argument. |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2254 } | 2246 } |
2255 | 2247 |
2256 | 2248 |
2257 void StubCode::GenerateFrameAwaitingMaterializationStub(Assembler* assembler) { | 2249 void StubCode::GenerateFrameAwaitingMaterializationStub(Assembler* assembler) { |
2258 __ int3(); | 2250 __ int3(); |
2259 } | 2251 } |
2260 | 2252 |
2261 } // namespace dart | 2253 } // namespace dart |
2262 | 2254 |
2263 #endif // defined TARGET_ARCH_X64 | 2255 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |