| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 // Top has static variables used for JavaScript execution. | 39 // Top has static variables used for JavaScript execution. |
| 40 | 40 |
| 41 class SaveContext; // Forward decleration. | 41 class SaveContext; // Forward decleration. |
| 42 | 42 |
| 43 class ThreadLocalTop BASE_EMBEDDED { | 43 class ThreadLocalTop BASE_EMBEDDED { |
| 44 public: | 44 public: |
| 45 // The context where the current execution method is created and for variable | 45 // The context where the current execution method is created and for variable |
| 46 // lookups. | 46 // lookups. |
| 47 Context* context_; | 47 Context* context_; |
| 48 Object* pending_exception_; | 48 Object* pending_exception_; |
| 49 const char* pending_message_; | |
| 50 Object* pending_message_obj_; | |
| 51 Script* pending_message_script_; | |
| 52 int pending_message_start_pos_; | |
| 53 int pending_message_end_pos_; | |
| 54 // Use a separate value for scheduled exceptions to preserve the | 49 // Use a separate value for scheduled exceptions to preserve the |
| 55 // invariants that hold about pending_exception. We may want to | 50 // invariants that hold about pending_exception. We may want to |
| 56 // unify them later. | 51 // unify them later. |
| 57 Object* scheduled_exception_; | 52 Object* scheduled_exception_; |
| 58 bool external_caught_exception_; | 53 bool external_caught_exception_; |
| 59 v8::TryCatch* try_catch_handler_; | 54 v8::TryCatch* try_catch_handler_; |
| 60 SaveContext* save_context_; | 55 SaveContext* save_context_; |
| 61 v8::TryCatch* catcher_; | 56 v8::TryCatch* catcher_; |
| 62 | 57 |
| 63 // Stack. | 58 // Stack. |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 static void clear_pending_exception() { | 113 static void clear_pending_exception() { |
| 119 thread_local_.pending_exception_ = Heap::the_hole_value(); | 114 thread_local_.pending_exception_ = Heap::the_hole_value(); |
| 120 } | 115 } |
| 121 | 116 |
| 122 static Object** pending_exception_address() { | 117 static Object** pending_exception_address() { |
| 123 return &thread_local_.pending_exception_; | 118 return &thread_local_.pending_exception_; |
| 124 } | 119 } |
| 125 static bool has_pending_exception() { | 120 static bool has_pending_exception() { |
| 126 return !thread_local_.pending_exception_->IsTheHole(); | 121 return !thread_local_.pending_exception_->IsTheHole(); |
| 127 } | 122 } |
| 128 static void clear_pending_message() { | |
| 129 thread_local_.catcher_ = NULL; | |
| 130 thread_local_.pending_message_ = NULL; | |
| 131 thread_local_.pending_message_obj_ = Heap::the_hole_value(); | |
| 132 thread_local_.pending_message_script_ = NULL; | |
| 133 } | |
| 134 static v8::TryCatch* try_catch_handler() { | 123 static v8::TryCatch* try_catch_handler() { |
| 135 return thread_local_.try_catch_handler_; | 124 return thread_local_.try_catch_handler_; |
| 136 } | 125 } |
| 137 // This method is called by the api after operations that may throw | 126 // This method is called by the api after operations that may throw |
| 138 // exceptions. If an exception was thrown and not handled by an external | 127 // exceptions. If an exception was thrown and not handled by an external |
| 139 // handler the exception is scheduled to be rethrown when we return to running | 128 // handler the exception is scheduled to be rethrown when we return to running |
| 140 // JavaScript code. If an exception is scheduled true is returned. | 129 // JavaScript code. If an exception is scheduled true is returned. |
| 141 static bool optional_reschedule_exception(bool is_bottom_call); | 130 static bool optional_reschedule_exception(bool is_bottom_call); |
| 142 | 131 |
| 143 static bool* external_caught_exception_address() { | 132 static bool* external_caught_exception_address() { |
| 144 return &thread_local_.external_caught_exception_; | 133 return &thread_local_.external_caught_exception_; |
| 145 } | 134 } |
| 146 | 135 |
| 147 static Object* scheduled_exception() { | 136 static Object* scheduled_exception() { |
| 148 ASSERT(has_scheduled_exception()); | 137 ASSERT(has_scheduled_exception()); |
| 149 return thread_local_.scheduled_exception_; | 138 return thread_local_.scheduled_exception_; |
| 150 } | 139 } |
| 151 static bool has_scheduled_exception() { | 140 static bool has_scheduled_exception() { |
| 152 return !thread_local_.scheduled_exception_->IsTheHole(); | 141 return !thread_local_.scheduled_exception_->IsTheHole(); |
| 153 } | 142 } |
| 154 static void clear_scheduled_exception() { | 143 static void clear_scheduled_exception() { |
| 155 thread_local_.scheduled_exception_ = Heap::the_hole_value(); | 144 thread_local_.scheduled_exception_ = Heap::the_hole_value(); |
| 156 } | 145 } |
| 157 | 146 |
| 158 static void setup_external_caught() { | 147 static void setup_external_caught() { |
| 159 thread_local_.external_caught_exception_ = | 148 thread_local_.external_caught_exception_ = |
| 160 (!thread_local_.pending_exception_->IsTheHole()) && | |
| 161 (thread_local_.catcher_ != NULL) && | 149 (thread_local_.catcher_ != NULL) && |
| 162 (Top::thread_local_.try_catch_handler_ == Top::thread_local_.catcher_); | 150 (Top::thread_local_.try_catch_handler_ == Top::thread_local_.catcher_); |
| 163 } | 151 } |
| 164 | 152 |
| 165 // Tells whether the current context has experienced an out of memory | 153 // Tells whether the current context has experienced an out of memory |
| 166 // exception. | 154 // exception. |
| 167 static bool is_out_of_memory(); | 155 static bool is_out_of_memory(); |
| 168 | 156 |
| 169 // JS execution stack (see frames.h). | 157 // JS execution stack (see frames.h). |
| 170 static Address c_entry_fp(ThreadLocalTop* thread) { | 158 static Address c_entry_fp(ThreadLocalTop* thread) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 static void ReportFailedAccessCheck(JSObject* receiver, v8::AccessType type); | 200 static void ReportFailedAccessCheck(JSObject* receiver, v8::AccessType type); |
| 213 | 201 |
| 214 // Exception throwing support. The caller should use the result | 202 // Exception throwing support. The caller should use the result |
| 215 // of Throw() as its return value. | 203 // of Throw() as its return value. |
| 216 static Failure* Throw(Object* exception, MessageLocation* location = NULL); | 204 static Failure* Throw(Object* exception, MessageLocation* location = NULL); |
| 217 // Re-throw an exception. This involves no error reporting since | 205 // Re-throw an exception. This involves no error reporting since |
| 218 // error reporting was handled when the exception was thrown | 206 // error reporting was handled when the exception was thrown |
| 219 // originally. | 207 // originally. |
| 220 static Failure* ReThrow(Object* exception, MessageLocation* location = NULL); | 208 static Failure* ReThrow(Object* exception, MessageLocation* location = NULL); |
| 221 static void ScheduleThrow(Object* exception); | 209 static void ScheduleThrow(Object* exception); |
| 222 static void ReportPendingMessages(); | |
| 223 | 210 |
| 224 // Promote a scheduled exception to pending. Asserts has_scheduled_exception. | 211 // Promote a scheduled exception to pending. Asserts has_scheduled_exception. |
| 225 static Object* PromoteScheduledException(); | 212 static Object* PromoteScheduledException(); |
| 226 static void DoThrow(Object* exception, | 213 static void DoThrow(Object* exception, |
| 227 MessageLocation* location, | 214 MessageLocation* location, |
| 228 const char* message); | 215 const char* message); |
| 229 static bool ShouldReportException(bool* is_caught_externally); | 216 static bool ShouldReportException(bool* is_caught_externally); |
| 230 static void ReportUncaughtException(Handle<Object> exception, | 217 static void ReportUncaughtException(Handle<Object> exception, |
| 231 MessageLocation* location, | 218 MessageLocation* location, |
| 232 Handle<String> stack_trace); | 219 Handle<String> stack_trace); |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 | 366 |
| 380 class ExecutionAccess BASE_EMBEDDED { | 367 class ExecutionAccess BASE_EMBEDDED { |
| 381 public: | 368 public: |
| 382 ExecutionAccess(); | 369 ExecutionAccess(); |
| 383 ~ExecutionAccess(); | 370 ~ExecutionAccess(); |
| 384 }; | 371 }; |
| 385 | 372 |
| 386 } } // namespace v8::internal | 373 } } // namespace v8::internal |
| 387 | 374 |
| 388 #endif // V8_TOP_H_ | 375 #endif // V8_TOP_H_ |
| OLD | NEW |