OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-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 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 clear_pending_message(); | 816 clear_pending_message(); |
817 } | 817 } |
818 | 818 |
819 | 819 |
820 void Top::TraceException(bool flag) { | 820 void Top::TraceException(bool flag) { |
821 FLAG_trace_exception = flag; | 821 FLAG_trace_exception = flag; |
822 } | 822 } |
823 | 823 |
824 | 824 |
825 bool Top::optional_reschedule_exception(bool is_bottom_call) { | 825 bool Top::optional_reschedule_exception(bool is_bottom_call) { |
826 if (!is_out_of_memory() && | 826 // Allways reschedule out of memory exceptions. |
827 (thread_local_.external_caught_exception_ || is_bottom_call)) { | 827 if (!is_out_of_memory()) { |
828 thread_local_.external_caught_exception_ = false; | 828 // Never reschedule the exception if this is the bottom call. |
829 clear_pending_exception(); | 829 bool clear_exception = is_bottom_call; |
830 return false; | 830 |
831 } else { | 831 // If the exception is externally caught, clear it if there are no |
832 thread_local_.scheduled_exception_ = pending_exception(); | 832 // JavaScript frames on the way to the C++ frame that has the |
833 clear_pending_exception(); | 833 // external handler. |
834 return true; | 834 if (thread_local_.external_caught_exception_) { |
| 835 ASSERT(thread_local_.try_catch_handler_ != NULL); |
| 836 Address external_handler_address = |
| 837 reinterpret_cast<Address>(thread_local_.try_catch_handler_); |
| 838 JavaScriptFrameIterator it; |
| 839 if (it.done() || (it.frame()->sp() > external_handler_address)) { |
| 840 clear_exception = true; |
| 841 } |
| 842 } |
| 843 |
| 844 // Clear the exception if needed. |
| 845 if (clear_exception) { |
| 846 thread_local_.external_caught_exception_ = false; |
| 847 clear_pending_exception(); |
| 848 return false; |
| 849 } |
835 } | 850 } |
| 851 |
| 852 // Reschedule the exception. |
| 853 thread_local_.scheduled_exception_ = pending_exception(); |
| 854 clear_pending_exception(); |
| 855 return true; |
836 } | 856 } |
837 | 857 |
838 | 858 |
839 bool Top::is_out_of_memory() { | 859 bool Top::is_out_of_memory() { |
840 if (has_pending_exception()) { | 860 if (has_pending_exception()) { |
841 Object* e = pending_exception(); | 861 Object* e = pending_exception(); |
842 if (e->IsFailure() && Failure::cast(e)->IsOutOfMemoryException()) { | 862 if (e->IsFailure() && Failure::cast(e)->IsOutOfMemoryException()) { |
843 return true; | 863 return true; |
844 } | 864 } |
845 } | 865 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
892 Top::break_access_->Lock(); | 912 Top::break_access_->Lock(); |
893 } | 913 } |
894 | 914 |
895 | 915 |
896 ExecutionAccess::~ExecutionAccess() { | 916 ExecutionAccess::~ExecutionAccess() { |
897 Top::break_access_->Unlock(); | 917 Top::break_access_->Unlock(); |
898 } | 918 } |
899 | 919 |
900 | 920 |
901 } } // namespace v8::internal | 921 } } // namespace v8::internal |
OLD | NEW |