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

Side by Side Diff: src/top.h

Issue 174056: Add support for forceful termination of JavaScript execution. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/objects-inl.h ('k') | src/top.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 39
40 // Top has static variables used for JavaScript execution. 40 // Top has static variables used for JavaScript execution.
41 41
42 class SaveContext; // Forward declaration. 42 class SaveContext; // Forward declaration.
43 43
44 class ThreadLocalTop BASE_EMBEDDED { 44 class ThreadLocalTop BASE_EMBEDDED {
45 public: 45 public:
46 // The context where the current execution method is created and for variable 46 // The context where the current execution method is created and for variable
47 // lookups. 47 // lookups.
48 Context* context_; 48 Context* context_;
49 int thread_id_;
49 Object* pending_exception_; 50 Object* pending_exception_;
50 bool has_pending_message_; 51 bool has_pending_message_;
51 const char* pending_message_; 52 const char* pending_message_;
52 Object* pending_message_obj_; 53 Object* pending_message_obj_;
53 Script* pending_message_script_; 54 Script* pending_message_script_;
54 int pending_message_start_pos_; 55 int pending_message_start_pos_;
55 int pending_message_end_pos_; 56 int pending_message_end_pos_;
56 // Use a separate value for scheduled exceptions to preserve the 57 // Use a separate value for scheduled exceptions to preserve the
57 // invariants that hold about pending_exception. We may want to 58 // invariants that hold about pending_exception. We may want to
58 // unify them later. 59 // unify them later.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 static void set_context(Context* context) { 112 static void set_context(Context* context) {
112 thread_local_.context_ = context; 113 thread_local_.context_ = context;
113 } 114 }
114 static Context** context_address() { return &thread_local_.context_; } 115 static Context** context_address() { return &thread_local_.context_; }
115 116
116 static SaveContext* save_context() {return thread_local_.save_context_; } 117 static SaveContext* save_context() {return thread_local_.save_context_; }
117 static void set_save_context(SaveContext* save) { 118 static void set_save_context(SaveContext* save) {
118 thread_local_.save_context_ = save; 119 thread_local_.save_context_ = save;
119 } 120 }
120 121
122 // Access to current thread id.
123 static int thread_id() { return thread_local_.thread_id_; }
124 static void set_thread_id(int id) { thread_local_.thread_id_ = id; }
125
121 // Interface to pending exception. 126 // Interface to pending exception.
122 static Object* pending_exception() { 127 static Object* pending_exception() {
123 ASSERT(has_pending_exception()); 128 ASSERT(has_pending_exception());
124 return thread_local_.pending_exception_; 129 return thread_local_.pending_exception_;
125 } 130 }
126 static bool external_caught_exception() { 131 static bool external_caught_exception() {
127 return thread_local_.external_caught_exception_; 132 return thread_local_.external_caught_exception_;
128 } 133 }
129 static void set_pending_exception(Object* exception) { 134 static void set_pending_exception(Object* exception) {
130 thread_local_.pending_exception_ = exception; 135 thread_local_.pending_exception_ = exception;
(...skipping 14 matching lines...) Expand all
145 thread_local_.pending_message_obj_ = Heap::the_hole_value(); 150 thread_local_.pending_message_obj_ = Heap::the_hole_value();
146 thread_local_.pending_message_script_ = NULL; 151 thread_local_.pending_message_script_ = NULL;
147 } 152 }
148 static v8::TryCatch* try_catch_handler() { 153 static v8::TryCatch* try_catch_handler() {
149 return thread_local_.try_catch_handler_; 154 return thread_local_.try_catch_handler_;
150 } 155 }
151 // This method is called by the api after operations that may throw 156 // This method is called by the api after operations that may throw
152 // exceptions. If an exception was thrown and not handled by an external 157 // exceptions. If an exception was thrown and not handled by an external
153 // handler the exception is scheduled to be rethrown when we return to running 158 // handler the exception is scheduled to be rethrown when we return to running
154 // JavaScript code. If an exception is scheduled true is returned. 159 // JavaScript code. If an exception is scheduled true is returned.
155 static bool optional_reschedule_exception(bool is_bottom_call); 160 static bool OptionalRescheduleException(bool is_bottom_call,
161 bool force_clear_catchable);
156 162
157 static bool* external_caught_exception_address() { 163 static bool* external_caught_exception_address() {
158 return &thread_local_.external_caught_exception_; 164 return &thread_local_.external_caught_exception_;
159 } 165 }
160 166
161 static Object* scheduled_exception() { 167 static Object* scheduled_exception() {
162 ASSERT(has_scheduled_exception()); 168 ASSERT(has_scheduled_exception());
163 return thread_local_.scheduled_exception_; 169 return thread_local_.scheduled_exception_;
164 } 170 }
165 static bool has_scheduled_exception() { 171 static bool has_scheduled_exception() {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 static Failure* ReThrow(Object* exception, MessageLocation* location = NULL); 245 static Failure* ReThrow(Object* exception, MessageLocation* location = NULL);
240 static void ScheduleThrow(Object* exception); 246 static void ScheduleThrow(Object* exception);
241 static void ReportPendingMessages(); 247 static void ReportPendingMessages();
242 static Failure* ThrowIllegalOperation(); 248 static Failure* ThrowIllegalOperation();
243 249
244 // Promote a scheduled exception to pending. Asserts has_scheduled_exception. 250 // Promote a scheduled exception to pending. Asserts has_scheduled_exception.
245 static Object* PromoteScheduledException(); 251 static Object* PromoteScheduledException();
246 static void DoThrow(Object* exception, 252 static void DoThrow(Object* exception,
247 MessageLocation* location, 253 MessageLocation* location,
248 const char* message); 254 const char* message);
249 static bool ShouldReportException(bool* is_caught_externally); 255 static bool ShouldReturnException(bool* is_caught_externally,
256 bool catchable_by_javascript);
250 static void ReportUncaughtException(Handle<Object> exception, 257 static void ReportUncaughtException(Handle<Object> exception,
251 MessageLocation* location, 258 MessageLocation* location,
252 Handle<String> stack_trace); 259 Handle<String> stack_trace);
253 260
254 // Attempts to compute the current source location, storing the 261 // Attempts to compute the current source location, storing the
255 // result in the target out parameter. 262 // result in the target out parameter.
256 static void ComputeLocation(MessageLocation* target); 263 static void ComputeLocation(MessageLocation* target);
257 264
258 // Override command line flag. 265 // Override command line flag.
259 static void TraceException(bool flag); 266 static void TraceException(bool flag);
260 267
261 // Out of resource exception helpers. 268 // Out of resource exception helpers.
262 static Failure* StackOverflow(); 269 static Failure* StackOverflow();
270 static Failure* TerminateExecution();
263 271
264 // Administration 272 // Administration
265 static void Initialize(); 273 static void Initialize();
266 static void TearDown(); 274 static void TearDown();
267 static void Iterate(ObjectVisitor* v); 275 static void Iterate(ObjectVisitor* v);
268 static void Iterate(ObjectVisitor* v, ThreadLocalTop* t); 276 static void Iterate(ObjectVisitor* v, ThreadLocalTop* t);
269 static char* Iterate(ObjectVisitor* v, char* t); 277 static char* Iterate(ObjectVisitor* v, char* t);
270 278
271 // Returns the global object of the current context. It could be 279 // Returns the global object of the current context. It could be
272 // a builtin object, or a js global object. 280 // a builtin object, or a js global object.
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 405
398 class ExecutionAccess BASE_EMBEDDED { 406 class ExecutionAccess BASE_EMBEDDED {
399 public: 407 public:
400 ExecutionAccess(); 408 ExecutionAccess();
401 ~ExecutionAccess(); 409 ~ExecutionAccess();
402 }; 410 };
403 411
404 } } // namespace v8::internal 412 } } // namespace v8::internal
405 413
406 #endif // V8_TOP_H_ 414 #endif // V8_TOP_H_
OLDNEW
« no previous file with comments | « src/objects-inl.h ('k') | src/top.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698