| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 external_caught_exception_ = false; | 100 external_caught_exception_ = false; |
| 101 failed_access_check_callback_ = NULL; | 101 failed_access_check_callback_ = NULL; |
| 102 save_context_ = NULL; | 102 save_context_ = NULL; |
| 103 catcher_ = NULL; | 103 catcher_ = NULL; |
| 104 top_lookup_result_ = NULL; | 104 top_lookup_result_ = NULL; |
| 105 | 105 |
| 106 // These members are re-initialized later after deserialization | 106 // These members are re-initialized later after deserialization |
| 107 // is complete. | 107 // is complete. |
| 108 pending_exception_ = NULL; | 108 pending_exception_ = NULL; |
| 109 has_pending_message_ = false; | 109 has_pending_message_ = false; |
| 110 rethrowing_message_ = false; |
| 110 pending_message_obj_ = NULL; | 111 pending_message_obj_ = NULL; |
| 111 pending_message_script_ = NULL; | 112 pending_message_script_ = NULL; |
| 112 scheduled_exception_ = NULL; | 113 scheduled_exception_ = NULL; |
| 113 } | 114 } |
| 114 | 115 |
| 115 | 116 |
| 116 void ThreadLocalTop::Initialize() { | 117 void ThreadLocalTop::Initialize() { |
| 117 InitializeInternal(); | 118 InitializeInternal(); |
| 118 #ifdef USE_SIMULATOR | 119 #ifdef USE_SIMULATOR |
| 119 #ifdef V8_TARGET_ARCH_ARM | 120 #ifdef V8_TARGET_ARCH_ARM |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 Object* scheduled; | 480 Object* scheduled; |
| 480 if (thread->scheduled_exception_->ToObject(&scheduled)) { | 481 if (thread->scheduled_exception_->ToObject(&scheduled)) { |
| 481 v->VisitPointer(&scheduled); | 482 v->VisitPointer(&scheduled); |
| 482 thread->scheduled_exception_ = scheduled; | 483 thread->scheduled_exception_ = scheduled; |
| 483 } | 484 } |
| 484 | 485 |
| 485 for (v8::TryCatch* block = thread->TryCatchHandler(); | 486 for (v8::TryCatch* block = thread->TryCatchHandler(); |
| 486 block != NULL; | 487 block != NULL; |
| 487 block = TRY_CATCH_FROM_ADDRESS(block->next_)) { | 488 block = TRY_CATCH_FROM_ADDRESS(block->next_)) { |
| 488 v->VisitPointer(BitCast<Object**>(&(block->exception_))); | 489 v->VisitPointer(BitCast<Object**>(&(block->exception_))); |
| 489 v->VisitPointer(BitCast<Object**>(&(block->message_))); | 490 v->VisitPointer(BitCast<Object**>(&(block->message_obj_))); |
| 491 v->VisitPointer(BitCast<Object**>(&(block->message_script_))); |
| 490 } | 492 } |
| 491 | 493 |
| 492 // Iterate over pointers on native execution stack. | 494 // Iterate over pointers on native execution stack. |
| 493 for (StackFrameIterator it(this, thread); !it.done(); it.Advance()) { | 495 for (StackFrameIterator it(this, thread); !it.done(); it.Advance()) { |
| 494 it.frame()->Iterate(v); | 496 it.frame()->Iterate(v); |
| 495 } | 497 } |
| 496 | 498 |
| 497 // Iterate pointers in live lookup results. | 499 // Iterate pointers in live lookup results. |
| 498 thread->top_lookup_result_->Iterate(v); | 500 thread->top_lookup_result_->Iterate(v); |
| 499 } | 501 } |
| (...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1155 Throw(exception); | 1157 Throw(exception); |
| 1156 PropagatePendingExceptionToExternalTryCatch(); | 1158 PropagatePendingExceptionToExternalTryCatch(); |
| 1157 if (has_pending_exception()) { | 1159 if (has_pending_exception()) { |
| 1158 thread_local_top()->scheduled_exception_ = pending_exception(); | 1160 thread_local_top()->scheduled_exception_ = pending_exception(); |
| 1159 thread_local_top()->external_caught_exception_ = false; | 1161 thread_local_top()->external_caught_exception_ = false; |
| 1160 clear_pending_exception(); | 1162 clear_pending_exception(); |
| 1161 } | 1163 } |
| 1162 } | 1164 } |
| 1163 | 1165 |
| 1164 | 1166 |
| 1167 void Isolate::RestorePendingMessageFromTryCatch(v8::TryCatch* handler) { |
| 1168 ASSERT(handler == try_catch_handler()); |
| 1169 ASSERT(handler->HasCaught()); |
| 1170 ASSERT(handler->rethrow_); |
| 1171 ASSERT(handler->capture_message_); |
| 1172 Object* message = reinterpret_cast<Object*>(handler->message_obj_); |
| 1173 Object* script = reinterpret_cast<Object*>(handler->message_script_); |
| 1174 ASSERT(message->IsJSMessageObject() || message->IsTheHole()); |
| 1175 ASSERT(script->IsScript() || script->IsTheHole()); |
| 1176 thread_local_top()->pending_message_obj_ = message; |
| 1177 thread_local_top()->pending_message_script_ = script; |
| 1178 thread_local_top()->pending_message_start_pos_ = handler->message_start_pos_; |
| 1179 thread_local_top()->pending_message_end_pos_ = handler->message_end_pos_; |
| 1180 } |
| 1181 |
| 1182 |
| 1165 Failure* Isolate::PromoteScheduledException() { | 1183 Failure* Isolate::PromoteScheduledException() { |
| 1166 MaybeObject* thrown = scheduled_exception(); | 1184 MaybeObject* thrown = scheduled_exception(); |
| 1167 clear_scheduled_exception(); | 1185 clear_scheduled_exception(); |
| 1168 // Re-throw the exception to avoid getting repeated error reporting. | 1186 // Re-throw the exception to avoid getting repeated error reporting. |
| 1169 return ReThrow(thrown); | 1187 return ReThrow(thrown); |
| 1170 } | 1188 } |
| 1171 | 1189 |
| 1172 | 1190 |
| 1173 void Isolate::PrintCurrentStackTrace(FILE* out) { | 1191 void Isolate::PrintCurrentStackTrace(FILE* out) { |
| 1174 StackTraceFrameIterator it(this); | 1192 StackTraceFrameIterator it(this); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1273 HandleScope scope(this); | 1291 HandleScope scope(this); |
| 1274 Handle<Object> exception_handle(exception, this); | 1292 Handle<Object> exception_handle(exception, this); |
| 1275 | 1293 |
| 1276 // Determine reporting and whether the exception is caught externally. | 1294 // Determine reporting and whether the exception is caught externally. |
| 1277 bool catchable_by_javascript = is_catchable_by_javascript(exception); | 1295 bool catchable_by_javascript = is_catchable_by_javascript(exception); |
| 1278 bool can_be_caught_externally = false; | 1296 bool can_be_caught_externally = false; |
| 1279 bool should_report_exception = | 1297 bool should_report_exception = |
| 1280 ShouldReportException(&can_be_caught_externally, catchable_by_javascript); | 1298 ShouldReportException(&can_be_caught_externally, catchable_by_javascript); |
| 1281 bool report_exception = catchable_by_javascript && should_report_exception; | 1299 bool report_exception = catchable_by_javascript && should_report_exception; |
| 1282 bool try_catch_needs_message = | 1300 bool try_catch_needs_message = |
| 1283 can_be_caught_externally && try_catch_handler()->capture_message_; | 1301 can_be_caught_externally && try_catch_handler()->capture_message_ && |
| 1302 !thread_local_top()->rethrowing_message_; |
| 1284 bool bootstrapping = bootstrapper()->IsActive(); | 1303 bool bootstrapping = bootstrapper()->IsActive(); |
| 1285 | 1304 |
| 1305 thread_local_top()->rethrowing_message_ = false; |
| 1306 |
| 1286 #ifdef ENABLE_DEBUGGER_SUPPORT | 1307 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 1287 // Notify debugger of exception. | 1308 // Notify debugger of exception. |
| 1288 if (catchable_by_javascript) { | 1309 if (catchable_by_javascript) { |
| 1289 debugger_->OnException(exception_handle, report_exception); | 1310 debugger_->OnException(exception_handle, report_exception); |
| 1290 } | 1311 } |
| 1291 #endif | 1312 #endif |
| 1292 | 1313 |
| 1293 // Generate the message if required. | 1314 // Generate the message if required. |
| 1294 if (report_exception || try_catch_needs_message) { | 1315 if (report_exception || try_catch_needs_message) { |
| 1295 MessageLocation potential_computed_location; | 1316 MessageLocation potential_computed_location; |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1457 heap()->termination_exception()) { | 1478 heap()->termination_exception()) { |
| 1458 // Do nothing: if needed, the exception has been already propagated to | 1479 // Do nothing: if needed, the exception has been already propagated to |
| 1459 // v8::TryCatch. | 1480 // v8::TryCatch. |
| 1460 } else { | 1481 } else { |
| 1461 if (thread_local_top_.has_pending_message_) { | 1482 if (thread_local_top_.has_pending_message_) { |
| 1462 thread_local_top_.has_pending_message_ = false; | 1483 thread_local_top_.has_pending_message_ = false; |
| 1463 if (!thread_local_top_.pending_message_obj_->IsTheHole()) { | 1484 if (!thread_local_top_.pending_message_obj_->IsTheHole()) { |
| 1464 HandleScope scope(this); | 1485 HandleScope scope(this); |
| 1465 Handle<Object> message_obj(thread_local_top_.pending_message_obj_, | 1486 Handle<Object> message_obj(thread_local_top_.pending_message_obj_, |
| 1466 this); | 1487 this); |
| 1467 if (thread_local_top_.pending_message_script_ != NULL) { | 1488 if (!thread_local_top_.pending_message_script_->IsTheHole()) { |
| 1468 Handle<Script> script(thread_local_top_.pending_message_script_); | 1489 Handle<Script> script( |
| 1490 Script::cast(thread_local_top_.pending_message_script_)); |
| 1469 int start_pos = thread_local_top_.pending_message_start_pos_; | 1491 int start_pos = thread_local_top_.pending_message_start_pos_; |
| 1470 int end_pos = thread_local_top_.pending_message_end_pos_; | 1492 int end_pos = thread_local_top_.pending_message_end_pos_; |
| 1471 MessageLocation location(script, start_pos, end_pos); | 1493 MessageLocation location(script, start_pos, end_pos); |
| 1472 MessageHandler::ReportMessage(this, &location, message_obj); | 1494 MessageHandler::ReportMessage(this, &location, message_obj); |
| 1473 } else { | 1495 } else { |
| 1474 MessageHandler::ReportMessage(this, NULL, message_obj); | 1496 MessageHandler::ReportMessage(this, NULL, message_obj); |
| 1475 } | 1497 } |
| 1476 } | 1498 } |
| 1477 } | 1499 } |
| 1478 } | 1500 } |
| 1479 clear_pending_message(); | 1501 clear_pending_message(); |
| 1480 } | 1502 } |
| 1481 | 1503 |
| 1482 | 1504 |
| 1483 MessageLocation Isolate::GetMessageLocation() { | 1505 MessageLocation Isolate::GetMessageLocation() { |
| 1484 ASSERT(has_pending_exception()); | 1506 ASSERT(has_pending_exception()); |
| 1485 | 1507 |
| 1486 if (!thread_local_top_.pending_exception_->IsOutOfMemory() && | 1508 if (!thread_local_top_.pending_exception_->IsOutOfMemory() && |
| 1487 thread_local_top_.pending_exception_ != heap()->termination_exception() && | 1509 thread_local_top_.pending_exception_ != heap()->termination_exception() && |
| 1488 thread_local_top_.has_pending_message_ && | 1510 thread_local_top_.has_pending_message_ && |
| 1489 !thread_local_top_.pending_message_obj_->IsTheHole() && | 1511 !thread_local_top_.pending_message_obj_->IsTheHole() && |
| 1490 thread_local_top_.pending_message_script_ != NULL) { | 1512 !thread_local_top_.pending_message_obj_->IsTheHole()) { |
| 1491 Handle<Script> script(thread_local_top_.pending_message_script_); | 1513 Handle<Script> script( |
| 1514 Script::cast(thread_local_top_.pending_message_script_)); |
| 1492 int start_pos = thread_local_top_.pending_message_start_pos_; | 1515 int start_pos = thread_local_top_.pending_message_start_pos_; |
| 1493 int end_pos = thread_local_top_.pending_message_end_pos_; | 1516 int end_pos = thread_local_top_.pending_message_end_pos_; |
| 1494 return MessageLocation(script, start_pos, end_pos); | 1517 return MessageLocation(script, start_pos, end_pos); |
| 1495 } | 1518 } |
| 1496 | 1519 |
| 1497 return MessageLocation(); | 1520 return MessageLocation(); |
| 1498 } | 1521 } |
| 1499 | 1522 |
| 1500 | 1523 |
| 1501 void Isolate::TraceException(bool flag) { | 1524 void Isolate::TraceException(bool flag) { |
| (...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2034 if (!external_caught) return; | 2057 if (!external_caught) return; |
| 2035 | 2058 |
| 2036 if (thread_local_top_.pending_exception_->IsOutOfMemory()) { | 2059 if (thread_local_top_.pending_exception_->IsOutOfMemory()) { |
| 2037 // Do not propagate OOM exception: we should kill VM asap. | 2060 // Do not propagate OOM exception: we should kill VM asap. |
| 2038 } else if (thread_local_top_.pending_exception_ == | 2061 } else if (thread_local_top_.pending_exception_ == |
| 2039 heap()->termination_exception()) { | 2062 heap()->termination_exception()) { |
| 2040 try_catch_handler()->can_continue_ = false; | 2063 try_catch_handler()->can_continue_ = false; |
| 2041 try_catch_handler()->has_terminated_ = true; | 2064 try_catch_handler()->has_terminated_ = true; |
| 2042 try_catch_handler()->exception_ = heap()->null_value(); | 2065 try_catch_handler()->exception_ = heap()->null_value(); |
| 2043 } else { | 2066 } else { |
| 2067 v8::TryCatch* handler = try_catch_handler(); |
| 2044 // At this point all non-object (failure) exceptions have | 2068 // At this point all non-object (failure) exceptions have |
| 2045 // been dealt with so this shouldn't fail. | 2069 // been dealt with so this shouldn't fail. |
| 2046 ASSERT(!pending_exception()->IsFailure()); | 2070 ASSERT(!pending_exception()->IsFailure()); |
| 2047 try_catch_handler()->can_continue_ = true; | 2071 ASSERT(thread_local_top_.pending_message_obj_->IsJSMessageObject() || |
| 2048 try_catch_handler()->has_terminated_ = false; | 2072 thread_local_top_.pending_message_obj_->IsTheHole()); |
| 2049 try_catch_handler()->exception_ = pending_exception(); | 2073 ASSERT(thread_local_top_.pending_message_script_->IsScript() || |
| 2050 if (!thread_local_top_.pending_message_obj_->IsTheHole()) { | 2074 thread_local_top_.pending_message_script_->IsTheHole()); |
| 2051 try_catch_handler()->message_ = thread_local_top_.pending_message_obj_; | 2075 handler->can_continue_ = true; |
| 2052 } | 2076 handler->has_terminated_ = false; |
| 2077 handler->exception_ = pending_exception(); |
| 2078 // Propagate to the external try-catch only if we got an actual message. |
| 2079 if (thread_local_top_.pending_message_obj_->IsTheHole()) return; |
| 2080 |
| 2081 handler->message_obj_ = thread_local_top_.pending_message_obj_; |
| 2082 handler->message_script_ = thread_local_top_.pending_message_script_; |
| 2083 handler->message_start_pos_ = thread_local_top_.pending_message_start_pos_; |
| 2084 handler->message_end_pos_ = thread_local_top_.pending_message_end_pos_; |
| 2053 } | 2085 } |
| 2054 } | 2086 } |
| 2055 | 2087 |
| 2056 | 2088 |
| 2057 void Isolate::InitializeLoggingAndCounters() { | 2089 void Isolate::InitializeLoggingAndCounters() { |
| 2058 if (logger_ == NULL) { | 2090 if (logger_ == NULL) { |
| 2059 logger_ = new Logger(this); | 2091 logger_ = new Logger(this); |
| 2060 } | 2092 } |
| 2061 if (counters_ == NULL) { | 2093 if (counters_ == NULL) { |
| 2062 counters_ = new Counters(this); | 2094 counters_ = new Counters(this); |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2443 | 2475 |
| 2444 #ifdef DEBUG | 2476 #ifdef DEBUG |
| 2445 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ | 2477 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ |
| 2446 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); | 2478 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); |
| 2447 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) | 2479 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) |
| 2448 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) | 2480 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) |
| 2449 #undef ISOLATE_FIELD_OFFSET | 2481 #undef ISOLATE_FIELD_OFFSET |
| 2450 #endif | 2482 #endif |
| 2451 | 2483 |
| 2452 } } // namespace v8::internal | 2484 } } // namespace v8::internal |
| OLD | NEW |