Reviewers: vsevik,
Description:
V8 don't clear exception pending message if we have externally try catch
block,
but there is finally block on top of stack.
Please review this at https://codereview.chromium.org/306463002/
SVN Base: git://github.com/v8/v8.git@master
Affected files (+22, -12 lines):
M src/isolate.h
M src/isolate.cc
Index: src/isolate.cc
diff --git a/src/isolate.cc b/src/isolate.cc
index
3542b994ff3338ffd3860b763f49b4730dfe6d54..2ae9b4d59e7ebe436ac6f3322a94aac50e835567
100644
--- a/src/isolate.cc
+++ b/src/isolate.cc
@@ -1154,10 +1154,11 @@ bool Isolate::IsExternallyCaught() {
return false;
}
- if (!is_catchable_by_javascript(pending_exception())) {
- return true;
- }
+ return true;
+}
+
+bool Isolate::IsFinallyOnTop() {
// 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.
Address external_handler_address =
@@ -1177,18 +1178,18 @@ bool Isolate::IsExternallyCaught() {
StackHandler::FromAddress(Isolate::handler(thread_local_top()));
while (handler != NULL && handler->address() < external_handler_address)
{
ASSERT(!handler->is_catch());
- if (handler->is_finally()) return false;
+ if (handler->is_finally()) return true;
handler = handler->next();
}
- return true;
+ return false;
}
void Isolate::ReportPendingMessages() {
ASSERT(has_pending_exception());
- PropagatePendingExceptionToExternalTryCatch();
+ bool canClearMessage = PropagatePendingExceptionToExternalTryCatch();
HandleScope scope(this);
if (thread_local_top_.pending_exception_ ==
@@ -1215,7 +1216,8 @@ void Isolate::ReportPendingMessages() {
}
}
}
- clear_pending_message();
+ if (canClearMessage)
+ clear_pending_message();
}
@@ -1722,13 +1724,19 @@ void Isolate::InitializeThreadLocal() {
}
-void Isolate::PropagatePendingExceptionToExternalTryCatch() {
+// Return true. if we don't pending message and can remove it
+bool Isolate::PropagatePendingExceptionToExternalTryCatch() {
ASSERT(has_pending_exception());
bool external_caught = IsExternallyCaught();
- thread_local_top_.external_caught_exception_ = external_caught;
+ bool finally_on_top = IsFinallyOnTop();
- if (!external_caught) return;
+ bool next_external_caught = external_caught && !finally_on_top;
+ thread_local_top_.external_caught_exception_ = next_external_caught;
+
+ // if no v8::TryCatch - we don't need store exception andf can clear it
+ if (!external_caught) return true;
+ if (finally_on_top) return false;
if (thread_local_top_.pending_exception_ ==
heap()->termination_exception()) {
@@ -1745,13 +1753,14 @@ void
Isolate::PropagatePendingExceptionToExternalTryCatch() {
handler->has_terminated_ = false;
handler->exception_ = pending_exception();
// Propagate to the external try-catch only if we got an actual
message.
- if (thread_local_top_.pending_message_obj_->IsTheHole()) return;
+ if (thread_local_top_.pending_message_obj_->IsTheHole()) return true;
handler->message_obj_ = thread_local_top_.pending_message_obj_;
handler->message_script_ = thread_local_top_.pending_message_script_;
handler->message_start_pos_ =
thread_local_top_.pending_message_start_pos_;
handler->message_end_pos_ = thread_local_top_.pending_message_end_pos_;
}
+ return true;
}
Index: src/isolate.h
diff --git a/src/isolate.h b/src/isolate.h
index
bc7646bd4834bafc03bf333f53da14ee072ac451..963f5f53076fb89e3d89ede87315cd70c085acbc
100644
--- a/src/isolate.h
+++ b/src/isolate.h
@@ -606,6 +606,7 @@ class Isolate {
}
bool IsExternallyCaught();
+ bool IsFinallyOnTop();
bool is_catchable_by_javascript(Object* exception) {
return exception != heap()->termination_exception();
@@ -1178,7 +1179,7 @@ class Isolate {
void FillCache();
- void PropagatePendingExceptionToExternalTryCatch();
+ bool PropagatePendingExceptionToExternalTryCatch();
void InitializeDebugger();
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.