Reviewers: Benedikt Meurer,
Description:
Remove superfluous ThreadLocalTop::catcher field.
The external v8::TryCatch handler was computed eagerly and kept in
intact. This changes is to be computed lazily for simplicity and
readability of the code.
[email protected]
Please review this at https://codereview.chromium.org/997863003/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+13, -40 lines):
M src/isolate.h
M src/isolate.cc
Index: src/isolate.cc
diff --git a/src/isolate.cc b/src/isolate.cc
index
c704e06338b83a0a91d9c48ddc33d5266fc258c9..841e583c8bc22be0dcb9fec28b221e35aa2c6d07
100644
--- a/src/isolate.cc
+++ b/src/isolate.cc
@@ -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();
Index: src/isolate.h
diff --git a/src/isolate.h b/src/isolate.h
index
ab62d371dce328088b0238970aa1a5e7c5f813cb..e8c2a711ed81ccf9fe8d80abc484179f4e6b3fe4
100644
--- a/src/isolate.h
+++ b/src/isolate.h
@@ -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(
--
--
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.