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 #include <stdlib.h> | 5 #include <stdlib.h> |
6 | 6 |
7 #include <fstream> // NOLINT(readability/streams) | 7 #include <fstream> // NOLINT(readability/streams) |
8 #include <sstream> | 8 #include <sstream> |
9 | 9 |
10 #include "src/v8.h" | 10 #include "src/v8.h" |
(...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
902 entry = api_interrupts_queue_.front(); | 902 entry = api_interrupts_queue_.front(); |
903 api_interrupts_queue_.pop(); | 903 api_interrupts_queue_.pop(); |
904 } | 904 } |
905 VMState<EXTERNAL> state(this); | 905 VMState<EXTERNAL> state(this); |
906 HandleScope handle_scope(this); | 906 HandleScope handle_scope(this); |
907 entry.first(reinterpret_cast<v8::Isolate*>(this), entry.second); | 907 entry.first(reinterpret_cast<v8::Isolate*>(this), entry.second); |
908 } | 908 } |
909 } | 909 } |
910 | 910 |
911 | 911 |
912 void ReportBootstrappingException(Handle<Object> exception, | 912 void Isolate::ReportBootstrappingException(Handle<Object> exception, |
913 MessageLocation* location) { | 913 MessageLocation* location) { |
914 base::OS::PrintError("Exception thrown during bootstrapping\n"); | 914 base::OS::PrintError("Exception thrown during bootstrapping\n"); |
915 if (location == NULL || location->script().is_null()) return; | 915 if (location == NULL || location->script().is_null()) { |
| 916 exception->Print(); |
| 917 PrintStack(stdout); |
| 918 return; |
| 919 } |
916 // We are bootstrapping and caught an error where the location is set | 920 // We are bootstrapping and caught an error where the location is set |
917 // and we have a script for the location. | 921 // and we have a script for the location. |
918 // In this case we could have an extension (or an internal error | 922 // In this case we could have an extension (or an internal error |
919 // somewhere) and we print out the line number at which the error occured | 923 // somewhere) and we print out the line number at which the error occured |
920 // to the console for easier debugging. | 924 // to the console for easier debugging. |
921 int line_number = | 925 int line_number = |
922 location->script()->GetLineNumber(location->start_pos()) + 1; | 926 location->script()->GetLineNumber(location->start_pos()) + 1; |
923 if (exception->IsString() && location->script()->name()->IsString()) { | 927 if (exception->IsString() && location->script()->name()->IsString()) { |
924 base::OS::PrintError( | 928 base::OS::PrintError( |
925 "Extension or internal compilation error: %s in %s at line %d.\n", | 929 "Extension or internal compilation error: %s in %s at line %d.\n", |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
974 try_catch_handler()->capture_message_; | 978 try_catch_handler()->capture_message_; |
975 bool rethrowing_message = thread_local_top()->rethrowing_message_; | 979 bool rethrowing_message = thread_local_top()->rethrowing_message_; |
976 | 980 |
977 thread_local_top()->rethrowing_message_ = false; | 981 thread_local_top()->rethrowing_message_ = false; |
978 | 982 |
979 // Notify debugger of exception. | 983 // Notify debugger of exception. |
980 if (is_catchable_by_javascript(exception)) { | 984 if (is_catchable_by_javascript(exception)) { |
981 debug()->OnThrow(exception_handle); | 985 debug()->OnThrow(exception_handle); |
982 } | 986 } |
983 | 987 |
984 // Generate the message if required. | 988 if (bootstrapper()->IsActive()) { |
985 if (requires_message && !rethrowing_message) { | 989 // It's not safe to try to make message objects or collect stack traces |
| 990 // while the bootstrapper is active since the infrastructure may not have |
| 991 // been properly initialized. |
| 992 ReportBootstrappingException(exception_handle, location); |
| 993 } else if (requires_message && !rethrowing_message) { |
986 MessageLocation potential_computed_location; | 994 MessageLocation potential_computed_location; |
987 if (location == NULL) { | 995 if (location == NULL) { |
988 // If no location was specified we use a computed one instead. | 996 // If no location was specified we use a computed one instead. |
989 ComputeLocation(&potential_computed_location); | 997 ComputeLocation(&potential_computed_location); |
990 location = &potential_computed_location; | 998 location = &potential_computed_location; |
991 } | 999 } |
992 | 1000 |
993 if (bootstrapper()->IsActive()) { | 1001 Handle<Object> message_obj = CreateMessage(exception_handle, location); |
994 // It's not safe to try to make message objects or collect stack traces | 1002 thread_local_top()->pending_message_obj_ = *message_obj; |
995 // while the bootstrapper is active since the infrastructure may not have | |
996 // been properly initialized. | |
997 ReportBootstrappingException(exception_handle, location); | |
998 } else { | |
999 Handle<Object> message_obj = CreateMessage(exception_handle, location); | |
1000 thread_local_top()->pending_message_obj_ = *message_obj; | |
1001 | 1003 |
1002 // If the abort-on-uncaught-exception flag is specified, abort on any | 1004 // If the abort-on-uncaught-exception flag is specified, abort on any |
1003 // exception not caught by JavaScript, even when an external handler is | 1005 // exception not caught by JavaScript, even when an external handler is |
1004 // present. This flag is intended for use by JavaScript developers, so | 1006 // present. This flag is intended for use by JavaScript developers, so |
1005 // print a user-friendly stack trace (not an internal one). | 1007 // print a user-friendly stack trace (not an internal one). |
1006 if (FLAG_abort_on_uncaught_exception && | 1008 if (FLAG_abort_on_uncaught_exception && |
1007 PredictExceptionCatcher() != CAUGHT_BY_JAVASCRIPT) { | 1009 PredictExceptionCatcher() != CAUGHT_BY_JAVASCRIPT) { |
1008 FLAG_abort_on_uncaught_exception = false; // Prevent endless recursion. | 1010 FLAG_abort_on_uncaught_exception = false; // Prevent endless recursion. |
1009 PrintF(stderr, "%s\n\nFROM\n", | 1011 PrintF(stderr, "%s\n\nFROM\n", |
1010 MessageHandler::GetLocalizedMessage(this, message_obj).get()); | 1012 MessageHandler::GetLocalizedMessage(this, message_obj).get()); |
1011 PrintCurrentStackTrace(stderr); | 1013 PrintCurrentStackTrace(stderr); |
1012 base::OS::Abort(); | 1014 base::OS::Abort(); |
1013 } | |
1014 } | 1015 } |
1015 } | 1016 } |
1016 | 1017 |
1017 // Set the exception being thrown. | 1018 // Set the exception being thrown. |
1018 set_pending_exception(*exception_handle); | 1019 set_pending_exception(*exception_handle); |
1019 return heap()->exception(); | 1020 return heap()->exception(); |
1020 } | 1021 } |
1021 | 1022 |
1022 | 1023 |
1023 Object* Isolate::ReThrow(Object* exception) { | 1024 Object* Isolate::ReThrow(Object* exception) { |
(...skipping 1736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2760 if (prev_ && prev_->Intercept(flag)) return true; | 2761 if (prev_ && prev_->Intercept(flag)) return true; |
2761 // Then check whether this scope intercepts. | 2762 // Then check whether this scope intercepts. |
2762 if ((flag & intercept_mask_)) { | 2763 if ((flag & intercept_mask_)) { |
2763 intercepted_flags_ |= flag; | 2764 intercepted_flags_ |= flag; |
2764 return true; | 2765 return true; |
2765 } | 2766 } |
2766 return false; | 2767 return false; |
2767 } | 2768 } |
2768 | 2769 |
2769 } } // namespace v8::internal | 2770 } } // namespace v8::internal |
OLD | NEW |