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

Side by Side Diff: vm/cpu_ia32.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_arm.cc ('k') | vm/cpu_x64.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) 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_IA32) 7 #if defined(TARGET_ARCH_IA32)
8 8
9 #include "vm/cpu.h" 9 #include "vm/cpu.h"
10 10
11 #include "vm/constants_ia32.h" 11 #include "vm/constants_ia32.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 == EAX);
44 ASSERT(kStackTraceObjectReg == EDX);
45 #if defined(TARGET_OS_WINDOWS)
46 __asm {
47 mov eax, exception
48 mov edx, stacktrace
49 mov ebx, program_counter
50 mov ecx, frame_pointer
51 mov edi, stack_pointer
52 mov ebp, ecx
53 mov esp, edi
54 jmp ebx
55 }
56 #else
57 asm volatile("mov %[exception], %%eax;"
58 "mov %[stacktrace], %%edx;"
59 "mov %[pc], %%ebx;"
60 "mov %[fp], %%ecx;"
61 "mov %[sp], %%edi;"
62 "mov %%ecx, %%ebp;"
63 "mov %%edi, %%esp;"
64 "jmp *%%ebx;"
65 :
66 : [exception] "m" (exception),
67 [stacktrace] "m" (stacktrace),
68 [pc] "m" (program_counter),
69 [sp] "m" (stack_pointer),
70 [fp] "m" (frame_pointer));
71 #endif
72 UNREACHABLE();
73 }
74
75
76 void CPU::JumpToErrorHandler(
77 uword program_counter,
78 uword stack_pointer,
79 uword frame_pointer,
80 const Error& error) {
81 // The no_gc StackResource is unwound through the tear down of
82 // stack resources below.
83 NoGCScope no_gc;
84 ASSERT(!error.IsNull());
85 RawError* raw_error = error.raw();
86
87 // Prepare for unwinding frames by destroying all the stack resources
88 // in the previous frames.
89 Isolate* isolate = Isolate::Current();
90 while (isolate->top_resource() != NULL &&
91 (reinterpret_cast<uword>(isolate->top_resource()) < stack_pointer)) {
92 isolate->top_resource()->~StackResource();
93 }
94
95 // Set up the error object as the return value in EAX and continue
96 // from the invocation stub.
97 #if defined(TARGET_OS_WINDOWS)
98 __asm {
99 mov eax, raw_error
100 mov ebx, program_counter
101 mov ecx, frame_pointer
102 mov edi, stack_pointer
103 mov ebp, ecx
104 mov esp, edi
105 jmp ebx
106 }
107 #else
108 asm volatile("mov %[raw_error], %%eax;"
109 "mov %[pc], %%ebx;"
110 "mov %[fp], %%ecx;"
111 "mov %[sp], %%edi;"
112 "mov %%ecx, %%ebp;"
113 "mov %%edi, %%esp;"
114 "jmp *%%ebx;"
115 :
116 : [raw_error] "m" (raw_error),
117 [pc] "m" (program_counter),
118 [sp] "m" (stack_pointer),
119 [fp] "m" (frame_pointer));
120 #endif
121 UNREACHABLE();
122 }
123
124
125 const char* CPU::Id() { 23 const char* CPU::Id() {
126 return "ia32"; 24 return "ia32";
127 } 25 }
128 26
129 } // namespace dart 27 } // namespace dart
130 28
131 #endif // defined TARGET_ARCH_IA32 29 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « vm/cpu_arm.cc ('k') | vm/cpu_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698