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 953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 ASSERT(!handler->is_try_catch()); | 964 ASSERT(!handler->is_try_catch()); |
965 if (handler->is_try_finally()) return false; | 965 if (handler->is_try_finally()) return false; |
966 | 966 |
967 handler = handler->next(); | 967 handler = handler->next(); |
968 } | 968 } |
969 | 969 |
970 return true; | 970 return true; |
971 } | 971 } |
972 | 972 |
973 | 973 |
974 void Top::PropagatePendingExceptionToExternalTryCatch() { | |
975 ASSERT(has_pending_exception()); | |
976 | |
977 bool external_caught = IsExternallyCaught(); | |
978 thread_local_.external_caught_exception_ = external_caught; | |
979 | |
980 if (!external_caught) return; | |
981 | |
982 if (thread_local_.pending_exception_ == Failure::OutOfMemoryException()) { | |
983 // Do not propagate OOM exception: we should kill VM asap. | |
984 } else if (thread_local_.pending_exception_ == | |
985 Heap::termination_exception()) { | |
986 try_catch_handler()->can_continue_ = false; | |
987 try_catch_handler()->exception_ = Heap::null_value(); | |
988 } else { | |
989 // At this point all non-object (failure) exceptions have | |
990 // been dealt with so this shouldn't fail. | |
991 ASSERT(!pending_exception()->IsFailure()); | |
992 try_catch_handler()->can_continue_ = true; | |
993 try_catch_handler()->exception_ = pending_exception(); | |
994 if (!thread_local_.pending_message_obj_->IsTheHole()) { | |
995 try_catch_handler()->message_ = thread_local_.pending_message_obj_; | |
996 } | |
997 } | |
998 } | |
999 | |
1000 | |
1001 void Top::ReportPendingMessages() { | 974 void Top::ReportPendingMessages() { |
1002 ASSERT(has_pending_exception()); | 975 ASSERT(has_pending_exception()); |
1003 PropagatePendingExceptionToExternalTryCatch(); | |
1004 | |
1005 // If the pending exception is OutOfMemoryException set out_of_memory in | 976 // If the pending exception is OutOfMemoryException set out_of_memory in |
1006 // the global context. Note: We have to mark the global context here | 977 // the global context. Note: We have to mark the global context here |
1007 // since the GenerateThrowOutOfMemory stub cannot make a RuntimeCall to | 978 // since the GenerateThrowOutOfMemory stub cannot make a RuntimeCall to |
1008 // set it. | 979 // set it. |
| 980 bool external_caught = IsExternallyCaught(); |
| 981 thread_local_.external_caught_exception_ = external_caught; |
1009 HandleScope scope; | 982 HandleScope scope; |
1010 if (thread_local_.pending_exception_ == Failure::OutOfMemoryException()) { | 983 if (thread_local_.pending_exception_ == Failure::OutOfMemoryException()) { |
1011 context()->mark_out_of_memory(); | 984 context()->mark_out_of_memory(); |
1012 } else if (thread_local_.pending_exception_ == | 985 } else if (thread_local_.pending_exception_ == |
1013 Heap::termination_exception()) { | 986 Heap::termination_exception()) { |
1014 // Do nothing: if needed, the exception has been already propagated to | 987 if (external_caught) { |
1015 // v8::TryCatch. | 988 try_catch_handler()->can_continue_ = false; |
| 989 try_catch_handler()->exception_ = Heap::null_value(); |
| 990 } |
1016 } else { | 991 } else { |
| 992 // At this point all non-object (failure) exceptions have |
| 993 // been dealt with so this shouldn't fail. |
| 994 Object* pending_exception_object = pending_exception()->ToObjectUnchecked(); |
| 995 Handle<Object> exception(pending_exception_object); |
| 996 thread_local_.external_caught_exception_ = false; |
| 997 if (external_caught) { |
| 998 try_catch_handler()->can_continue_ = true; |
| 999 try_catch_handler()->exception_ = thread_local_.pending_exception_; |
| 1000 if (!thread_local_.pending_message_obj_->IsTheHole()) { |
| 1001 try_catch_handler()->message_ = thread_local_.pending_message_obj_; |
| 1002 } |
| 1003 } |
1017 if (thread_local_.has_pending_message_) { | 1004 if (thread_local_.has_pending_message_) { |
1018 thread_local_.has_pending_message_ = false; | 1005 thread_local_.has_pending_message_ = false; |
1019 if (thread_local_.pending_message_ != NULL) { | 1006 if (thread_local_.pending_message_ != NULL) { |
1020 MessageHandler::ReportMessage(thread_local_.pending_message_); | 1007 MessageHandler::ReportMessage(thread_local_.pending_message_); |
1021 } else if (!thread_local_.pending_message_obj_->IsTheHole()) { | 1008 } else if (!thread_local_.pending_message_obj_->IsTheHole()) { |
1022 HandleScope scope; | |
1023 Handle<Object> message_obj(thread_local_.pending_message_obj_); | 1009 Handle<Object> message_obj(thread_local_.pending_message_obj_); |
1024 if (thread_local_.pending_message_script_ != NULL) { | 1010 if (thread_local_.pending_message_script_ != NULL) { |
1025 Handle<Script> script(thread_local_.pending_message_script_); | 1011 Handle<Script> script(thread_local_.pending_message_script_); |
1026 int start_pos = thread_local_.pending_message_start_pos_; | 1012 int start_pos = thread_local_.pending_message_start_pos_; |
1027 int end_pos = thread_local_.pending_message_end_pos_; | 1013 int end_pos = thread_local_.pending_message_end_pos_; |
1028 MessageLocation location(script, start_pos, end_pos); | 1014 MessageLocation location(script, start_pos, end_pos); |
1029 MessageHandler::ReportMessage(&location, message_obj); | 1015 MessageHandler::ReportMessage(&location, message_obj); |
1030 } else { | 1016 } else { |
1031 MessageHandler::ReportMessage(NULL, message_obj); | 1017 MessageHandler::ReportMessage(NULL, message_obj); |
1032 } | 1018 } |
1033 } | 1019 } |
1034 } | 1020 } |
| 1021 thread_local_.external_caught_exception_ = external_caught; |
| 1022 set_pending_exception(*exception); |
1035 } | 1023 } |
1036 clear_pending_message(); | 1024 clear_pending_message(); |
1037 } | 1025 } |
1038 | 1026 |
1039 | 1027 |
1040 void Top::TraceException(bool flag) { | 1028 void Top::TraceException(bool flag) { |
1041 FLAG_trace_exception = flag; | 1029 FLAG_trace_exception = flag; |
1042 } | 1030 } |
1043 | 1031 |
1044 | 1032 |
1045 bool Top::OptionalRescheduleException(bool is_bottom_call) { | 1033 bool Top::OptionalRescheduleException(bool is_bottom_call) { |
1046 ASSERT(has_pending_exception()); | |
1047 PropagatePendingExceptionToExternalTryCatch(); | |
1048 | |
1049 // Allways reschedule out of memory exceptions. | 1034 // Allways reschedule out of memory exceptions. |
1050 if (!is_out_of_memory()) { | 1035 if (!is_out_of_memory()) { |
1051 bool is_termination_exception = | 1036 bool is_termination_exception = |
1052 pending_exception() == Heap::termination_exception(); | 1037 pending_exception() == Heap::termination_exception(); |
1053 | 1038 |
1054 // Do not reschedule the exception if this is the bottom call. | 1039 // Do not reschedule the exception if this is the bottom call. |
1055 bool clear_exception = is_bottom_call; | 1040 bool clear_exception = is_bottom_call; |
1056 | 1041 |
1057 if (is_termination_exception) { | 1042 if (is_termination_exception) { |
1058 if (is_bottom_call) { | 1043 if (is_bottom_call) { |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1158 #ifdef V8_TARGET_ARCH_ARM | 1143 #ifdef V8_TARGET_ARCH_ARM |
1159 thread_local_.simulator_ = Simulator::current(); | 1144 thread_local_.simulator_ = Simulator::current(); |
1160 #elif V8_TARGET_ARCH_MIPS | 1145 #elif V8_TARGET_ARCH_MIPS |
1161 thread_local_.simulator_ = assembler::mips::Simulator::current(); | 1146 thread_local_.simulator_ = assembler::mips::Simulator::current(); |
1162 #endif | 1147 #endif |
1163 #endif | 1148 #endif |
1164 return from + sizeof(thread_local_); | 1149 return from + sizeof(thread_local_); |
1165 } | 1150 } |
1166 | 1151 |
1167 } } // namespace v8::internal | 1152 } } // namespace v8::internal |
OLD | NEW |