Chromium Code Reviews| Index: src/top.h |
| diff --git a/src/top.h b/src/top.h |
| index 5b0fd6157cbd4da5c822e1442ea47824a4eecf85..fb7f5c893627e88f62d9878c7f0a51662dbc9bec 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 Scope { |
| + public: |
| + Scope() : |
|
Vitaly Repeshko
2011/02/01 19:07:17
Does it lint?
antonm
2011/02/01 20:14:39
Yes
|
| + // 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()) |
| + { } |
| + |
| + ~Scope() { |
| + 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_; |
| + }; |
| }; |