Revision: 7574
Author: [email protected]
Date: Mon Apr 11 09:16:52 2011
Log: Allow recursive messages reporting as it is already used.
Instead discard unhandled exceptions thown while running
message listeners.
Review URL: http://codereview.chromium.org/6820003
http://code.google.com/p/v8/source/detail?r=7574
Modified:
/branches/bleeding_edge/src/isolate.h
/branches/bleeding_edge/src/messages.cc
/branches/bleeding_edge/src/top.cc
/branches/bleeding_edge/test/cctest/test-api.cc
=======================================
--- /branches/bleeding_edge/src/isolate.h Fri Apr 8 02:39:45 2011
+++ /branches/bleeding_edge/src/isolate.h Mon Apr 11 09:16:52 2011
@@ -188,9 +188,6 @@
// unify them later.
MaybeObject* scheduled_exception_;
bool external_caught_exception_;
- // True if unhandled message is being currently reported by
- // MessageHandler::ReportMessage.
- bool in_exception_reporting_;
SaveContext* save_context_;
v8::TryCatch* catcher_;
@@ -526,12 +523,6 @@
bool* external_caught_exception_address() {
return &thread_local_top_.external_caught_exception_;
}
- bool in_exception_reporting() {
- return thread_local_top_.in_exception_reporting_;
- }
- void set_in_exception_reporting(bool value) {
- thread_local_top_.in_exception_reporting_ = value;
- }
v8::TryCatch* catcher() {
return thread_local_top_.catcher_;
}
=======================================
--- /branches/bleeding_edge/src/messages.cc Fri Apr 8 02:39:45 2011
+++ /branches/bleeding_edge/src/messages.cc Mon Apr 11 09:16:52 2011
@@ -104,15 +104,6 @@
void MessageHandler::ReportMessage(Isolate* isolate,
MessageLocation* loc,
Handle<Object> message) {
- // If we are in process of message reporting, just ignore all other
requests
- // to report a message as they are due to unhandled exceptions thrown in
- // message callbacks.
- if (isolate->in_exception_reporting()) {
- PrintF("uncaught exception thrown while reporting\n");
- return;
- }
- isolate->set_in_exception_reporting(true);
-
// We are calling into embedder's code which can throw exceptions.
// Thus we need to save current exception state, reset it to the clean
one
// and ignore scheduled exceptions callbacks can throw.
@@ -138,14 +129,16 @@
v8::MessageCallback callback =
FUNCTION_CAST<v8::MessageCallback>(callback_obj->proxy());
Handle<Object> callback_data(listener.get(1));
- callback(api_message_obj, v8::Utils::ToLocal(callback_data));
+ {
+ // Do not allow exceptions to propagate.
+ v8::TryCatch tryCatch;
+ callback(api_message_obj, v8::Utils::ToLocal(callback_data));
+ }
if (isolate->has_scheduled_exception()) {
isolate->clear_scheduled_exception();
}
}
}
-
- isolate->set_in_exception_reporting(false);
}
=======================================
--- /branches/bleeding_edge/src/top.cc Fri Apr 8 03:02:01 2011
+++ /branches/bleeding_edge/src/top.cc Mon Apr 11 09:16:52 2011
@@ -72,7 +72,6 @@
int id = Isolate::Current()->thread_manager()->CurrentId();
thread_id_ = (id == 0) ? ThreadManager::kInvalidId : id;
external_caught_exception_ = false;
- in_exception_reporting_ = false;
failed_access_check_callback_ = NULL;
save_context_ = NULL;
catcher_ = NULL;
=======================================
--- /branches/bleeding_edge/test/cctest/test-api.cc Mon Apr 11 02:04:30 2011
+++ /branches/bleeding_edge/test/cctest/test-api.cc Mon Apr 11 09:16:52 2011
@@ -8669,6 +8669,9 @@
CHECK(!i::Isolate::Current()->has_scheduled_exception());
return Undefined();
}
+
+
+static int call_depth;
static void WithTryCatch(Handle<Message> message, Handle<Value> data) {
@@ -8677,12 +8680,12 @@
static void ThrowFromJS(Handle<Message> message, Handle<Value> data) {
- CompileRun("throw 'ThrowInJS';");
+ if (--call_depth) CompileRun("throw 'ThrowInJS';");
}
static void ThrowViaApi(Handle<Message> message, Handle<Value> data) {
- ThrowException(v8_str("ThrowViaApi"));
+ if (--call_depth) ThrowException(v8_str("ThrowViaApi"));
}
@@ -8708,6 +8711,7 @@
if (callback != NULL) {
V8::AddMessageListener(callback);
}
+ call_depth = 5;
ExpectFalse(
"var thrown = false;\n"
"try { func(); } catch(e) { thrown = true; }\n"
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev