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_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
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 1774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1785 | 1785 |
1786 // Return the current stack pointer address, used to do stack alignment checks. | 1786 // Return the current stack pointer address, used to do stack alignment checks. |
1787 // TOS + 0: return address | 1787 // TOS + 0: return address |
1788 // Result in EAX. | 1788 // Result in EAX. |
1789 void StubCode::GenerateGetStackPointerStub(Assembler* assembler) { | 1789 void StubCode::GenerateGetStackPointerStub(Assembler* assembler) { |
1790 __ leal(EAX, Address(ESP, kWordSize)); | 1790 __ leal(EAX, Address(ESP, kWordSize)); |
1791 __ ret(); | 1791 __ ret(); |
1792 } | 1792 } |
1793 | 1793 |
1794 | 1794 |
1795 // Jump to the exception or error handler. | 1795 // Jump to a frame on the call stack. |
1796 // TOS + 0: return address | 1796 // TOS + 0: return address |
1797 // TOS + 1: program_counter | 1797 // TOS + 1: program_counter |
1798 // TOS + 2: stack_pointer | 1798 // TOS + 2: stack_pointer |
1799 // TOS + 3: frame_pointer | 1799 // TOS + 3: frame_pointer |
1800 // TOS + 4: exception object | 1800 // TOS + 4: thread |
1801 // TOS + 5: stacktrace object | |
1802 // TOS + 6: thread | |
1803 // No Result. | 1801 // No Result. |
1804 void StubCode::GenerateJumpToExceptionHandlerStub(Assembler* assembler) { | 1802 void StubCode::GenerateJumpToFrameStub(Assembler* assembler) { |
1805 ASSERT(kExceptionObjectReg == EAX); | 1803 __ movl(THR, Address(ESP, 4 * kWordSize)); // Load target thread. |
1806 ASSERT(kStackTraceObjectReg == EDX); | |
1807 __ movl(THR, Address(ESP, 6 * kWordSize)); // Load target thread. | |
1808 __ movl(kStackTraceObjectReg, Address(ESP, 5 * kWordSize)); | |
1809 __ movl(kExceptionObjectReg, Address(ESP, 4 * kWordSize)); | |
1810 __ movl(EBP, Address(ESP, 3 * kWordSize)); // Load target frame_pointer. | 1804 __ movl(EBP, Address(ESP, 3 * kWordSize)); // Load target frame_pointer. |
1811 __ movl(EBX, Address(ESP, 1 * kWordSize)); // Load target PC into EBX. | 1805 __ movl(EBX, Address(ESP, 1 * kWordSize)); // Load target PC into EBX. |
1812 __ movl(ESP, Address(ESP, 2 * kWordSize)); // Load target stack_pointer. | 1806 __ movl(ESP, Address(ESP, 2 * kWordSize)); // Load target stack_pointer. |
1813 // Set tag. | 1807 // Set tag. |
1814 __ movl(Assembler::VMTagAddress(), Immediate(VMTag::kDartTagId)); | 1808 __ movl(Assembler::VMTagAddress(), Immediate(VMTag::kDartTagId)); |
1815 // Clear top exit frame. | 1809 // Clear top exit frame. |
1816 __ movl(Address(THR, Thread::top_exit_frame_info_offset()), Immediate(0)); | 1810 __ movl(Address(THR, Thread::top_exit_frame_info_offset()), Immediate(0)); |
1817 __ jmp(EBX); // Jump to the exception handler code. | 1811 __ jmp(EBX); // Jump to the exception handler code. |
1818 } | 1812 } |
1819 | 1813 |
1820 | 1814 |
| 1815 // Run an exception handler. Execution comes from JumpToFrame stub. |
| 1816 // |
| 1817 // The arguments are stored in the Thread object. |
| 1818 // No result. |
| 1819 void StubCode::GenerateRunExceptionHandlerStub(Assembler* assembler) { |
| 1820 ASSERT(kExceptionObjectReg == EAX); |
| 1821 ASSERT(kStackTraceObjectReg == EDX); |
| 1822 __ movl(EBX, Address(THR, Thread::resume_pc_offset())); |
| 1823 |
| 1824 // Load the exception from the current thread. |
| 1825 Address exception_addr(THR, Thread::active_exception_offset()); |
| 1826 __ movl(kExceptionObjectReg, exception_addr); |
| 1827 __ movl(exception_addr, Immediate(0)); |
| 1828 |
| 1829 // Load the stacktrace from the current thread. |
| 1830 Address stacktrace_addr(THR, Thread::active_stacktrace_offset()); |
| 1831 __ movl(kStackTraceObjectReg, stacktrace_addr); |
| 1832 __ movl(stacktrace_addr, Immediate(0)); |
| 1833 |
| 1834 __ jmp(EBX); // Jump to continuation point. |
| 1835 } |
| 1836 |
| 1837 |
1821 // Calls to the runtime to optimize the given function. | 1838 // Calls to the runtime to optimize the given function. |
1822 // EBX: function to be reoptimized. | 1839 // EBX: function to be reoptimized. |
1823 // EDX: argument descriptor (preserved). | 1840 // EDX: argument descriptor (preserved). |
1824 void StubCode::GenerateOptimizeFunctionStub(Assembler* assembler) { | 1841 void StubCode::GenerateOptimizeFunctionStub(Assembler* assembler) { |
1825 __ EnterStubFrame(); | 1842 __ EnterStubFrame(); |
1826 __ pushl(EDX); | 1843 __ pushl(EDX); |
1827 __ pushl(Immediate(0)); // Setup space on stack for return value. | 1844 __ pushl(Immediate(0)); // Setup space on stack for return value. |
1828 __ pushl(EBX); | 1845 __ pushl(EBX); |
1829 __ CallRuntime(kOptimizeInvokedFunctionRuntimeEntry, 1); | 1846 __ CallRuntime(kOptimizeInvokedFunctionRuntimeEntry, 1); |
1830 __ popl(EAX); // Discard argument. | 1847 __ popl(EAX); // Discard argument. |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2053 } | 2070 } |
2054 | 2071 |
2055 | 2072 |
2056 void StubCode::GenerateFrameAwaitingMaterializationStub(Assembler* assembler) { | 2073 void StubCode::GenerateFrameAwaitingMaterializationStub(Assembler* assembler) { |
2057 __ int3(); | 2074 __ int3(); |
2058 } | 2075 } |
2059 | 2076 |
2060 } // namespace dart | 2077 } // namespace dart |
2061 | 2078 |
2062 #endif // defined TARGET_ARCH_IA32 | 2079 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |