Reviewers: iposva, Description: Fix the exception order by remember JS handler in an external handler.
Please review this at http://codereview.chromium.org/10625 SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/ Affected files: M include/v8.h M src/api.cc M src/top.cc Index: src/top.cc =================================================================== --- src/top.cc (revision 727) +++ src/top.cc (working copy) @@ -254,6 +254,7 @@ void Top::RegisterTryCatchHandler(v8::TryCatch* that) { + that->js_handler_ = thread_local_.handler_; // casted to void* thread_local_.try_catch_handler_ = that; } @@ -719,8 +720,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 +732,10 @@ } // 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. *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 +745,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 { Index: include/v8.h =================================================================== --- include/v8.h (revision 727) +++ include/v8.h (working copy) @@ -2052,6 +2052,7 @@ void* message_; bool is_verbose_; bool capture_message_; + void* js_handler_; }; Index: src/api.cc =================================================================== --- src/api.cc (revision 727) +++ src/api.cc (working copy) @@ -1081,7 +1081,8 @@ exception_(i::Heap::the_hole_value()), message_(i::Smi::FromInt(0)), is_verbose_(false), - capture_message_(true) { + capture_message_(true), + js_handler_(NULL) { i::Top::RegisterTryCatchHandler(this); } --~--~---------~--~----~------------~-------~--~----~ v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev -~----------~----~----~----~------~----~------~--~---
