OLD | NEW |
1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-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 2205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2216 * | 2216 * |
2217 * \param from_pos specified a point in a buffer to read from, 0 is the | 2217 * \param from_pos specified a point in a buffer to read from, 0 is the |
2218 * beginning of a buffer. It is assumed that caller updates its current | 2218 * beginning of a buffer. It is assumed that caller updates its current |
2219 * position using returned size value from the previous call. | 2219 * position using returned size value from the previous call. |
2220 * \param dest_buf destination buffer for log data. | 2220 * \param dest_buf destination buffer for log data. |
2221 * \param max_size size of the destination buffer. | 2221 * \param max_size size of the destination buffer. |
2222 * \returns actual size of log data copied into buffer. | 2222 * \returns actual size of log data copied into buffer. |
2223 */ | 2223 */ |
2224 static int GetLogLines(int from_pos, char* dest_buf, int max_size); | 2224 static int GetLogLines(int from_pos, char* dest_buf, int max_size); |
2225 | 2225 |
| 2226 /** |
| 2227 * Retrieve the V8 thread id of the calling thread. |
| 2228 * |
| 2229 * The thread id for a thread should only be retrieved after the V8 |
| 2230 * lock has been acquired with a Locker object with that thread. |
| 2231 */ |
| 2232 static int GetCurrentThreadId(); |
| 2233 |
| 2234 /** |
| 2235 * Forcefully terminate execution of a JavaScript thread. This can |
| 2236 * be used to terminate long-running scripts. |
| 2237 * |
| 2238 * TerminateExecution should only be called when then V8 lock has |
| 2239 * been acquired with a Locker object. Therefore, in order to be |
| 2240 * able to terminate long-running threads, preemption must be |
| 2241 * enabled to allow the user of TerminateExecution to acquire the |
| 2242 * lock. |
| 2243 * |
| 2244 * The termination is achieved by throwing an exception that is |
| 2245 * uncatchable by JavaScript exception handlers. Termination |
| 2246 * exceptions act as if they were caught by a C++ TryCatch exception |
| 2247 * handlers. If forceful termination is used, any C++ TryCatch |
| 2248 * exception handler that catches an exception should check if that |
| 2249 * exception is a termination exception and immediately return if |
| 2250 * that is the case. Returning immediately in that case will |
| 2251 * continue the propagation of the termination exception if needed. |
| 2252 * |
| 2253 * The thread id passed to TerminateExecution must have been |
| 2254 * obtained by calling GetCurrentThreadId on the thread in question. |
| 2255 * |
| 2256 * \param thread_id The thread id of the thread to terminate. |
| 2257 */ |
| 2258 static void TerminateExecution(int thread_id); |
| 2259 |
| 2260 /** |
| 2261 * Forcefully terminate the current thread of JavaScript execution. |
| 2262 * |
| 2263 * This method can be used by any thread even if that thread has not |
| 2264 * acquired the V8 lock with a Locker object. |
| 2265 */ |
| 2266 static void TerminateExecution(); |
2226 | 2267 |
2227 /** | 2268 /** |
2228 * Releases any resources used by v8 and stops any utility threads | 2269 * Releases any resources used by v8 and stops any utility threads |
2229 * that may be running. Note that disposing v8 is permanent, it | 2270 * that may be running. Note that disposing v8 is permanent, it |
2230 * cannot be reinitialized. | 2271 * cannot be reinitialized. |
2231 * | 2272 * |
2232 * It should generally not be necessary to dispose v8 before exiting | 2273 * It should generally not be necessary to dispose v8 before exiting |
2233 * a process, this should happen automatically. It is only necessary | 2274 * a process, this should happen automatically. It is only necessary |
2234 * to use if the process needs the resources taken up by v8. | 2275 * to use if the process needs the resources taken up by v8. |
2235 */ | 2276 */ |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2275 * Unregisters and deletes this try/catch block. | 2316 * Unregisters and deletes this try/catch block. |
2276 */ | 2317 */ |
2277 ~TryCatch(); | 2318 ~TryCatch(); |
2278 | 2319 |
2279 /** | 2320 /** |
2280 * Returns true if an exception has been caught by this try/catch block. | 2321 * Returns true if an exception has been caught by this try/catch block. |
2281 */ | 2322 */ |
2282 bool HasCaught() const; | 2323 bool HasCaught() const; |
2283 | 2324 |
2284 /** | 2325 /** |
| 2326 * For certain types of exceptions, it makes no sense to continue |
| 2327 * execution. |
| 2328 * |
| 2329 * Currently, the only type of exception that can be caught by a |
| 2330 * TryCatch handler and for which it does not make sense to continue |
| 2331 * is termination exception. Such exceptions are thrown when the |
| 2332 * TerminateExecution methods are called to terminate a long-running |
| 2333 * script. |
| 2334 * |
| 2335 * If CanContinue returns false, the correct action is to perform |
| 2336 * any C++ cleanup needed and then return. |
| 2337 */ |
| 2338 bool CanContinue() const; |
| 2339 |
| 2340 /** |
2285 * Returns the exception caught by this try/catch block. If no exception has | 2341 * Returns the exception caught by this try/catch block. If no exception has |
2286 * been caught an empty handle is returned. | 2342 * been caught an empty handle is returned. |
2287 * | 2343 * |
2288 * The returned handle is valid until this TryCatch block has been destroyed. | 2344 * The returned handle is valid until this TryCatch block has been destroyed. |
2289 */ | 2345 */ |
2290 Local<Value> Exception() const; | 2346 Local<Value> Exception() const; |
2291 | 2347 |
2292 /** | 2348 /** |
2293 * Returns the .stack property of the thrown object. If no .stack | 2349 * Returns the .stack property of the thrown object. If no .stack |
2294 * property is present an empty handle is returned. | 2350 * property is present an empty handle is returned. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2330 * which holds source information about where the exception | 2386 * which holds source information about where the exception |
2331 * occurred. True by default. | 2387 * occurred. True by default. |
2332 */ | 2388 */ |
2333 void SetCaptureMessage(bool value); | 2389 void SetCaptureMessage(bool value); |
2334 | 2390 |
2335 public: | 2391 public: |
2336 TryCatch* next_; | 2392 TryCatch* next_; |
2337 void* exception_; | 2393 void* exception_; |
2338 void* message_; | 2394 void* message_; |
2339 bool is_verbose_; | 2395 bool is_verbose_; |
| 2396 bool can_continue_; |
2340 bool capture_message_; | 2397 bool capture_message_; |
2341 void* js_handler_; | 2398 void* js_handler_; |
2342 }; | 2399 }; |
2343 | 2400 |
2344 | 2401 |
2345 // --- C o n t e x t --- | 2402 // --- C o n t e x t --- |
2346 | 2403 |
2347 | 2404 |
2348 /** | 2405 /** |
2349 * Ignore | 2406 * Ignore |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2728 | 2785 |
2729 } // namespace v8 | 2786 } // namespace v8 |
2730 | 2787 |
2731 | 2788 |
2732 #undef V8EXPORT | 2789 #undef V8EXPORT |
2733 #undef V8EXPORT_INLINE | 2790 #undef V8EXPORT_INLINE |
2734 #undef TYPE_CHECK | 2791 #undef TYPE_CHECK |
2735 | 2792 |
2736 | 2793 |
2737 #endif // V8_H_ | 2794 #endif // V8_H_ |
OLD | NEW |