Commit 61e4b602 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

Remove superfluous ThreadLocalTop::catcher field.

The external v8::TryCatch handler was computed eagerly and kept in
intact. This changes it to be computed lazily for simplicity and
readability of the code.

R=bmeurer@chromium.org

Review URL: https://codereview.chromium.org/997863003

Cr-Commit-Position: refs/heads/master@{#27132}
parent 88a7f24f
......@@ -82,7 +82,6 @@ void ThreadLocalTop::InitializeInternal() {
external_caught_exception_ = false;
failed_access_check_callback_ = NULL;
save_context_ = NULL;
catcher_ = NULL;
promise_on_stack_ = NULL;
// These members are re-initialized later after deserialization
......@@ -252,7 +251,6 @@ void Isolate::RegisterTryCatchHandler(v8::TryCatch* that) {
void Isolate::UnregisterTryCatchHandler(v8::TryCatch* that) {
DCHECK(thread_local_top()->try_catch_handler() == that);
thread_local_top()->set_try_catch_handler(that->next_);
thread_local_top()->catcher_ = NULL;
}
......@@ -1005,11 +1003,6 @@ Object* Isolate::Throw(Object* exception, MessageLocation* location) {
// Save the message for reporting if the the exception remains uncaught.
thread_local_top()->has_pending_message_ = report_exception;
// Do not forget to clean catcher_ if currently thrown exception cannot
// be caught. If necessary, ReThrow will update the catcher.
thread_local_top()->catcher_ =
can_be_caught_externally ? try_catch_handler() : NULL;
// Set the exception being thrown.
set_pending_exception(*exception_handle);
return heap()->exception();
......@@ -1017,12 +1010,7 @@ Object* Isolate::Throw(Object* exception, MessageLocation* location) {
Object* Isolate::ReThrow(Object* exception) {
bool can_be_caught_externally = false;
bool catchable_by_javascript = is_catchable_by_javascript(exception);
ShouldReportException(&can_be_caught_externally, catchable_by_javascript);
thread_local_top()->catcher_ = can_be_caught_externally ?
try_catch_handler() : NULL;
DCHECK(!has_pending_exception());
// Set the exception being re-thrown.
set_pending_exception(exception);
......@@ -1387,14 +1375,6 @@ Handle<JSMessageObject> Isolate::CreateMessage(Handle<Object> exception,
}
bool Isolate::HasExternalTryCatch() {
DCHECK(has_pending_exception());
return (thread_local_top()->catcher_ != NULL) &&
(try_catch_handler() == thread_local_top()->catcher_);
}
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.
......@@ -1954,22 +1934,23 @@ void Isolate::InitializeThreadLocal() {
bool Isolate::PropagatePendingExceptionToExternalTryCatch() {
DCHECK(has_pending_exception());
Object* exception = pending_exception();
bool has_external_try_catch = HasExternalTryCatch();
if (!has_external_try_catch) {
bool can_be_caught_externally = false;
bool catchable_by_javascript = is_catchable_by_javascript(exception);
ShouldReportException(&can_be_caught_externally, catchable_by_javascript);
if (!can_be_caught_externally) {
thread_local_top_.external_caught_exception_ = false;
return true;
}
bool catchable_by_js = is_catchable_by_javascript(pending_exception());
if (catchable_by_js && IsFinallyOnTop()) {
if (catchable_by_javascript && IsFinallyOnTop()) {
thread_local_top_.external_caught_exception_ = false;
return false;
}
thread_local_top_.external_caught_exception_ = true;
if (thread_local_top_.pending_exception_ == heap()->termination_exception()) {
if (!catchable_by_javascript) {
try_catch_handler()->can_continue_ = false;
try_catch_handler()->has_terminated_ = true;
try_catch_handler()->exception_ = heap()->null_value();
......
......@@ -292,7 +292,6 @@ class ThreadLocalTop BASE_EMBEDDED {
Object* scheduled_exception_;
bool external_caught_exception_;
SaveContext* save_context_;
v8::TryCatch* catcher_;
// Stack.
Address c_entry_fp_; // the frame pointer of the top c entry frame
......@@ -618,8 +617,6 @@ class Isolate {
return &thread_local_top_.external_caught_exception_;
}
THREAD_LOCAL_TOP_ACCESSOR(v8::TryCatch*, catcher)
THREAD_LOCAL_TOP_ADDRESS(Object*, scheduled_exception)
Address pending_message_obj_address() {
......@@ -644,7 +641,6 @@ class Isolate {
thread_local_top_.scheduled_exception_ = heap_.the_hole_value();
}
bool HasExternalTryCatch();
bool IsFinallyOnTop();
bool is_catchable_by_javascript(Object* exception) {
......@@ -708,23 +704,19 @@ class Isolate {
class ExceptionScope {
public:
explicit ExceptionScope(Isolate* isolate) :
// Scope currently can only be used for regular exceptions,
// not termination exception.
isolate_(isolate),
pending_exception_(isolate_->pending_exception(), isolate_),
catcher_(isolate_->catcher())
{ }
// Scope currently can only be used for regular exceptions,
// not termination exception.
explicit ExceptionScope(Isolate* isolate)
: isolate_(isolate),
pending_exception_(isolate_->pending_exception(), isolate_) {}
~ExceptionScope() {
isolate_->set_catcher(catcher_);
isolate_->set_pending_exception(*pending_exception_);
}
private:
Isolate* isolate_;
Handle<Object> pending_exception_;
v8::TryCatch* catcher_;
};
void SetCaptureStackTraceForUncaughtExceptions(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment