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

Unified Diff: src/top.cc

Issue 8050: Changed the message reporting for try { ... } finally { ... } statements to... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 12 years, 2 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 | « src/top.h ('k') | test/message/bugs/try-finally-linenum.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/top.cc
===================================================================
--- src/top.cc (revision 557)
+++ src/top.cc (working copy)
@@ -594,19 +594,25 @@
// reworked.
static const char* kMessage =
"Uncaught RangeError: Maximum call stack size exceeded";
- DoThrow(*exception, NULL, kMessage, false);
+ DoThrow(*exception, NULL, kMessage);
return Failure::Exception();
}
Failure* Top::Throw(Object* exception, MessageLocation* location) {
- DoThrow(exception, location, NULL, false);
+ DoThrow(exception, location, NULL);
return Failure::Exception();
}
Failure* Top::ReThrow(Object* exception, MessageLocation* location) {
- DoThrow(exception, location, NULL, true);
+ // Check is this exception is externally caught.
+ bool is_caught_externally = false;
+ ShouldReportException(&is_caught_externally);
+ thread_local_.external_caught_exception_ = is_caught_externally;
+
+ // Set the exception beeing re-thrown.
+ set_pending_exception(exception);
return Failure::Exception();
}
@@ -724,22 +730,17 @@
// 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 or try-finally handler.
- while (handler != NULL && handler->is_entry()) {
+ // Find the top-most try-catch handler.
+ while (handler != NULL && !handler->is_try_catch()) {
handler = handler->next();
}
// The exception has been externally caught if and only if there is
- // an external handler which is above any JavaScript try-catch or
+ // an external handler which is above any JavaScript try-catch but NOT
// try-finally handlers.
*is_caught_externally = has_external_handler &&
(handler == NULL || handler->address() > external_handler_address);
- // Find the top-most try-catch handler.
- while (handler != NULL && !handler->is_try_catch()) {
- handler = handler->next();
- }
-
// If we have a try-catch handler then the exception is caught in
// JavaScript code.
bool is_uncaught_by_js = (handler == NULL);
@@ -760,23 +761,23 @@
void Top::DoThrow(Object* exception,
MessageLocation* location,
- const char* message,
- bool is_rethrow) {
+ const char* message) {
ASSERT(!has_pending_exception());
- ASSERT(!external_caught_exception());
HandleScope scope;
Handle<Object> exception_handle(exception);
+ // Determine reporting and whether the exception is caught externally.
bool is_caught_externally = false;
bool report_exception = (exception != Failure::OutOfMemoryException()) &&
- ShouldReportException(&is_caught_externally);
- if (is_rethrow) report_exception = false;
+ ShouldReportException(&is_caught_externally);
+ // Generate the message.
Handle<Object> message_obj;
MessageLocation potential_computed_location;
bool try_catch_needs_message =
- is_caught_externally && thread_local_.try_catch_handler_->capture_message_;
+ is_caught_externally &&
+ thread_local_.try_catch_handler_->capture_message_;
if (report_exception || try_catch_needs_message) {
if (location == NULL) {
// If no location was specified we use a computed one instead
@@ -812,6 +813,7 @@
}
}
thread_local_.external_caught_exception_ = is_caught_externally;
+
// NOTE: Notifying the debugger or reporting the exception may have caused
// new exceptions. For now, we just ignore that and set the pending exception
// to the original one.
« no previous file with comments | « src/top.h ('k') | test/message/bugs/try-finally-linenum.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698