Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(583)

Side by Side Diff: vm/cpu_x64.cc

Issue 10664004: Fix issue 1968, replace usage of inline 'asm' constructs in 'stack alignment', 'jump to exception h… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « vm/cpu_ia32.cc ('k') | vm/exceptions.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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" 11 #include "vm/constants_x64.h"
12 #include "vm/heap.h" 12 #include "vm/heap.h"
13 #include "vm/isolate.h" 13 #include "vm/isolate.h"
14 #include "vm/object.h" 14 #include "vm/object.h"
15 15
16 namespace dart { 16 namespace dart {
17 17
18 void CPU::FlushICache(uword start, uword size) { 18 void CPU::FlushICache(uword start, uword size) {
19 // Nothing to be done here. 19 // Nothing to be done here.
20 } 20 }
21 21
22 22
23 void CPU::JumpToExceptionHandler(uword program_counter,
24 uword stack_pointer,
25 uword frame_pointer,
26 const Instance& exception_object,
27 const Instance& stacktrace_object) {
28 // The no_gc StackResource is unwound through the tear down of
29 // stack resources below.
30 NoGCScope no_gc;
31 RawInstance* exception = exception_object.raw();
32 RawInstance* stacktrace = stacktrace_object.raw();
33
34 // Prepare for unwinding frames by destroying all the stack resources
35 // in the previous frames.
36 Isolate* isolate = Isolate::Current();
37 while (isolate->top_resource() != NULL &&
38 (reinterpret_cast<uword>(isolate->top_resource()) < stack_pointer)) {
39 isolate->top_resource()->~StackResource();
40 }
41
42 // Set up the appropriate register state and jump to the handler.
43 ASSERT(kExceptionObjectReg == RAX);
44 ASSERT(kStackTraceObjectReg == RDX);
45 #if defined(TARGET_OS_WINDOWS)
46 UNIMPLEMENTED();
47 #else
48 asm volatile("mov %[exception], %%rax;"
49 "mov %[stacktrace], %%rdx;"
50 "mov %[pc], %%rbx;"
51 "mov %[fp], %%rcx;"
52 "mov %[sp], %%rdi;"
53 "mov %%rcx, %%rbp;"
54 "mov %%rdi, %%rsp;"
55 "jmp *%%rbx;"
56 :
57 : [exception] "m" (exception),
58 [stacktrace] "m" (stacktrace),
59 [pc] "m" (program_counter),
60 [sp] "m" (stack_pointer),
61 [fp] "m" (frame_pointer));
62 #endif
63 UNREACHABLE();
64 }
65
66
67 void CPU::JumpToErrorHandler(
68 uword program_counter,
69 uword stack_pointer,
70 uword frame_pointer,
71 const Error& error) {
72 // The no_gc StackResource is unwound through the tear down of
73 // stack resources below.
74 NoGCScope no_gc;
75 ASSERT(!error.IsNull());
76 RawError* raw_error = error.raw();
77
78 // Prepare for unwinding frames by destroying all the stack resources
79 // in the previous frames.
80 Isolate* isolate = Isolate::Current();
81 while (isolate->top_resource() != NULL &&
82 (reinterpret_cast<uword>(isolate->top_resource()) < stack_pointer)) {
83 isolate->top_resource()->~StackResource();
84 }
85
86 // Set up the error object as the return value in RAX and continue
87 // from the invocation stub.
88 #if defined(TARGET_OS_WINDOWS)
89 UNIMPLEMENTED();
90 #else
91 asm volatile("mov %[raw_error], %%rax;"
92 "mov %[pc], %%rbx;"
93 "mov %[fp], %%rcx;"
94 "mov %[sp], %%rdi;"
95 "mov %%rcx, %%rbp;"
96 "mov %%rdi, %%rsp;"
97 "jmp *%%rbx;"
98 :
99 : [raw_error] "m" (raw_error),
100 [pc] "m" (program_counter),
101 [sp] "m" (stack_pointer),
102 [fp] "m" (frame_pointer));
103 #endif
104 UNREACHABLE();
105 }
106
107
108 const char* CPU::Id() { 23 const char* CPU::Id() {
109 return "x64"; 24 return "x64";
110 } 25 }
111 26
112 } // namespace dart 27 } // namespace dart
113 28
114 #endif // defined TARGET_ARCH_X64 29 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « vm/cpu_ia32.cc ('k') | vm/exceptions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698