OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 3387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3398 * Returns true if JavaScript execution is currently terminating | 3398 * Returns true if JavaScript execution is currently terminating |
3399 * because of a call to TerminateExecution. In that case there are | 3399 * because of a call to TerminateExecution. In that case there are |
3400 * still JavaScript frames on the stack and the termination | 3400 * still JavaScript frames on the stack and the termination |
3401 * exception is still active. | 3401 * exception is still active. |
3402 * | 3402 * |
3403 * \param isolate The isolate in which to check. | 3403 * \param isolate The isolate in which to check. |
3404 */ | 3404 */ |
3405 static bool IsExecutionTerminating(Isolate* isolate = NULL); | 3405 static bool IsExecutionTerminating(Isolate* isolate = NULL); |
3406 | 3406 |
3407 /** | 3407 /** |
| 3408 * Resume execution capability in the given isolate, whose execution |
| 3409 * was previously forcefully terminated using TerminateExecution(). |
| 3410 * If no isolate is provided, the default isolate is used. |
| 3411 * |
| 3412 * When execution is forcefully terminated using TerminateExecution(), |
| 3413 * the isolate can not resume execution until all JavaScript frames |
| 3414 * have propagated the uncatchable exception which is generated. This |
| 3415 * method allows the program embedding the engine to handle the |
| 3416 * termination event and resume execution capability, even if |
| 3417 * JavaScript frames remain on the stack. |
| 3418 * |
| 3419 * This method can be used by any thread even if that thread has not |
| 3420 * acquired the V8 lock with a Locker object. |
| 3421 * |
| 3422 * \param isolate The isolate in which to resume execution capability. |
| 3423 */ |
| 3424 static void ResumeExecution(Isolate* isolate = NULL); |
| 3425 |
| 3426 /** |
3408 * Releases any resources used by v8 and stops any utility threads | 3427 * Releases any resources used by v8 and stops any utility threads |
3409 * that may be running. Note that disposing v8 is permanent, it | 3428 * that may be running. Note that disposing v8 is permanent, it |
3410 * cannot be reinitialized. | 3429 * cannot be reinitialized. |
3411 * | 3430 * |
3412 * It should generally not be necessary to dispose v8 before exiting | 3431 * It should generally not be necessary to dispose v8 before exiting |
3413 * a process, this should happen automatically. It is only necessary | 3432 * a process, this should happen automatically. It is only necessary |
3414 * to use if the process needs the resources taken up by v8. | 3433 * to use if the process needs the resources taken up by v8. |
3415 */ | 3434 */ |
3416 static bool Dispose(); | 3435 static bool Dispose(); |
3417 | 3436 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3494 | 3513 |
3495 /** | 3514 /** |
3496 * Returns true if an exception has been caught by this try/catch block. | 3515 * Returns true if an exception has been caught by this try/catch block. |
3497 */ | 3516 */ |
3498 bool HasCaught() const; | 3517 bool HasCaught() const; |
3499 | 3518 |
3500 /** | 3519 /** |
3501 * For certain types of exceptions, it makes no sense to continue | 3520 * For certain types of exceptions, it makes no sense to continue |
3502 * execution. | 3521 * execution. |
3503 * | 3522 * |
3504 * Currently, the only type of exception that can be caught by a | |
3505 * TryCatch handler and for which it does not make sense to continue | |
3506 * is termination exception. Such exceptions are thrown when the | |
3507 * TerminateExecution methods are called to terminate a long-running | |
3508 * script. | |
3509 * | |
3510 * If CanContinue returns false, the correct action is to perform | 3523 * If CanContinue returns false, the correct action is to perform |
3511 * any C++ cleanup needed and then return. | 3524 * any C++ cleanup needed and then return. If CanContinue returns |
| 3525 * false and HasTerminated returns true, it is possible to call |
| 3526 * ResumeExecution in order to continue calling into the engine. |
3512 */ | 3527 */ |
3513 bool CanContinue() const; | 3528 bool CanContinue() const; |
3514 | 3529 |
3515 /** | 3530 /** |
| 3531 * Returns true if an exception has been caught due to script execution |
| 3532 * being terminated. |
| 3533 * |
| 3534 * There is no JavaScript representation of an execution termination |
| 3535 * exception. Such exceptions are thrown when the TerminateExecution |
| 3536 * methods are called to terminate a long-running script. |
| 3537 * |
| 3538 * If such an exception has been thrown, HasTerminated will return |
| 3539 * true, indicating that it is possible to call ResumeExecution in |
| 3540 * order to continue calling into the engine. |
| 3541 */ |
| 3542 bool HasTerminated() const; |
| 3543 |
| 3544 /** |
3516 * Throws the exception caught by this TryCatch in a way that avoids | 3545 * Throws the exception caught by this TryCatch in a way that avoids |
3517 * it being caught again by this same TryCatch. As with ThrowException | 3546 * it being caught again by this same TryCatch. As with ThrowException |
3518 * it is illegal to execute any JavaScript operations after calling | 3547 * it is illegal to execute any JavaScript operations after calling |
3519 * ReThrow; the caller must return immediately to where the exception | 3548 * ReThrow; the caller must return immediately to where the exception |
3520 * is caught. | 3549 * is caught. |
3521 */ | 3550 */ |
3522 Handle<Value> ReThrow(); | 3551 Handle<Value> ReThrow(); |
3523 | 3552 |
3524 /** | 3553 /** |
3525 * Returns the exception caught by this try/catch block. If no exception has | 3554 * Returns the exception caught by this try/catch block. If no exception has |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3574 | 3603 |
3575 private: | 3604 private: |
3576 v8::internal::Isolate* isolate_; | 3605 v8::internal::Isolate* isolate_; |
3577 void* next_; | 3606 void* next_; |
3578 void* exception_; | 3607 void* exception_; |
3579 void* message_; | 3608 void* message_; |
3580 bool is_verbose_ : 1; | 3609 bool is_verbose_ : 1; |
3581 bool can_continue_ : 1; | 3610 bool can_continue_ : 1; |
3582 bool capture_message_ : 1; | 3611 bool capture_message_ : 1; |
3583 bool rethrow_ : 1; | 3612 bool rethrow_ : 1; |
| 3613 bool has_terminated_ : 1; |
3584 | 3614 |
3585 friend class v8::internal::Isolate; | 3615 friend class v8::internal::Isolate; |
3586 }; | 3616 }; |
3587 | 3617 |
3588 | 3618 |
3589 // --- Context --- | 3619 // --- Context --- |
3590 | 3620 |
3591 | 3621 |
3592 /** | 3622 /** |
3593 * Ignore | 3623 * Ignore |
(...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4654 | 4684 |
4655 | 4685 |
4656 } // namespace v8 | 4686 } // namespace v8 |
4657 | 4687 |
4658 | 4688 |
4659 #undef V8EXPORT | 4689 #undef V8EXPORT |
4660 #undef TYPE_CHECK | 4690 #undef TYPE_CHECK |
4661 | 4691 |
4662 | 4692 |
4663 #endif // V8_H_ | 4693 #endif // V8_H_ |
OLD | NEW |