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

Unified Diff: src/top.cc

Issue 10625: Fix the exception order by remember JS handler in an external handler. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 12 years, 1 month 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/api.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/top.cc
===================================================================
--- src/top.cc (revision 742)
+++ src/top.cc (working copy)
@@ -253,7 +253,30 @@
}
+// There are cases where the C stack is separated from JS stack (ARM simulator).
+// To figure out the order of top-most JS try-catch handler and the top-most C
+// try-catch handler, the C try-catch handler keeps a reference to the top-most
+// JS try_catch handler when it was created.
+//
+// Here is a picture to explain the idea:
+// Top::thread_local_.handler_ Top::thread_local_.try_catch_handler_
+//
+// | |
+// v v
+//
+// | JS handler | | C try_catch handler |
+// | next |--+ +-------- | js_handler_ |
+// | | | next_ |--+
+// | | |
+// | JS handler |--+ <---------+ |
+// | next |
+//
+// If the top-most JS try-catch handler is not equal to
+// Top::thread_local_.try_catch_handler_.js_handler_, it means the JS handler
+// is on the top. Otherwise, it means the C try-catch handler is on the top.
+//
void Top::RegisterTryCatchHandler(v8::TryCatch* that) {
+ that->js_handler_ = thread_local_.handler_; // casted to void*
thread_local_.try_catch_handler_ = that;
}
@@ -719,8 +742,7 @@
// 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);
- Address external_handler_address =
- reinterpret_cast<Address>(thread_local_.try_catch_handler_);
+ 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
@@ -732,10 +754,12 @@
}
// The exception has been externally caught if and only if there is
- // an external handler which is above any JavaScript try-catch but NOT
- // try-finally handlers.
+ // an external handler which is on top of the top-most try-catch
+ // handler.
+ //
+ // See comments in RegisterTryCatchHandler for details.
*is_caught_externally = has_external_handler &&
- (handler == NULL || handler->address() > external_handler_address);
+ (handler == NULL || handler == try_catch->js_handler_);
// If we have a try-catch handler then the exception is caught in
// JavaScript code.
@@ -745,7 +769,7 @@
// exception if it isn't caught by JavaScript code.
if (!has_external_handler) return is_uncaught_by_js;
- if (is_uncaught_by_js || handler->address() > external_handler_address) {
+ if (is_uncaught_by_js || handler == try_catch->js_handler_) {
// Only report the exception if the external handler is verbose.
return thread_local_.try_catch_handler_->is_verbose_;
} else {
« no previous file with comments | « src/api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698