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 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 } | 628 } |
629 bool has_scheduled_exception() { | 629 bool has_scheduled_exception() { |
630 DCHECK(!thread_local_top_.scheduled_exception_->IsException()); | 630 DCHECK(!thread_local_top_.scheduled_exception_->IsException()); |
631 return thread_local_top_.scheduled_exception_ != heap_.the_hole_value(); | 631 return thread_local_top_.scheduled_exception_ != heap_.the_hole_value(); |
632 } | 632 } |
633 void clear_scheduled_exception() { | 633 void clear_scheduled_exception() { |
634 DCHECK(!thread_local_top_.scheduled_exception_->IsException()); | 634 DCHECK(!thread_local_top_.scheduled_exception_->IsException()); |
635 thread_local_top_.scheduled_exception_ = heap_.the_hole_value(); | 635 thread_local_top_.scheduled_exception_ = heap_.the_hole_value(); |
636 } | 636 } |
637 | 637 |
638 bool IsFinallyOnTop(); | 638 bool IsJavaScriptHandlerOnTop(Object* exception); |
| 639 bool IsExternalHandlerOnTop(Object* exception); |
639 | 640 |
640 bool is_catchable_by_javascript(Object* exception) { | 641 bool is_catchable_by_javascript(Object* exception) { |
641 return exception != heap()->termination_exception(); | 642 return exception != heap()->termination_exception(); |
642 } | 643 } |
643 | 644 |
644 // JS execution stack (see frames.h). | 645 // JS execution stack (see frames.h). |
645 static Address c_entry_fp(ThreadLocalTop* thread) { | 646 static Address c_entry_fp(ThreadLocalTop* thread) { |
646 return thread->c_entry_fp_; | 647 return thread->c_entry_fp_; |
647 } | 648 } |
648 static Address handler(ThreadLocalTop* thread) { return thread->handler_; } | 649 static Address handler(ThreadLocalTop* thread) { return thread->handler_; } |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
745 bool MayAccess(Handle<JSObject> receiver); | 746 bool MayAccess(Handle<JSObject> receiver); |
746 bool IsInternallyUsedPropertyName(Handle<Object> name); | 747 bool IsInternallyUsedPropertyName(Handle<Object> name); |
747 bool IsInternallyUsedPropertyName(Object* name); | 748 bool IsInternallyUsedPropertyName(Object* name); |
748 | 749 |
749 void SetFailedAccessCheckCallback(v8::FailedAccessCheckCallback callback); | 750 void SetFailedAccessCheckCallback(v8::FailedAccessCheckCallback callback); |
750 void ReportFailedAccessCheck(Handle<JSObject> receiver); | 751 void ReportFailedAccessCheck(Handle<JSObject> receiver); |
751 | 752 |
752 // Exception throwing support. The caller should use the result | 753 // Exception throwing support. The caller should use the result |
753 // of Throw() as its return value. | 754 // of Throw() as its return value. |
754 Object* Throw(Object* exception, MessageLocation* location = NULL); | 755 Object* Throw(Object* exception, MessageLocation* location = NULL); |
| 756 Object* ThrowIllegalOperation(); |
755 | 757 |
756 template <typename T> | 758 template <typename T> |
757 MUST_USE_RESULT MaybeHandle<T> Throw(Handle<Object> exception, | 759 MUST_USE_RESULT MaybeHandle<T> Throw(Handle<Object> exception, |
758 MessageLocation* location = NULL) { | 760 MessageLocation* location = NULL) { |
759 Throw(*exception, location); | 761 Throw(*exception, location); |
760 return MaybeHandle<T>(); | 762 return MaybeHandle<T>(); |
761 } | 763 } |
762 | 764 |
763 // Re-throw an exception. This involves no error reporting since | 765 // Re-throw an exception. This involves no error reporting since error |
764 // error reporting was handled when the exception was thrown | 766 // reporting was handled when the exception was thrown originally. |
765 // originally. | |
766 Object* ReThrow(Object* exception); | 767 Object* ReThrow(Object* exception); |
767 | 768 |
768 // Find the correct handler for the current pending exception. This also | 769 // Find the correct handler for the current pending exception. This also |
769 // clears and returns the current pending exception. | 770 // clears and returns the current pending exception. |
770 Object* FindHandler(); | 771 Object* FindHandler(); |
771 | 772 |
| 773 // Tries to predict whether the exception will be caught. Note that this can |
| 774 // only produce an estimate, because it is undecidable whether a finally |
| 775 // clause will consume or re-throw an exception. We conservatively assume any |
| 776 // finally clause will behave as if the exception were consumed. |
| 777 bool PredictWhetherExceptionIsCaught(Object* exception); |
| 778 |
772 void ScheduleThrow(Object* exception); | 779 void ScheduleThrow(Object* exception); |
773 // Re-set pending message, script and positions reported to the TryCatch | 780 // Re-set pending message, script and positions reported to the TryCatch |
774 // back to the TLS for re-use when rethrowing. | 781 // back to the TLS for re-use when rethrowing. |
775 void RestorePendingMessageFromTryCatch(v8::TryCatch* handler); | 782 void RestorePendingMessageFromTryCatch(v8::TryCatch* handler); |
776 // Un-schedule an exception that was caught by a TryCatch handler. | 783 // Un-schedule an exception that was caught by a TryCatch handler. |
777 void CancelScheduledExceptionFromTryCatch(v8::TryCatch* handler); | 784 void CancelScheduledExceptionFromTryCatch(v8::TryCatch* handler); |
778 void ReportPendingMessages(); | 785 void ReportPendingMessages(); |
779 // Return pending location if any or unfilled structure. | 786 // Return pending location if any or unfilled structure. |
780 MessageLocation GetMessageLocation(); | 787 MessageLocation GetMessageLocation(); |
781 Object* ThrowIllegalOperation(); | |
782 | 788 |
783 // Promote a scheduled exception to pending. Asserts has_scheduled_exception. | 789 // Promote a scheduled exception to pending. Asserts has_scheduled_exception. |
784 Object* PromoteScheduledException(); | 790 Object* PromoteScheduledException(); |
785 // Checks if exception should be reported and finds out if it's | |
786 // caught externally. | |
787 bool ShouldReportException(bool* can_be_caught_externally, | |
788 bool catchable_by_javascript); | |
789 | 791 |
790 // Attempts to compute the current source location, storing the | 792 // Attempts to compute the current source location, storing the |
791 // result in the target out parameter. | 793 // result in the target out parameter. |
792 void ComputeLocation(MessageLocation* target); | 794 void ComputeLocation(MessageLocation* target); |
793 bool ComputeLocationFromException(MessageLocation* target, | 795 bool ComputeLocationFromException(MessageLocation* target, |
794 Handle<Object> exception); | 796 Handle<Object> exception); |
795 bool ComputeLocationFromStackTrace(MessageLocation* target, | 797 bool ComputeLocationFromStackTrace(MessageLocation* target, |
796 Handle<Object> exception); | 798 Handle<Object> exception); |
797 | 799 |
798 Handle<JSMessageObject> CreateMessage(Handle<Object> exception, | 800 Handle<JSMessageObject> CreateMessage(Handle<Object> exception, |
799 MessageLocation* location); | 801 MessageLocation* location); |
800 | 802 |
801 // Out of resource exception helpers. | 803 // Out of resource exception helpers. |
802 Object* StackOverflow(); | 804 Object* StackOverflow(); |
803 Object* TerminateExecution(); | 805 Object* TerminateExecution(); |
804 void CancelTerminateExecution(); | 806 void CancelTerminateExecution(); |
805 | 807 |
806 void RequestInterrupt(InterruptCallback callback, void* data); | 808 void RequestInterrupt(InterruptCallback callback, void* data); |
807 void InvokeApiInterruptCallbacks(); | 809 void InvokeApiInterruptCallbacks(); |
808 | 810 |
809 // Administration | 811 // Administration |
810 void Iterate(ObjectVisitor* v); | 812 void Iterate(ObjectVisitor* v); |
811 void Iterate(ObjectVisitor* v, ThreadLocalTop* t); | 813 void Iterate(ObjectVisitor* v, ThreadLocalTop* t); |
812 char* Iterate(ObjectVisitor* v, char* t); | 814 char* Iterate(ObjectVisitor* v, char* t); |
813 void IterateThread(ThreadVisitor* v, char* t); | 815 void IterateThread(ThreadVisitor* v, char* t); |
814 | 816 |
815 | |
816 // Returns the current native context. | 817 // Returns the current native context. |
817 Handle<Context> native_context(); | 818 Handle<Context> native_context(); |
818 | 819 |
819 // Returns the native context of the calling JavaScript code. That | 820 // Returns the native context of the calling JavaScript code. That |
820 // is, the native context of the top-most JavaScript frame. | 821 // is, the native context of the top-most JavaScript frame. |
821 Handle<Context> GetCallingNativeContext(); | 822 Handle<Context> GetCallingNativeContext(); |
822 | 823 |
823 void RegisterTryCatchHandler(v8::TryCatch* that); | 824 void RegisterTryCatchHandler(v8::TryCatch* that); |
824 void UnregisterTryCatchHandler(v8::TryCatch* that); | 825 void UnregisterTryCatchHandler(v8::TryCatch* that); |
825 | 826 |
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1571 } | 1572 } |
1572 | 1573 |
1573 EmbeddedVector<char, 128> filename_; | 1574 EmbeddedVector<char, 128> filename_; |
1574 FILE* file_; | 1575 FILE* file_; |
1575 int scope_depth_; | 1576 int scope_depth_; |
1576 }; | 1577 }; |
1577 | 1578 |
1578 } } // namespace v8::internal | 1579 } } // namespace v8::internal |
1579 | 1580 |
1580 #endif // V8_ISOLATE_H_ | 1581 #endif // V8_ISOLATE_H_ |
OLD | NEW |