Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: src/top.cc

Issue 13283: Simplify the logic determining whether to report an exception. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 731 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 location, 742 location,
743 HandleVector<Object>(&exception, 1), 743 HandleVector<Object>(&exception, 1),
744 stack_trace); 744 stack_trace);
745 745
746 // Report the uncaught exception. 746 // Report the uncaught exception.
747 MessageHandler::ReportMessage(location, message); 747 MessageHandler::ReportMessage(location, message);
748 } 748 }
749 749
750 750
751 bool Top::ShouldReportException(bool* is_caught_externally) { 751 bool Top::ShouldReportException(bool* is_caught_externally) {
752 // Find the top-most try-catch handler.
752 StackHandler* handler = 753 StackHandler* handler =
753 StackHandler::FromAddress(Top::handler(Top::GetCurrentThread())); 754 StackHandler::FromAddress(Top::handler(Top::GetCurrentThread()));
754
755 // Determine if we have an external exception handler and get the
756 // address of the external handler so we can compare the address to
757 // determine which one is closer to the top of the stack.
758 bool has_external_handler = (thread_local_.try_catch_handler_ != NULL);
759 v8::TryCatch* try_catch = thread_local_.try_catch_handler_;
760
761 // NOTE: The stack is assumed to grown towards lower addresses. If
762 // the handler is at a higher address than the external address it
763 // means that it is below it on the stack.
764
765 // Find the top-most try-catch handler.
766 while (handler != NULL && !handler->is_try_catch()) { 755 while (handler != NULL && !handler->is_try_catch()) {
767 handler = handler->next(); 756 handler = handler->next();
768 } 757 }
769 758
759 // Get the address of the external handler so we can compare the address to
760 // determine which one is closer to the top of the stack.
761 v8::TryCatch* try_catch = thread_local_.try_catch_handler_;
762
770 // The exception has been externally caught if and only if there is 763 // The exception has been externally caught if and only if there is
771 // an external handler which is on top of the top-most try-catch 764 // an external handler which is on top of the top-most try-catch
772 // handler. 765 // handler.
773 // 766 //
774 // See comments in RegisterTryCatchHandler for details. 767 // See comments in RegisterTryCatchHandler for details.
775 *is_caught_externally = has_external_handler && 768 *is_caught_externally = try_catch != NULL &&
776 (handler == NULL || handler == try_catch->js_handler_); 769 (handler == NULL || handler == try_catch->js_handler_);
777 770
778 // If we have a try-catch handler then the exception is caught in 771 if (*is_caught_externally) {
779 // JavaScript code.
780 bool is_uncaught_by_js = (handler == NULL);
781
782 // If there is no external try-catch handler, we report the
783 // exception if it isn't caught by JavaScript code.
784 if (!has_external_handler) return is_uncaught_by_js;
785
786 if (is_uncaught_by_js || handler == try_catch->js_handler_) {
787 // Only report the exception if the external handler is verbose. 772 // Only report the exception if the external handler is verbose.
788 return thread_local_.try_catch_handler_->is_verbose_; 773 return thread_local_.try_catch_handler_->is_verbose_;
789 } else { 774 } else {
790 // Report the exception if it isn't caught by JavaScript code. 775 // Report the exception if it isn't caught by JavaScript code.
791 return is_uncaught_by_js; 776 return handler == NULL;
792 } 777 }
793 } 778 }
794 779
795 780
796 void Top::DoThrow(Object* exception, 781 void Top::DoThrow(Object* exception,
797 MessageLocation* location, 782 MessageLocation* location,
798 const char* message) { 783 const char* message) {
799 ASSERT(!has_pending_exception()); 784 ASSERT(!has_pending_exception());
800 785
801 HandleScope scope; 786 HandleScope scope;
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 Top::break_access_->Lock(); 957 Top::break_access_->Lock();
973 } 958 }
974 959
975 960
976 ExecutionAccess::~ExecutionAccess() { 961 ExecutionAccess::~ExecutionAccess() {
977 Top::break_access_->Unlock(); 962 Top::break_access_->Unlock();
978 } 963 }
979 964
980 965
981 } } // namespace v8::internal 966 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698