| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_ISOLATE_H_ | 5 #ifndef V8_ISOLATE_H_ |
| 6 #define V8_ISOLATE_H_ | 6 #define V8_ISOLATE_H_ |
| 7 | 7 |
| 8 #include <queue> | 8 #include <queue> |
| 9 #include "include/v8-debug.h" | 9 #include "include/v8-debug.h" |
| 10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
| (...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 } | 622 } |
| 623 bool has_scheduled_exception() { | 623 bool has_scheduled_exception() { |
| 624 DCHECK(!thread_local_top_.scheduled_exception_->IsException()); | 624 DCHECK(!thread_local_top_.scheduled_exception_->IsException()); |
| 625 return thread_local_top_.scheduled_exception_ != heap_.the_hole_value(); | 625 return thread_local_top_.scheduled_exception_ != heap_.the_hole_value(); |
| 626 } | 626 } |
| 627 void clear_scheduled_exception() { | 627 void clear_scheduled_exception() { |
| 628 DCHECK(!thread_local_top_.scheduled_exception_->IsException()); | 628 DCHECK(!thread_local_top_.scheduled_exception_->IsException()); |
| 629 thread_local_top_.scheduled_exception_ = heap_.the_hole_value(); | 629 thread_local_top_.scheduled_exception_ = heap_.the_hole_value(); |
| 630 } | 630 } |
| 631 | 631 |
| 632 bool IsFinallyOnTop(); | 632 bool IsJavaScriptHandlerOnTop(Object* exception); |
| 633 bool IsExternalHandlerOnTop(Object* exception); |
| 633 | 634 |
| 634 bool is_catchable_by_javascript(Object* exception) { | 635 bool is_catchable_by_javascript(Object* exception) { |
| 635 return exception != heap()->termination_exception(); | 636 return exception != heap()->termination_exception(); |
| 636 } | 637 } |
| 637 | 638 |
| 638 // JS execution stack (see frames.h). | 639 // JS execution stack (see frames.h). |
| 639 static Address c_entry_fp(ThreadLocalTop* thread) { | 640 static Address c_entry_fp(ThreadLocalTop* thread) { |
| 640 return thread->c_entry_fp_; | 641 return thread->c_entry_fp_; |
| 641 } | 642 } |
| 642 static Address handler(ThreadLocalTop* thread) { return thread->handler_; } | 643 static Address handler(ThreadLocalTop* thread) { return thread->handler_; } |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 736 bool MayAccess(Handle<JSObject> receiver); | 737 bool MayAccess(Handle<JSObject> receiver); |
| 737 bool IsInternallyUsedPropertyName(Handle<Object> name); | 738 bool IsInternallyUsedPropertyName(Handle<Object> name); |
| 738 bool IsInternallyUsedPropertyName(Object* name); | 739 bool IsInternallyUsedPropertyName(Object* name); |
| 739 | 740 |
| 740 void SetFailedAccessCheckCallback(v8::FailedAccessCheckCallback callback); | 741 void SetFailedAccessCheckCallback(v8::FailedAccessCheckCallback callback); |
| 741 void ReportFailedAccessCheck(Handle<JSObject> receiver); | 742 void ReportFailedAccessCheck(Handle<JSObject> receiver); |
| 742 | 743 |
| 743 // Exception throwing support. The caller should use the result | 744 // Exception throwing support. The caller should use the result |
| 744 // of Throw() as its return value. | 745 // of Throw() as its return value. |
| 745 Object* Throw(Object* exception, MessageLocation* location = NULL); | 746 Object* Throw(Object* exception, MessageLocation* location = NULL); |
| 747 Object* ThrowIllegalOperation(); |
| 746 | 748 |
| 747 template <typename T> | 749 template <typename T> |
| 748 MUST_USE_RESULT MaybeHandle<T> Throw(Handle<Object> exception, | 750 MUST_USE_RESULT MaybeHandle<T> Throw(Handle<Object> exception, |
| 749 MessageLocation* location = NULL) { | 751 MessageLocation* location = NULL) { |
| 750 Throw(*exception, location); | 752 Throw(*exception, location); |
| 751 return MaybeHandle<T>(); | 753 return MaybeHandle<T>(); |
| 752 } | 754 } |
| 753 | 755 |
| 754 // Re-throw an exception. This involves no error reporting since | 756 // Re-throw an exception. This involves no error reporting since error |
| 755 // error reporting was handled when the exception was thrown | 757 // reporting was handled when the exception was thrown originally. |
| 756 // originally. | |
| 757 Object* ReThrow(Object* exception); | 758 Object* ReThrow(Object* exception); |
| 758 | 759 |
| 759 // Find the correct handler for the current pending exception. This also | 760 // Find the correct handler for the current pending exception. This also |
| 760 // clears and returns the current pending exception. | 761 // clears and returns the current pending exception. |
| 761 Object* FindHandler(); | 762 Object* FindHandler(); |
| 762 | 763 |
| 764 // Tries to predict whether the exception will be caught. Note that this can |
| 765 // only produce an estimate, because it is undecidable whether a finally |
| 766 // clause will consume or re-throw an exception. We conservatively assume any |
| 767 // finally clause will behave as if the exception were consumed. |
| 768 bool PredictWhetherExceptionIsCaught(Object* exception); |
| 769 |
| 763 void ScheduleThrow(Object* exception); | 770 void ScheduleThrow(Object* exception); |
| 764 // Re-set pending message, script and positions reported to the TryCatch | 771 // Re-set pending message, script and positions reported to the TryCatch |
| 765 // back to the TLS for re-use when rethrowing. | 772 // back to the TLS for re-use when rethrowing. |
| 766 void RestorePendingMessageFromTryCatch(v8::TryCatch* handler); | 773 void RestorePendingMessageFromTryCatch(v8::TryCatch* handler); |
| 767 // Un-schedule an exception that was caught by a TryCatch handler. | 774 // Un-schedule an exception that was caught by a TryCatch handler. |
| 768 void CancelScheduledExceptionFromTryCatch(v8::TryCatch* handler); | 775 void CancelScheduledExceptionFromTryCatch(v8::TryCatch* handler); |
| 769 void ReportPendingMessages(); | 776 void ReportPendingMessages(); |
| 770 // Return pending location if any or unfilled structure. | 777 // Return pending location if any or unfilled structure. |
| 771 MessageLocation GetMessageLocation(); | 778 MessageLocation GetMessageLocation(); |
| 772 Object* ThrowIllegalOperation(); | |
| 773 | 779 |
| 774 // Promote a scheduled exception to pending. Asserts has_scheduled_exception. | 780 // Promote a scheduled exception to pending. Asserts has_scheduled_exception. |
| 775 Object* PromoteScheduledException(); | 781 Object* PromoteScheduledException(); |
| 776 // Checks if exception should be reported and finds out if it's | |
| 777 // caught externally. | |
| 778 bool ShouldReportException(bool* can_be_caught_externally, | |
| 779 bool catchable_by_javascript); | |
| 780 | 782 |
| 781 // Attempts to compute the current source location, storing the | 783 // Attempts to compute the current source location, storing the |
| 782 // result in the target out parameter. | 784 // result in the target out parameter. |
| 783 void ComputeLocation(MessageLocation* target); | 785 void ComputeLocation(MessageLocation* target); |
| 784 bool ComputeLocationFromException(MessageLocation* target, | 786 bool ComputeLocationFromException(MessageLocation* target, |
| 785 Handle<Object> exception); | 787 Handle<Object> exception); |
| 786 bool ComputeLocationFromStackTrace(MessageLocation* target, | 788 bool ComputeLocationFromStackTrace(MessageLocation* target, |
| 787 Handle<Object> exception); | 789 Handle<Object> exception); |
| 788 | 790 |
| 789 Handle<JSMessageObject> CreateMessage(Handle<Object> exception, | 791 Handle<JSMessageObject> CreateMessage(Handle<Object> exception, |
| 790 MessageLocation* location); | 792 MessageLocation* location); |
| 791 | 793 |
| 792 // Out of resource exception helpers. | 794 // Out of resource exception helpers. |
| 793 Object* StackOverflow(); | 795 Object* StackOverflow(); |
| 794 Object* TerminateExecution(); | 796 Object* TerminateExecution(); |
| 795 void CancelTerminateExecution(); | 797 void CancelTerminateExecution(); |
| 796 | 798 |
| 797 void RequestInterrupt(InterruptCallback callback, void* data); | 799 void RequestInterrupt(InterruptCallback callback, void* data); |
| 798 void InvokeApiInterruptCallbacks(); | 800 void InvokeApiInterruptCallbacks(); |
| 799 | 801 |
| 800 // Administration | 802 // Administration |
| 801 void Iterate(ObjectVisitor* v); | 803 void Iterate(ObjectVisitor* v); |
| 802 void Iterate(ObjectVisitor* v, ThreadLocalTop* t); | 804 void Iterate(ObjectVisitor* v, ThreadLocalTop* t); |
| 803 char* Iterate(ObjectVisitor* v, char* t); | 805 char* Iterate(ObjectVisitor* v, char* t); |
| 804 void IterateThread(ThreadVisitor* v, char* t); | 806 void IterateThread(ThreadVisitor* v, char* t); |
| 805 | 807 |
| 806 | |
| 807 // Returns the current native context. | 808 // Returns the current native context. |
| 808 Handle<Context> native_context(); | 809 Handle<Context> native_context(); |
| 809 | 810 |
| 810 // Returns the native context of the calling JavaScript code. That | 811 // Returns the native context of the calling JavaScript code. That |
| 811 // is, the native context of the top-most JavaScript frame. | 812 // is, the native context of the top-most JavaScript frame. |
| 812 Handle<Context> GetCallingNativeContext(); | 813 Handle<Context> GetCallingNativeContext(); |
| 813 | 814 |
| 814 void RegisterTryCatchHandler(v8::TryCatch* that); | 815 void RegisterTryCatchHandler(v8::TryCatch* that); |
| 815 void UnregisterTryCatchHandler(v8::TryCatch* that); | 816 void UnregisterTryCatchHandler(v8::TryCatch* that); |
| 816 | 817 |
| (...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1562 } | 1563 } |
| 1563 | 1564 |
| 1564 EmbeddedVector<char, 128> filename_; | 1565 EmbeddedVector<char, 128> filename_; |
| 1565 FILE* file_; | 1566 FILE* file_; |
| 1566 int scope_depth_; | 1567 int scope_depth_; |
| 1567 }; | 1568 }; |
| 1568 | 1569 |
| 1569 } } // namespace v8::internal | 1570 } } // namespace v8::internal |
| 1570 | 1571 |
| 1571 #endif // V8_ISOLATE_H_ | 1572 #endif // V8_ISOLATE_H_ |
| OLD | NEW |