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

Side by Side Diff: src/top.h

Issue 12901: Reporting uncaught errors at the boundary between C++ and JS instead of tryin... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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_;
49 // Use a separate value for scheduled exceptions to preserve the 54 // Use a separate value for scheduled exceptions to preserve the
50 // invariants that hold about pending_exception. We may want to 55 // invariants that hold about pending_exception. We may want to
51 // unify them later. 56 // unify them later.
52 Object* scheduled_exception_; 57 Object* scheduled_exception_;
53 bool external_caught_exception_; 58 bool external_caught_exception_;
54 v8::TryCatch* try_catch_handler_; 59 v8::TryCatch* try_catch_handler_;
55 SaveContext* save_context_; 60 SaveContext* save_context_;
56 v8::TryCatch* catcher_; 61 v8::TryCatch* catcher_;
57 62
58 // Stack. 63 // Stack.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 static void clear_pending_exception() { 118 static void clear_pending_exception() {
114 thread_local_.pending_exception_ = Heap::the_hole_value(); 119 thread_local_.pending_exception_ = Heap::the_hole_value();
115 } 120 }
116 121
117 static Object** pending_exception_address() { 122 static Object** pending_exception_address() {
118 return &thread_local_.pending_exception_; 123 return &thread_local_.pending_exception_;
119 } 124 }
120 static bool has_pending_exception() { 125 static bool has_pending_exception() {
121 return !thread_local_.pending_exception_->IsTheHole(); 126 return !thread_local_.pending_exception_->IsTheHole();
122 } 127 }
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 }
123 static v8::TryCatch* try_catch_handler() { 134 static v8::TryCatch* try_catch_handler() {
124 return thread_local_.try_catch_handler_; 135 return thread_local_.try_catch_handler_;
125 } 136 }
126 // This method is called by the api after operations that may throw 137 // This method is called by the api after operations that may throw
127 // exceptions. If an exception was thrown and not handled by an external 138 // exceptions. If an exception was thrown and not handled by an external
128 // handler the exception is scheduled to be rethrown when we return to running 139 // handler the exception is scheduled to be rethrown when we return to running
129 // JavaScript code. If an exception is scheduled true is returned. 140 // JavaScript code. If an exception is scheduled true is returned.
130 static bool optional_reschedule_exception(bool is_bottom_call); 141 static bool optional_reschedule_exception(bool is_bottom_call);
131 142
132 static bool* external_caught_exception_address() { 143 static bool* external_caught_exception_address() {
133 return &thread_local_.external_caught_exception_; 144 return &thread_local_.external_caught_exception_;
134 } 145 }
135 146
136 static Object* scheduled_exception() { 147 static Object* scheduled_exception() {
137 ASSERT(has_scheduled_exception()); 148 ASSERT(has_scheduled_exception());
138 return thread_local_.scheduled_exception_; 149 return thread_local_.scheduled_exception_;
139 } 150 }
140 static bool has_scheduled_exception() { 151 static bool has_scheduled_exception() {
141 return !thread_local_.scheduled_exception_->IsTheHole(); 152 return !thread_local_.scheduled_exception_->IsTheHole();
142 } 153 }
143 static void clear_scheduled_exception() { 154 static void clear_scheduled_exception() {
144 thread_local_.scheduled_exception_ = Heap::the_hole_value(); 155 thread_local_.scheduled_exception_ = Heap::the_hole_value();
145 } 156 }
146 157
147 static void setup_external_caught() { 158 static void setup_external_caught() {
148 thread_local_.external_caught_exception_ = 159 thread_local_.external_caught_exception_ =
160 (!thread_local_.pending_exception_->IsTheHole()) &&
149 (thread_local_.catcher_ != NULL) && 161 (thread_local_.catcher_ != NULL) &&
150 (Top::thread_local_.try_catch_handler_ == Top::thread_local_.catcher_); 162 (Top::thread_local_.try_catch_handler_ == Top::thread_local_.catcher_);
151 } 163 }
152 164
153 // Tells whether the current context has experienced an out of memory 165 // Tells whether the current context has experienced an out of memory
154 // exception. 166 // exception.
155 static bool is_out_of_memory(); 167 static bool is_out_of_memory();
156 168
157 // JS execution stack (see frames.h). 169 // JS execution stack (see frames.h).
158 static Address c_entry_fp(ThreadLocalTop* thread) { 170 static Address c_entry_fp(ThreadLocalTop* thread) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 static void ReportFailedAccessCheck(JSObject* receiver, v8::AccessType type); 212 static void ReportFailedAccessCheck(JSObject* receiver, v8::AccessType type);
201 213
202 // Exception throwing support. The caller should use the result 214 // Exception throwing support. The caller should use the result
203 // of Throw() as its return value. 215 // of Throw() as its return value.
204 static Failure* Throw(Object* exception, MessageLocation* location = NULL); 216 static Failure* Throw(Object* exception, MessageLocation* location = NULL);
205 // Re-throw an exception. This involves no error reporting since 217 // Re-throw an exception. This involves no error reporting since
206 // error reporting was handled when the exception was thrown 218 // error reporting was handled when the exception was thrown
207 // originally. 219 // originally.
208 static Failure* ReThrow(Object* exception, MessageLocation* location = NULL); 220 static Failure* ReThrow(Object* exception, MessageLocation* location = NULL);
209 static void ScheduleThrow(Object* exception); 221 static void ScheduleThrow(Object* exception);
222 static void ReportPendingMessages();
210 223
211 // Promote a scheduled exception to pending. Asserts has_scheduled_exception. 224 // Promote a scheduled exception to pending. Asserts has_scheduled_exception.
212 static Object* PromoteScheduledException(); 225 static Object* PromoteScheduledException();
213 static void DoThrow(Object* exception, 226 static void DoThrow(Object* exception,
214 MessageLocation* location, 227 MessageLocation* location,
215 const char* message); 228 const char* message);
216 static bool ShouldReportException(bool* is_caught_externally); 229 static bool IsUncaughtException(bool* is_caught_externally);
217 static void ReportUncaughtException(Handle<Object> exception, 230 static void ReportUncaughtException(Handle<Object> exception,
218 MessageLocation* location, 231 MessageLocation* location,
219 Handle<String> stack_trace); 232 Handle<String> stack_trace);
220 233
221 // Attempts to compute the current source location, storing the 234 // Attempts to compute the current source location, storing the
222 // result in the target out parameter. 235 // result in the target out parameter.
223 static void ComputeLocation(MessageLocation* target); 236 static void ComputeLocation(MessageLocation* target);
224 237
225 // Override command line flag. 238 // Override command line flag.
226 static void TraceException(bool flag); 239 static void TraceException(bool flag);
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 379
367 class ExecutionAccess BASE_EMBEDDED { 380 class ExecutionAccess BASE_EMBEDDED {
368 public: 381 public:
369 ExecutionAccess(); 382 ExecutionAccess();
370 ~ExecutionAccess(); 383 ~ExecutionAccess();
371 }; 384 };
372 385
373 } } // namespace v8::internal 386 } } // namespace v8::internal
374 387
375 #endif // V8_TOP_H_ 388 #endif // V8_TOP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698