Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1055)

Unified Diff: src/top.h

Issue 6397011: Make exception thrown via v8 public API propagate to v8::TryCatch as JS thrown exceptions do. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressing Vitaly's comments Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/messages.cc ('k') | src/top.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/top.h
diff --git a/src/top.h b/src/top.h
index 5b0fd6157cbd4da5c822e1442ea47824a4eecf85..74b6229e84b1dc2ea0a624083316bc4353e77daa 100644
--- a/src/top.h
+++ b/src/top.h
@@ -186,22 +186,26 @@ class Top {
ASSERT(has_pending_exception());
return thread_local_.pending_exception_;
}
- static bool external_caught_exception() {
- return thread_local_.external_caught_exception_;
- }
static void set_pending_exception(MaybeObject* exception) {
thread_local_.pending_exception_ = exception;
}
static void clear_pending_exception() {
thread_local_.pending_exception_ = Heap::the_hole_value();
}
-
static MaybeObject** pending_exception_address() {
return &thread_local_.pending_exception_;
}
static bool has_pending_exception() {
return !thread_local_.pending_exception_->IsTheHole();
}
+
+ static bool external_caught_exception() {
+ return thread_local_.external_caught_exception_;
+ }
+ static void set_external_caught_exception(bool value) {
+ thread_local_.external_caught_exception_ = value;
+ }
+
static void clear_pending_message() {
thread_local_.has_pending_message_ = false;
thread_local_.pending_message_ = NULL;
@@ -240,13 +244,6 @@ class Top {
thread_local_.scheduled_exception_ = Heap::the_hole_value();
}
- static void setup_external_caught() {
- thread_local_.external_caught_exception_ =
- has_pending_exception() &&
- (thread_local_.catcher_ != NULL) &&
- (try_catch_handler() == thread_local_.catcher_);
- }
-
static void SetCaptureStackTraceForUncaughtExceptions(
bool capture,
int frame_limit,
@@ -452,6 +449,25 @@ class Top {
static const char* kStackOverflowMessage;
private:
+
+ static v8::TryCatch* catcher() {
+ return thread_local_.catcher_;
+ }
+
+ static void set_catcher(v8::TryCatch* catcher) {
+ thread_local_.catcher_ = catcher;
+ }
+
+ static void setup_external_caught() {
+ thread_local_.external_caught_exception_ =
+ has_pending_exception() &&
+ (thread_local_.catcher_ != NULL) &&
+ (try_catch_handler() == thread_local_.catcher_);
+ }
+
+ // Attempts to propagate the pending exception to the proper v8::TryCatch.
+ static void PropagatePendingExceptionToExternalTryCatch();
+
#ifdef ENABLE_VMSTATE_TRACKING
// Set of states used when communicating with the runtime profiler.
//
@@ -516,6 +532,29 @@ class Top {
friend class ThreadLocalTop;
static void FillCache();
+
+ public:
+ class ExceptionScope {
+ public:
+ ExceptionScope() :
+ // Scope currently can only be used for regular exceptions, not
+ // failures like OOM or termination exception.
+ pending_exception_(Top::pending_exception()->ToObjectUnchecked()),
+ external_caught_exception_(Top::external_caught_exception()),
+ catcher_(Top::catcher())
+ { }
+
+ ~ExceptionScope() {
+ Top::set_catcher(catcher_);
+ Top::set_external_caught_exception(external_caught_exception);
+ Top::set_pending_exception(*pending_exception_);
+ }
+
+ private:
+ Handle<Object> pending_exception_;
+ bool external_caught_exception_;
+ v8::TryCatch* catcher_;
+ };
};
« no previous file with comments | « src/messages.cc ('k') | src/top.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698