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 the exception or error handler. | 1848 // Jump to a frame on the call stack. |
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: exception object | 1853 // Arg4: thread |
1854 // Arg5: stacktrace object | |
1855 // Arg6: thread | |
1856 // No Result. | 1854 // No Result. |
1857 void StubCode::GenerateJumpToExceptionHandlerStub(Assembler* assembler) { | 1855 void StubCode::GenerateJumpToFrameStub(Assembler* assembler) { |
1858 ASSERT(kExceptionObjectReg == RAX); | 1856 __ movq(THR, CallingConventions::kArg4Reg); |
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 | |
1871 __ movq(RBP, CallingConventions::kArg3Reg); | 1857 __ movq(RBP, CallingConventions::kArg3Reg); |
1872 __ movq(RSP, CallingConventions::kArg2Reg); | 1858 __ movq(RSP, CallingConventions::kArg2Reg); |
1873 __ movq(kStackTraceObjectReg, stacktrace_reg); | |
1874 __ movq(kExceptionObjectReg, CallingConventions::kArg4Reg); | |
1875 // Set the tag. | 1859 // Set the tag. |
1876 __ movq(Assembler::VMTagAddress(), Immediate(VMTag::kDartTagId)); | 1860 __ movq(Assembler::VMTagAddress(), Immediate(VMTag::kDartTagId)); |
1877 // Clear top exit frame. | 1861 // Clear top exit frame. |
1878 __ movq(Address(THR, Thread::top_exit_frame_info_offset()), Immediate(0)); | 1862 __ movq(Address(THR, Thread::top_exit_frame_info_offset()), Immediate(0)); |
1879 // Restore the pool pointer. | 1863 // Restore the pool pointer. |
1880 __ RestoreCodePointer(); | 1864 __ RestoreCodePointer(); |
1881 __ LoadPoolPointer(PP); | 1865 __ LoadPoolPointer(PP); |
1882 __ jmp(CallingConventions::kArg1Reg); // Jump to the exception handler code. | 1866 __ jmp(CallingConventions::kArg1Reg); // Jump to program counter. |
1883 } | 1867 } |
1884 | 1868 |
1885 | 1869 |
| 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 |
1886 // Calls to the runtime to optimize the given function. | 1894 // Calls to the runtime to optimize the given function. |
1887 // RDI: function to be reoptimized. | 1895 // RDI: function to be reoptimized. |
1888 // R10: argument descriptor (preserved). | 1896 // R10: argument descriptor (preserved). |
1889 void StubCode::GenerateOptimizeFunctionStub(Assembler* assembler) { | 1897 void StubCode::GenerateOptimizeFunctionStub(Assembler* assembler) { |
1890 __ EnterStubFrame(); | 1898 __ EnterStubFrame(); |
1891 __ pushq(R10); // Preserve args descriptor. | 1899 __ pushq(R10); // Preserve args descriptor. |
1892 __ pushq(Immediate(0)); // Result slot. | 1900 __ pushq(Immediate(0)); // Result slot. |
1893 __ pushq(RDI); // Arg0: function to optimize | 1901 __ pushq(RDI); // Arg0: function to optimize |
1894 __ CallRuntime(kOptimizeInvokedFunctionRuntimeEntry, 1); | 1902 __ CallRuntime(kOptimizeInvokedFunctionRuntimeEntry, 1); |
1895 __ popq(RAX); // Disard argument. | 1903 __ popq(RAX); // Disard argument. |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2246 } | 2254 } |
2247 | 2255 |
2248 | 2256 |
2249 void StubCode::GenerateFrameAwaitingMaterializationStub(Assembler* assembler) { | 2257 void StubCode::GenerateFrameAwaitingMaterializationStub(Assembler* assembler) { |
2250 __ int3(); | 2258 __ int3(); |
2251 } | 2259 } |
2252 | 2260 |
2253 } // namespace dart | 2261 } // namespace dart |
2254 | 2262 |
2255 #endif // defined TARGET_ARCH_X64 | 2263 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |