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