OLD | NEW |
---|---|
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 | 6 |
7 #if defined(TARGET_ARCH_X64) | 7 #if defined(TARGET_ARCH_X64) |
8 | 8 |
9 #include "vm/cpu.h" | 9 #include "vm/cpu.h" |
10 | 10 |
11 #include "vm/constants_x64.h" | |
12 #include "vm/heap.h" | |
13 #include "vm/isolate.h" | |
14 #include "vm/object.h" | |
15 | |
11 namespace dart { | 16 namespace dart { |
12 | 17 |
13 void CPU::FlushICache(uword start, uword size) { | 18 void CPU::FlushICache(uword start, uword size) { |
14 // Nothing to be done here. | 19 // Nothing to be done here. |
15 } | 20 } |
16 | 21 |
17 | 22 |
18 void CPU::JumpToExceptionHandler(uword pc, | 23 void CPU::JumpToExceptionHandler(uword program_counter, |
19 uword sp, | 24 uword stack_pointer, |
20 uword fp, | 25 uword frame_pointer, |
21 const Instance& exception_object, | 26 const Instance& exception_object, |
22 const Instance& stacktrace_object) { | 27 const Instance& stacktrace_object) { |
23 UNIMPLEMENTED(); | 28 NoGCScope no_gc; |
29 RawInstance* exception = exception_object.raw(); | |
30 RawInstance* stacktrace = stacktrace_object.raw(); | |
31 | |
32 // Prepare for unwinding frames by destroying all the stack resources | |
33 // in the previous frames. | |
34 Isolate* isolate = Isolate::Current(); | |
35 while (isolate->top_resource() != NULL && | |
36 (reinterpret_cast<uword>(isolate->top_resource()) < stack_pointer)) { | |
37 isolate->top_resource()->~StackResource(); | |
38 } | |
39 | |
40 // Set up the appropriate register state and jump to the handler. | |
41 ASSERT(kExceptionObjectReg == RAX); | |
42 ASSERT(kStackTraceObjectReg == RDX); | |
43 #if defined(TARGET_OS_WINDOWS) | |
44 __asm { | |
Ivan Posva
2012/01/11 00:49:18
Please do not put code into the repository that ha
regis
2012/01/11 01:51:12
Done. I guess we should use stubs instead of inlin
| |
45 mov rax, exception | |
46 mov rdx, stacktrace | |
47 mov rbx, program_counter | |
48 mov rcx, frame_pointer | |
49 mov rdi, stack_pointer | |
50 mov rbp, rcx | |
51 mov rsp, rdi | |
52 jmp rbx | |
53 } | |
54 #else | |
55 asm volatile("mov %[exception], %%rax;" | |
56 "mov %[stacktrace], %%rdx;" | |
57 "mov %[pc], %%rbx;" | |
58 "mov %[fp], %%rcx;" | |
59 "mov %[sp], %%rdi;" | |
60 "mov %%rcx, %%rbp;" | |
61 "mov %%rdi, %%rsp;" | |
62 "jmp *%%rbx;" | |
63 : | |
64 : [exception] "m" (exception), | |
65 [stacktrace] "m" (stacktrace), | |
66 [pc] "m" (program_counter), | |
67 [sp] "m" (stack_pointer), | |
68 [fp] "m" (frame_pointer)); | |
69 #endif | |
70 UNREACHABLE(); | |
24 } | 71 } |
25 | 72 |
26 | 73 |
27 void CPU::JumpToUnhandledExceptionHandler( | 74 void CPU::JumpToUnhandledExceptionHandler( |
28 uword pc, | 75 uword program_counter, |
29 uword sp, | 76 uword stack_pointer, |
30 uword fp, | 77 uword frame_pointer, |
31 const UnhandledException& unhandled_exception) { | 78 const UnhandledException& unhandled_exception_object) { |
32 UNIMPLEMENTED(); | 79 NoGCScope no_gc; |
80 ASSERT(!unhandled_exception_object.IsNull()); | |
81 RawUnhandledException* unhandled_exception = unhandled_exception_object.raw(); | |
82 | |
83 // Prepare for unwinding frames by destroying all the stack resources | |
84 // in the previous frames. | |
85 Isolate* isolate = Isolate::Current(); | |
86 while (isolate->top_resource() != NULL && | |
87 (reinterpret_cast<uword>(isolate->top_resource()) < stack_pointer)) { | |
88 isolate->top_resource()->~StackResource(); | |
89 } | |
90 | |
91 // Set up the unhandled exception object as the return value in EAX | |
92 // and continue from the invocation stub. | |
93 #if defined(TARGET_OS_WINDOWS) | |
94 __asm { | |
Ivan Posva
2012/01/11 00:49:18
ditto.
regis
2012/01/11 01:51:12
Done.
| |
95 mov rax, unhandled_exception | |
96 mov rbx, program_counter | |
97 mov rcx, frame_pointer | |
98 mov rdi, stack_pointer | |
99 mov rbp, rcx | |
100 mov rsp, rdi | |
101 jmp rbx | |
102 } | |
103 #else | |
104 asm volatile("mov %[unhandled_exception], %%rax;" | |
105 "mov %[pc], %%rbx;" | |
106 "mov %[fp], %%rcx;" | |
107 "mov %[sp], %%rdi;" | |
108 "mov %%rcx, %%rbp;" | |
109 "mov %%rdi, %%rsp;" | |
110 "jmp *%%rbx;" | |
111 : | |
112 : [unhandled_exception] "m" (unhandled_exception), | |
113 [pc] "m" (program_counter), | |
114 [sp] "m" (stack_pointer), | |
115 [fp] "m" (frame_pointer)); | |
116 #endif | |
117 UNREACHABLE(); | |
33 } | 118 } |
34 | 119 |
35 | 120 |
36 const char* CPU::Id() { | 121 const char* CPU::Id() { |
37 return "x64"; | 122 return "x64"; |
38 } | 123 } |
39 | 124 |
40 } // namespace dart | 125 } // namespace dart |
41 | 126 |
42 #endif // defined TARGET_ARCH_X64 | 127 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |