Commit f1aa70ac authored by olehougaard's avatar olehougaard

Simplify the logic determining whether to report an exception.

Review URL: http://codereview.chromium.org/13283

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@946 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent ccf388fc
...@@ -749,46 +749,31 @@ void Top::ReportUncaughtException(Handle<Object> exception, ...@@ -749,46 +749,31 @@ void Top::ReportUncaughtException(Handle<Object> exception,
bool Top::ShouldReportException(bool* is_caught_externally) { bool Top::ShouldReportException(bool* is_caught_externally) {
// Find the top-most try-catch handler.
StackHandler* handler = StackHandler* handler =
StackHandler::FromAddress(Top::handler(Top::GetCurrentThread())); StackHandler::FromAddress(Top::handler(Top::GetCurrentThread()));
// Determine if we have an external exception handler and get the
// address of the external handler so we can compare the address to
// determine which one is closer to the top of the stack.
bool has_external_handler = (thread_local_.try_catch_handler_ != NULL);
v8::TryCatch* try_catch = thread_local_.try_catch_handler_;
// NOTE: The stack is assumed to grown towards lower addresses. If
// the handler is at a higher address than the external address it
// means that it is below it on the stack.
// Find the top-most try-catch handler.
while (handler != NULL && !handler->is_try_catch()) { while (handler != NULL && !handler->is_try_catch()) {
handler = handler->next(); handler = handler->next();
} }
// Get the address of the external handler so we can compare the address to
// determine which one is closer to the top of the stack.
v8::TryCatch* try_catch = thread_local_.try_catch_handler_;
// The exception has been externally caught if and only if there is // The exception has been externally caught if and only if there is
// an external handler which is on top of the top-most try-catch // an external handler which is on top of the top-most try-catch
// handler. // handler.
// //
// See comments in RegisterTryCatchHandler for details. // See comments in RegisterTryCatchHandler for details.
*is_caught_externally = has_external_handler && *is_caught_externally = try_catch != NULL &&
(handler == NULL || handler == try_catch->js_handler_); (handler == NULL || handler == try_catch->js_handler_);
// If we have a try-catch handler then the exception is caught in if (*is_caught_externally) {
// JavaScript code.
bool is_uncaught_by_js = (handler == NULL);
// If there is no external try-catch handler, we report the
// exception if it isn't caught by JavaScript code.
if (!has_external_handler) return is_uncaught_by_js;
if (is_uncaught_by_js || handler == try_catch->js_handler_) {
// Only report the exception if the external handler is verbose. // Only report the exception if the external handler is verbose.
return thread_local_.try_catch_handler_->is_verbose_; return thread_local_.try_catch_handler_->is_verbose_;
} else { } else {
// Report the exception if it isn't caught by JavaScript code. // Report the exception if it isn't caught by JavaScript code.
return is_uncaught_by_js; return handler == NULL;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment