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

Unified Diff: vm/exceptions.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, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « vm/cpu_x64.cc ('k') | vm/native_arguments.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: vm/exceptions.cc
===================================================================
--- vm/exceptions.cc (revision 9040)
+++ vm/exceptions.cc (working copy)
@@ -4,12 +4,12 @@
#include "vm/exceptions.h"
-#include "vm/cpu.h"
#include "vm/dart_entry.h"
#include "vm/debugger.h"
#include "vm/flags.h"
#include "vm/object.h"
#include "vm/stack_frame.h"
+#include "vm/stub_code.h"
namespace dart {
@@ -64,6 +64,62 @@
}
+void JumpToExceptionHandler(uword program_counter,
+ uword stack_pointer,
+ uword frame_pointer,
+ const Instance& exception_object,
+ const Instance& stacktrace_object) {
+ // The no_gc StackResource is unwound through the tear down of
+ // stack resources below.
+ NoGCScope no_gc;
+ RawInstance* exception = exception_object.raw();
+ RawInstance* stacktrace = stacktrace_object.raw();
+
+ // Prepare for unwinding frames by destroying all the stack resources
+ // in the previous frames.
+ Isolate* isolate = Isolate::Current();
+ while (isolate->top_resource() != NULL &&
+ (reinterpret_cast<uword>(isolate->top_resource()) < stack_pointer)) {
+ isolate->top_resource()->~StackResource();
+ }
+
+ // Set up the appropriate register state and jump to the handler.
+ typedef void (*ExcpHandler)(uword, uword, uword, RawInstance*, RawInstance*);
+ ExcpHandler func = reinterpret_cast<ExcpHandler>(
+ StubCode::JumpToExceptionHandlerEntryPoint());
+ func(program_counter, stack_pointer, frame_pointer, exception, stacktrace);
+ UNREACHABLE();
+}
+
+
+void JumpToErrorHandler(uword program_counter,
+ uword stack_pointer,
+ uword frame_pointer,
+ const Error& error) {
+ // The no_gc StackResource is unwound through the tear down of
+ // stack resources below.
+ NoGCScope no_gc;
+ ASSERT(!error.IsNull());
+ RawError* raw_error = error.raw();
+
+ // Prepare for unwinding frames by destroying all the stack resources
+ // in the previous frames.
+ Isolate* isolate = Isolate::Current();
+ while (isolate->top_resource() != NULL &&
+ (reinterpret_cast<uword>(isolate->top_resource()) < stack_pointer)) {
+ isolate->top_resource()->~StackResource();
+ }
+
+ // Set up the error object as the return value in EAX and continue
+ // from the invocation stub.
+ typedef void (*ErrorHandler)(uword, uword, uword, RawError*);
+ ErrorHandler func = reinterpret_cast<ErrorHandler>(
+ StubCode::JumpToErrorHandlerEntryPoint());
+ func(program_counter, stack_pointer, frame_pointer, raw_error);
+ UNREACHABLE();
+}
+
+
static void ThrowExceptionHelper(const Instance& incoming_exception,
const Instance& existing_stacktrace) {
Instance& exception = Instance::Handle(incoming_exception.raw());
@@ -99,11 +155,11 @@
}
if (handler_exists) {
// Found a dart handler for the exception, jump to it.
- CPU::JumpToExceptionHandler(handler_pc,
- handler_sp,
- handler_fp,
- exception,
- stacktrace);
+ JumpToExceptionHandler(handler_pc,
+ handler_sp,
+ handler_fp,
+ exception,
+ stacktrace);
} else {
// No dart exception handler found in this invocation sequence,
// so we create an unhandled exception object and return to the
@@ -114,10 +170,7 @@
// the isolate etc.).
const UnhandledException& unhandled_exception = UnhandledException::Handle(
UnhandledException::New(exception, stacktrace));
- CPU::JumpToErrorHandler(handler_pc,
- handler_sp,
- handler_fp,
- unhandled_exception);
+ JumpToErrorHandler(handler_pc, handler_sp, handler_fp, unhandled_exception);
}
UNREACHABLE();
}
@@ -279,7 +332,7 @@
uword handler_sp = 0;
uword handler_fp = 0;
FindErrorHandler(&handler_pc, &handler_sp, &handler_fp);
- CPU::JumpToErrorHandler(handler_pc, handler_sp, handler_fp, error);
+ JumpToErrorHandler(handler_pc, handler_sp, handler_fp, error);
}
UNREACHABLE();
}
« no previous file with comments | « vm/cpu_x64.cc ('k') | vm/native_arguments.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698