| 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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 } | 278 } |
| 279 | 279 |
| 280 that->js_handler_ = handler; // casted to void* | 280 that->js_handler_ = handler; // casted to void* |
| 281 thread_local_.try_catch_handler_ = that; | 281 thread_local_.try_catch_handler_ = that; |
| 282 } | 282 } |
| 283 | 283 |
| 284 | 284 |
| 285 void Top::UnregisterTryCatchHandler(v8::TryCatch* that) { | 285 void Top::UnregisterTryCatchHandler(v8::TryCatch* that) { |
| 286 ASSERT(thread_local_.try_catch_handler_ == that); | 286 ASSERT(thread_local_.try_catch_handler_ == that); |
| 287 thread_local_.try_catch_handler_ = that->next_; | 287 thread_local_.try_catch_handler_ = that->next_; |
| 288 thread_local_.catcher_ = NULL; |
| 288 } | 289 } |
| 289 | 290 |
| 290 | 291 |
| 291 void Top::MarkCompactPrologue(bool is_compacting) { | 292 void Top::MarkCompactPrologue(bool is_compacting) { |
| 292 MarkCompactPrologue(is_compacting, &thread_local_); | 293 MarkCompactPrologue(is_compacting, &thread_local_); |
| 293 } | 294 } |
| 294 | 295 |
| 295 | 296 |
| 296 void Top::MarkCompactPrologue(bool is_compacting, char* data) { | 297 void Top::MarkCompactPrologue(bool is_compacting, char* data) { |
| 297 MarkCompactPrologue(is_compacting, reinterpret_cast<ThreadLocalTop*>(data)); | 298 MarkCompactPrologue(is_compacting, reinterpret_cast<ThreadLocalTop*>(data)); |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 MessageLocation* location, | 718 MessageLocation* location, |
| 718 const char* message) { | 719 const char* message) { |
| 719 ASSERT(!has_pending_exception()); | 720 ASSERT(!has_pending_exception()); |
| 720 | 721 |
| 721 HandleScope scope; | 722 HandleScope scope; |
| 722 Handle<Object> exception_handle(exception); | 723 Handle<Object> exception_handle(exception); |
| 723 | 724 |
| 724 // Determine reporting and whether the exception is caught externally. | 725 // Determine reporting and whether the exception is caught externally. |
| 725 bool is_caught_externally = false; | 726 bool is_caught_externally = false; |
| 726 bool is_out_of_memory = exception == Failure::OutOfMemoryException(); | 727 bool is_out_of_memory = exception == Failure::OutOfMemoryException(); |
| 727 bool should_return_exception = ShouldReportException(&is_caught_externally); | 728 bool should_return_exception = ShouldReportException(&is_caught_externally); |
| 728 bool report_exception = !is_out_of_memory && should_return_exception; | 729 bool report_exception = !is_out_of_memory && should_return_exception; |
| 729 | 730 |
| 730 | |
| 731 // Notify debugger of exception. | 731 // Notify debugger of exception. |
| 732 Debugger::OnException(exception_handle, report_exception); | 732 Debugger::OnException(exception_handle, report_exception); |
| 733 | 733 |
| 734 // Generate the message. | 734 // Generate the message. |
| 735 Handle<Object> message_obj; | 735 Handle<Object> message_obj; |
| 736 MessageLocation potential_computed_location; | 736 MessageLocation potential_computed_location; |
| 737 bool try_catch_needs_message = | 737 bool try_catch_needs_message = |
| 738 is_caught_externally && | 738 is_caught_externally && |
| 739 thread_local_.try_catch_handler_->capture_message_; | 739 thread_local_.try_catch_handler_->capture_message_; |
| 740 if (report_exception || try_catch_needs_message) { | 740 if (report_exception || try_catch_needs_message) { |
| (...skipping 75 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 |