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