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 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
927 PrintF("%c", character); | 927 PrintF("%c", character); |
928 if (character == '\n' && i < len - 2) { | 928 if (character == '\n' && i < len - 2) { |
929 PrintF("%5d: ", ++line_number); | 929 PrintF("%5d: ", ++line_number); |
930 } | 930 } |
931 } | 931 } |
932 } | 932 } |
933 #endif | 933 #endif |
934 } | 934 } |
935 | 935 |
936 | 936 |
937 namespace { | |
938 | |
939 // Only use by Isolate::Throw for --abort-on-uncaught-exception. | |
940 int fatal_exception_depth = 0; | |
941 | |
942 } // namespace | |
943 | |
944 | |
945 Object* Isolate::Throw(Object* exception, MessageLocation* location) { | 937 Object* Isolate::Throw(Object* exception, MessageLocation* location) { |
946 DCHECK(!has_pending_exception()); | 938 DCHECK(!has_pending_exception()); |
947 | 939 |
948 HandleScope scope(this); | 940 HandleScope scope(this); |
949 Handle<Object> exception_handle(exception, this); | 941 Handle<Object> exception_handle(exception, this); |
950 | 942 |
951 // Determine reporting and whether the exception is caught externally. | 943 // Determine whether a message needs to be created for the given exception |
952 bool catchable_by_javascript = is_catchable_by_javascript(exception); | 944 // depending on the following criteria: |
953 bool can_be_caught_externally = false; | 945 // 1) External v8::TryCatch missing: Always create a message because any |
954 bool should_report_exception = | 946 // JavaScript handler for a finally-block might re-throw to top-level. |
955 ShouldReportException(&can_be_caught_externally, catchable_by_javascript); | 947 // 2) External v8::TryCatch exists: Only create a message if the handler |
956 bool report_exception = catchable_by_javascript && should_report_exception; | 948 // captures messages or is verbose (which reports despite the catch). |
957 bool try_catch_needs_message = | 949 // 3) ReThrow from v8::TryCatch: The message from a previous throw still |
958 can_be_caught_externally && try_catch_handler()->capture_message_; | 950 // exists and we preserve it instead of creating a new message. |
| 951 bool requires_message = try_catch_handler() == nullptr || |
| 952 try_catch_handler()->is_verbose_ || |
| 953 try_catch_handler()->capture_message_; |
959 bool rethrowing_message = thread_local_top()->rethrowing_message_; | 954 bool rethrowing_message = thread_local_top()->rethrowing_message_; |
960 | 955 |
961 thread_local_top()->rethrowing_message_ = false; | 956 thread_local_top()->rethrowing_message_ = false; |
962 | 957 |
963 // Notify debugger of exception. | 958 // Notify debugger of exception. |
964 if (catchable_by_javascript) { | 959 if (is_catchable_by_javascript(exception)) { |
965 debug()->OnThrow(exception_handle, report_exception); | 960 debug()->OnThrow(exception_handle); |
966 } | 961 } |
967 | 962 |
968 // Generate the message if required. | 963 // Generate the message if required. |
969 if (!rethrowing_message && (report_exception || try_catch_needs_message)) { | 964 if (requires_message && !rethrowing_message) { |
970 MessageLocation potential_computed_location; | 965 MessageLocation potential_computed_location; |
971 if (location == NULL) { | 966 if (location == NULL) { |
972 // If no location was specified we use a computed one instead. | 967 // If no location was specified we use a computed one instead. |
973 ComputeLocation(&potential_computed_location); | 968 ComputeLocation(&potential_computed_location); |
974 location = &potential_computed_location; | 969 location = &potential_computed_location; |
975 } | 970 } |
976 | 971 |
977 if (bootstrapper()->IsActive()) { | 972 if (bootstrapper()->IsActive()) { |
978 // It's not safe to try to make message objects or collect stack traces | 973 // It's not safe to try to make message objects or collect stack traces |
979 // while the bootstrapper is active since the infrastructure may not have | 974 // while the bootstrapper is active since the infrastructure may not have |
980 // been properly initialized. | 975 // been properly initialized. |
981 ReportBootstrappingException(exception_handle, location); | 976 ReportBootstrappingException(exception_handle, location); |
982 } else { | 977 } else { |
983 Handle<Object> message_obj = CreateMessage(exception_handle, location); | 978 Handle<Object> message_obj = CreateMessage(exception_handle, location); |
984 | |
985 thread_local_top()->pending_message_obj_ = *message_obj; | 979 thread_local_top()->pending_message_obj_ = *message_obj; |
986 | 980 |
987 // If the abort-on-uncaught-exception flag is specified, abort on any | 981 // If the abort-on-uncaught-exception flag is specified, abort on any |
988 // exception not caught by JavaScript, even when an external handler is | 982 // exception not caught by JavaScript, even when an external handler is |
989 // present. This flag is intended for use by JavaScript developers, so | 983 // present. This flag is intended for use by JavaScript developers, so |
990 // print a user-friendly stack trace (not an internal one). | 984 // print a user-friendly stack trace (not an internal one). |
991 if (fatal_exception_depth == 0 && FLAG_abort_on_uncaught_exception && | 985 if (FLAG_abort_on_uncaught_exception && |
992 (report_exception || can_be_caught_externally)) { | 986 !PredictWhetherExceptionIsCaught(*exception_handle)) { |
993 fatal_exception_depth++; | 987 FLAG_abort_on_uncaught_exception = false; // Prevent endless recursion. |
994 PrintF(stderr, "%s\n\nFROM\n", | 988 PrintF(stderr, "%s\n\nFROM\n", |
995 MessageHandler::GetLocalizedMessage(this, message_obj).get()); | 989 MessageHandler::GetLocalizedMessage(this, message_obj).get()); |
996 PrintCurrentStackTrace(stderr); | 990 PrintCurrentStackTrace(stderr); |
997 base::OS::Abort(); | 991 base::OS::Abort(); |
998 } | 992 } |
999 } | 993 } |
1000 } | 994 } |
1001 | 995 |
1002 // Set the exception being thrown. | 996 // Set the exception being thrown. |
1003 set_pending_exception(*exception_handle); | 997 set_pending_exception(*exception_handle); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1040 bool catchable_by_js = is_catchable_by_javascript(exception); | 1034 bool catchable_by_js = is_catchable_by_javascript(exception); |
1041 | 1035 |
1042 // Compute handler and stack unwinding information by performing a full walk | 1036 // Compute handler and stack unwinding information by performing a full walk |
1043 // over the stack and dispatching according to the frame type. | 1037 // over the stack and dispatching according to the frame type. |
1044 for (StackFrameIterator iter(this); !iter.done(); iter.Advance()) { | 1038 for (StackFrameIterator iter(this); !iter.done(); iter.Advance()) { |
1045 StackFrame* frame = iter.frame(); | 1039 StackFrame* frame = iter.frame(); |
1046 | 1040 |
1047 // For JSEntryStub frames we always have a handler. | 1041 // For JSEntryStub frames we always have a handler. |
1048 if (frame->is_entry() || frame->is_entry_construct()) { | 1042 if (frame->is_entry() || frame->is_entry_construct()) { |
1049 StackHandler* handler = frame->top_handler(); | 1043 StackHandler* handler = frame->top_handler(); |
1050 DCHECK_EQ(StackHandler::JS_ENTRY, handler->kind()); | |
1051 DCHECK_EQ(0, handler->index()); | 1044 DCHECK_EQ(0, handler->index()); |
1052 | 1045 |
1053 // Restore the next handler. | 1046 // Restore the next handler. |
1054 thread_local_top()->handler_ = handler->next()->address(); | 1047 thread_local_top()->handler_ = handler->next()->address(); |
1055 | 1048 |
1056 // Gather information from the handler. | 1049 // Gather information from the handler. |
1057 code = frame->LookupCode(); | 1050 code = frame->LookupCode(); |
1058 handler_sp = handler->address() + StackHandlerConstants::kSize; | 1051 handler_sp = handler->address() + StackHandlerConstants::kSize; |
1059 offset = Smi::cast(code->handler_table()->get(0))->value(); | 1052 offset = Smi::cast(code->handler_table()->get(0))->value(); |
1060 break; | 1053 break; |
1061 } | 1054 } |
1062 | 1055 |
1063 // For JavaScript frames which have a handler, we use the handler. | 1056 // For JavaScript frames which have a handler, we use the handler. |
1064 if (frame->is_java_script() && catchable_by_js && frame->HasHandler()) { | 1057 if (frame->is_java_script() && catchable_by_js && frame->HasHandler()) { |
1065 StackHandler* handler = frame->top_handler(); | 1058 StackHandler* handler = frame->top_handler(); |
1066 DCHECK_NE(StackHandler::JS_ENTRY, handler->kind()); | |
1067 | 1059 |
1068 // Restore the next handler. | 1060 // Restore the next handler. |
1069 thread_local_top()->handler_ = handler->next()->address(); | 1061 thread_local_top()->handler_ = handler->next()->address(); |
1070 | 1062 |
1071 // Gather information from the handler. | 1063 // Gather information from the handler. |
1072 code = frame->LookupCode(); | 1064 code = frame->LookupCode(); |
1073 context = handler->context(); | 1065 context = handler->context(); |
1074 offset = Smi::cast(code->handler_table()->get(handler->index()))->value(); | 1066 offset = Smi::cast(code->handler_table()->get(handler->index()))->value(); |
1075 handler_sp = handler->address() + StackHandlerConstants::kSize; | 1067 handler_sp = handler->address() + StackHandlerConstants::kSize; |
1076 handler_fp = frame->fp(); | 1068 handler_fp = frame->fp(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1109 thread_local_top()->pending_handler_offset_ = offset; | 1101 thread_local_top()->pending_handler_offset_ = offset; |
1110 thread_local_top()->pending_handler_fp_ = handler_fp; | 1102 thread_local_top()->pending_handler_fp_ = handler_fp; |
1111 thread_local_top()->pending_handler_sp_ = handler_sp; | 1103 thread_local_top()->pending_handler_sp_ = handler_sp; |
1112 | 1104 |
1113 // Return and clear pending exception. | 1105 // Return and clear pending exception. |
1114 clear_pending_exception(); | 1106 clear_pending_exception(); |
1115 return exception; | 1107 return exception; |
1116 } | 1108 } |
1117 | 1109 |
1118 | 1110 |
| 1111 // TODO(mstarzinger): We shouldn't need the exception object here. |
| 1112 bool Isolate::PredictWhetherExceptionIsCaught(Object* exception) { |
| 1113 if (IsExternalHandlerOnTop(exception)) return true; |
| 1114 |
| 1115 // Search for a JavaScript handler by performing a full walk over the stack |
| 1116 // and dispatching according to the frame type. |
| 1117 for (StackFrameIterator iter(this); !iter.done(); iter.Advance()) { |
| 1118 StackFrame* frame = iter.frame(); |
| 1119 |
| 1120 // For JavaScript frames which have a handler, we use the handler. |
| 1121 if (frame->is_java_script() && frame->HasHandler()) { |
| 1122 return true; |
| 1123 } |
| 1124 |
| 1125 // For optimized frames we perform a lookup in the handler table. |
| 1126 if (frame->is_optimized()) { |
| 1127 Code* frame_code = frame->LookupCode(); |
| 1128 DCHECK(frame_code->is_optimized_code()); |
| 1129 int pc_offset = static_cast<int>(frame->pc() - frame_code->entry()); |
| 1130 int handler_offset = LookupInHandlerTable(frame_code, pc_offset); |
| 1131 if (handler_offset < 0) continue; |
| 1132 return true; |
| 1133 } |
| 1134 } |
| 1135 |
| 1136 // Handler not found. |
| 1137 return false; |
| 1138 } |
| 1139 |
| 1140 |
1119 Object* Isolate::ThrowIllegalOperation() { | 1141 Object* Isolate::ThrowIllegalOperation() { |
1120 if (FLAG_stack_trace_on_illegal) PrintStack(stdout); | 1142 if (FLAG_stack_trace_on_illegal) PrintStack(stdout); |
1121 return Throw(heap_.illegal_access_string()); | 1143 return Throw(heap()->illegal_access_string()); |
1122 } | 1144 } |
1123 | 1145 |
1124 | 1146 |
1125 void Isolate::ScheduleThrow(Object* exception) { | 1147 void Isolate::ScheduleThrow(Object* exception) { |
1126 // When scheduling a throw we first throw the exception to get the | 1148 // When scheduling a throw we first throw the exception to get the |
1127 // error reporting if it is uncaught before rescheduling it. | 1149 // error reporting if it is uncaught before rescheduling it. |
1128 Throw(exception); | 1150 Throw(exception); |
1129 PropagatePendingExceptionToExternalTryCatch(); | 1151 PropagatePendingExceptionToExternalTryCatch(); |
1130 if (has_pending_exception()) { | 1152 if (has_pending_exception()) { |
1131 thread_local_top()->scheduled_exception_ = pending_exception(); | 1153 thread_local_top()->scheduled_exception_ = pending_exception(); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1262 int pos = code->SourcePosition(pc); | 1284 int pos = code->SourcePosition(pc); |
1263 Handle<Script> casted_script(Script::cast(script)); | 1285 Handle<Script> casted_script(Script::cast(script)); |
1264 *target = MessageLocation(casted_script, pos, pos + 1); | 1286 *target = MessageLocation(casted_script, pos, pos + 1); |
1265 return true; | 1287 return true; |
1266 } | 1288 } |
1267 } | 1289 } |
1268 return false; | 1290 return false; |
1269 } | 1291 } |
1270 | 1292 |
1271 | 1293 |
1272 bool Isolate::ShouldReportException(bool* can_be_caught_externally, | |
1273 bool catchable_by_javascript) { | |
1274 // Find the top-most try-catch handler. | |
1275 StackHandler* handler = | |
1276 StackHandler::FromAddress(Isolate::handler(thread_local_top())); | |
1277 while (handler != NULL && !handler->is_catch()) { | |
1278 handler = handler->next(); | |
1279 } | |
1280 | |
1281 // Get the address of the external handler so we can compare the address to | |
1282 // determine which one is closer to the top of the stack. | |
1283 Address external_handler_address = | |
1284 thread_local_top()->try_catch_handler_address(); | |
1285 | |
1286 // The exception has been externally caught if and only if there is | |
1287 // an external handler which is on top of the top-most try-catch | |
1288 // handler. | |
1289 *can_be_caught_externally = external_handler_address != NULL && | |
1290 (handler == NULL || handler->address() > external_handler_address || | |
1291 !catchable_by_javascript); | |
1292 | |
1293 if (*can_be_caught_externally) { | |
1294 // Only report the exception if the external handler is verbose. | |
1295 return try_catch_handler()->is_verbose_; | |
1296 } else { | |
1297 // Report the exception if it isn't caught by JavaScript code. | |
1298 return handler == NULL; | |
1299 } | |
1300 } | |
1301 | |
1302 | |
1303 // Traverse prototype chain to find out whether the object is derived from | 1294 // Traverse prototype chain to find out whether the object is derived from |
1304 // the Error object. | 1295 // the Error object. |
1305 bool Isolate::IsErrorObject(Handle<Object> obj) { | 1296 bool Isolate::IsErrorObject(Handle<Object> obj) { |
1306 if (!obj->IsJSObject()) return false; | 1297 if (!obj->IsJSObject()) return false; |
1307 | 1298 |
1308 Handle<String> error_key = | 1299 Handle<String> error_key = |
1309 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("$Error")); | 1300 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("$Error")); |
1310 Handle<Object> error_constructor = Object::GetProperty( | 1301 Handle<Object> error_constructor = Object::GetProperty( |
1311 js_builtins_object(), error_key).ToHandleChecked(); | 1302 js_builtins_object(), error_key).ToHandleChecked(); |
1312 | 1303 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1364 exception = | 1355 exception = |
1365 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("exception")); | 1356 factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("exception")); |
1366 } | 1357 } |
1367 } | 1358 } |
1368 return MessageHandler::MakeMessageObject(this, "uncaught_exception", location, | 1359 return MessageHandler::MakeMessageObject(this, "uncaught_exception", location, |
1369 HandleVector<Object>(&exception, 1), | 1360 HandleVector<Object>(&exception, 1), |
1370 stack_trace_object); | 1361 stack_trace_object); |
1371 } | 1362 } |
1372 | 1363 |
1373 | 1364 |
1374 bool Isolate::IsFinallyOnTop() { | 1365 bool Isolate::IsJavaScriptHandlerOnTop(Object* exception) { |
| 1366 DCHECK_NE(heap()->the_hole_value(), exception); |
| 1367 |
| 1368 // For uncatchable exceptions, the JavaScript handler cannot be on top. |
| 1369 if (!is_catchable_by_javascript(exception)) return false; |
| 1370 |
| 1371 // Get the top-most JS_ENTRY handler, cannot be on top if it doesn't exist. |
| 1372 Address entry_handler = Isolate::handler(thread_local_top()); |
| 1373 if (entry_handler == nullptr) return false; |
| 1374 |
1375 // Get the address of the external handler so we can compare the address to | 1375 // Get the address of the external handler so we can compare the address to |
1376 // determine which one is closer to the top of the stack. | 1376 // determine which one is closer to the top of the stack. |
1377 Address external_handler_address = | 1377 Address external_handler = thread_local_top()->try_catch_handler_address(); |
1378 thread_local_top()->try_catch_handler_address(); | 1378 if (external_handler == nullptr) return true; |
1379 DCHECK(external_handler_address != NULL); | |
1380 | 1379 |
1381 // The exception has been externally caught if and only if there is | 1380 // The exception has been externally caught if and only if there is an |
1382 // an external handler which is on top of the top-most try-finally | 1381 // external handler which is on top of the top-most JS_ENTRY handler. |
1383 // handler. | |
1384 // There should be no try-catch blocks as they would prohibit us from | |
1385 // finding external catcher in the first place (see catcher_ check above). | |
1386 // | 1382 // |
1387 // Note, that finally clause would rethrow an exception unless it's | 1383 // Note, that finally clauses would re-throw an exception unless it's aborted |
1388 // aborted by jumps in control flow like return, break, etc. and we'll | 1384 // by jumps in control flow (like return, break, etc.) and we'll have another |
1389 // have another chances to set proper v8::TryCatch. | 1385 // chance to set proper v8::TryCatch later. |
1390 StackHandler* handler = | 1386 return (entry_handler < external_handler); |
1391 StackHandler::FromAddress(Isolate::handler(thread_local_top())); | |
1392 while (handler != NULL && handler->address() < external_handler_address) { | |
1393 DCHECK(!handler->is_catch()); | |
1394 if (handler->is_finally()) return true; | |
1395 | |
1396 handler = handler->next(); | |
1397 } | |
1398 | |
1399 return false; | |
1400 } | 1387 } |
1401 | 1388 |
1402 | 1389 |
| 1390 bool Isolate::IsExternalHandlerOnTop(Object* exception) { |
| 1391 DCHECK_NE(heap()->the_hole_value(), exception); |
| 1392 |
| 1393 // Get the address of the external handler so we can compare the address to |
| 1394 // determine which one is closer to the top of the stack. |
| 1395 Address external_handler = thread_local_top()->try_catch_handler_address(); |
| 1396 if (external_handler == nullptr) return false; |
| 1397 |
| 1398 // For uncatchable exceptions, the external handler is always on top. |
| 1399 if (!is_catchable_by_javascript(exception)) return true; |
| 1400 |
| 1401 // Get the top-most JS_ENTRY handler, cannot be on top if it doesn't exist. |
| 1402 Address entry_handler = Isolate::handler(thread_local_top()); |
| 1403 if (entry_handler == nullptr) return true; |
| 1404 |
| 1405 // The exception has been externally caught if and only if there is an |
| 1406 // external handler which is on top of the top-most JS_ENTRY handler. |
| 1407 // |
| 1408 // Note, that finally clauses would re-throw an exception unless it's aborted |
| 1409 // by jumps in control flow (like return, break, etc.) and we'll have another |
| 1410 // chance to set proper v8::TryCatch later. |
| 1411 return (entry_handler > external_handler); |
| 1412 } |
| 1413 |
| 1414 |
1403 void Isolate::ReportPendingMessages() { | 1415 void Isolate::ReportPendingMessages() { |
1404 Object* exception = pending_exception(); | 1416 Object* exception = pending_exception(); |
1405 | 1417 |
1406 // Try to propagate the exception to an external v8::TryCatch handler. If | 1418 // Try to propagate the exception to an external v8::TryCatch handler. If |
1407 // propagation was unsuccessful, then we will get another chance at reporting | 1419 // propagation was unsuccessful, then we will get another chance at reporting |
1408 // the pending message if the exception is re-thrown. | 1420 // the pending message if the exception is re-thrown. |
1409 bool has_been_propagated = PropagatePendingExceptionToExternalTryCatch(); | 1421 bool has_been_propagated = PropagatePendingExceptionToExternalTryCatch(); |
1410 if (!has_been_propagated) return; | 1422 if (!has_been_propagated) return; |
1411 | 1423 |
1412 // Clear the pending message object early to avoid endless recursion. | 1424 // Clear the pending message object early to avoid endless recursion. |
1413 Object* message_obj = thread_local_top_.pending_message_obj_; | 1425 Object* message_obj = thread_local_top_.pending_message_obj_; |
1414 clear_pending_message(); | 1426 clear_pending_message(); |
1415 | 1427 |
1416 bool can_be_caught_externally = false; | 1428 // For uncatchable exceptions we do nothing. If needed, the exception and the |
1417 bool catchable_by_javascript = is_catchable_by_javascript(exception); | 1429 // message have already been propagated to v8::TryCatch. |
1418 bool should_report_exception = | 1430 if (!is_catchable_by_javascript(exception)) return; |
1419 ShouldReportException(&can_be_caught_externally, catchable_by_javascript); | |
1420 | 1431 |
1421 if (!catchable_by_javascript) { | 1432 // Determine whether the message needs to be reported to all message handlers |
1422 // Do nothing: if needed, the exception has been already propagated to | 1433 // depending on whether and external v8::TryCatch or an internal JavaScript |
1423 // v8::TryCatch. | 1434 // handler is on top. |
| 1435 bool should_report_exception; |
| 1436 if (IsExternalHandlerOnTop(exception)) { |
| 1437 // Only report the exception if the external handler is verbose. |
| 1438 should_report_exception = try_catch_handler()->is_verbose_; |
1424 } else { | 1439 } else { |
1425 if (!message_obj->IsTheHole() && should_report_exception) { | 1440 // Report the exception if it isn't caught by JavaScript code. |
1426 HandleScope scope(this); | 1441 should_report_exception = !IsJavaScriptHandlerOnTop(exception); |
1427 Handle<JSMessageObject> message(JSMessageObject::cast(message_obj)); | 1442 } |
1428 Handle<JSValue> script_wrapper(JSValue::cast(message->script())); | 1443 |
1429 Handle<Script> script(Script::cast(script_wrapper->value())); | 1444 // Actually report the pending message to all message handlers. |
1430 int start_pos = message->start_position(); | 1445 if (!message_obj->IsTheHole() && should_report_exception) { |
1431 int end_pos = message->end_position(); | 1446 HandleScope scope(this); |
1432 MessageLocation location(script, start_pos, end_pos); | 1447 Handle<JSMessageObject> message(JSMessageObject::cast(message_obj)); |
1433 MessageHandler::ReportMessage(this, &location, message); | 1448 Handle<JSValue> script_wrapper(JSValue::cast(message->script())); |
1434 } | 1449 Handle<Script> script(Script::cast(script_wrapper->value())); |
| 1450 int start_pos = message->start_position(); |
| 1451 int end_pos = message->end_position(); |
| 1452 MessageLocation location(script, start_pos, end_pos); |
| 1453 MessageHandler::ReportMessage(this, &location, message); |
1435 } | 1454 } |
1436 } | 1455 } |
1437 | 1456 |
1438 | 1457 |
1439 MessageLocation Isolate::GetMessageLocation() { | 1458 MessageLocation Isolate::GetMessageLocation() { |
1440 DCHECK(has_pending_exception()); | 1459 DCHECK(has_pending_exception()); |
1441 | 1460 |
1442 if (thread_local_top_.pending_exception_ != heap()->termination_exception() && | 1461 if (thread_local_top_.pending_exception_ != heap()->termination_exception() && |
1443 !thread_local_top_.pending_message_obj_->IsTheHole()) { | 1462 !thread_local_top_.pending_message_obj_->IsTheHole()) { |
1444 Handle<JSMessageObject> message_obj( | 1463 Handle<JSMessageObject> message_obj( |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1932 | 1951 |
1933 void Isolate::InitializeThreadLocal() { | 1952 void Isolate::InitializeThreadLocal() { |
1934 thread_local_top_.isolate_ = this; | 1953 thread_local_top_.isolate_ = this; |
1935 thread_local_top_.Initialize(); | 1954 thread_local_top_.Initialize(); |
1936 } | 1955 } |
1937 | 1956 |
1938 | 1957 |
1939 bool Isolate::PropagatePendingExceptionToExternalTryCatch() { | 1958 bool Isolate::PropagatePendingExceptionToExternalTryCatch() { |
1940 Object* exception = pending_exception(); | 1959 Object* exception = pending_exception(); |
1941 | 1960 |
1942 bool can_be_caught_externally = false; | 1961 if (IsJavaScriptHandlerOnTop(exception)) { |
1943 bool catchable_by_javascript = is_catchable_by_javascript(exception); | 1962 thread_local_top_.external_caught_exception_ = false; |
1944 ShouldReportException(&can_be_caught_externally, catchable_by_javascript); | 1963 return false; |
1945 if (!can_be_caught_externally) { | 1964 } |
| 1965 |
| 1966 if (!IsExternalHandlerOnTop(exception)) { |
1946 thread_local_top_.external_caught_exception_ = false; | 1967 thread_local_top_.external_caught_exception_ = false; |
1947 return true; | 1968 return true; |
1948 } | 1969 } |
1949 | 1970 |
1950 if (catchable_by_javascript && IsFinallyOnTop()) { | |
1951 thread_local_top_.external_caught_exception_ = false; | |
1952 return false; | |
1953 } | |
1954 | |
1955 thread_local_top_.external_caught_exception_ = true; | 1971 thread_local_top_.external_caught_exception_ = true; |
1956 if (!catchable_by_javascript) { | 1972 if (!is_catchable_by_javascript(exception)) { |
1957 try_catch_handler()->can_continue_ = false; | 1973 try_catch_handler()->can_continue_ = false; |
1958 try_catch_handler()->has_terminated_ = true; | 1974 try_catch_handler()->has_terminated_ = true; |
1959 try_catch_handler()->exception_ = heap()->null_value(); | 1975 try_catch_handler()->exception_ = heap()->null_value(); |
1960 } else { | 1976 } else { |
1961 v8::TryCatch* handler = try_catch_handler(); | 1977 v8::TryCatch* handler = try_catch_handler(); |
1962 DCHECK(thread_local_top_.pending_message_obj_->IsJSMessageObject() || | 1978 DCHECK(thread_local_top_.pending_message_obj_->IsJSMessageObject() || |
1963 thread_local_top_.pending_message_obj_->IsTheHole()); | 1979 thread_local_top_.pending_message_obj_->IsTheHole()); |
1964 handler->can_continue_ = true; | 1980 handler->can_continue_ = true; |
1965 handler->has_terminated_ = false; | 1981 handler->has_terminated_ = false; |
1966 handler->exception_ = pending_exception(); | 1982 handler->exception_ = pending_exception(); |
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2620 if (prev_ && prev_->Intercept(flag)) return true; | 2636 if (prev_ && prev_->Intercept(flag)) return true; |
2621 // Then check whether this scope intercepts. | 2637 // Then check whether this scope intercepts. |
2622 if ((flag & intercept_mask_)) { | 2638 if ((flag & intercept_mask_)) { |
2623 intercepted_flags_ |= flag; | 2639 intercepted_flags_ |= flag; |
2624 return true; | 2640 return true; |
2625 } | 2641 } |
2626 return false; | 2642 return false; |
2627 } | 2643 } |
2628 | 2644 |
2629 } } // namespace v8::internal | 2645 } } // namespace v8::internal |
OLD | NEW |