Chromium Code Reviews| 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 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1191 for (Object* prototype = *obj; !prototype->IsNull(); | 1191 for (Object* prototype = *obj; !prototype->IsNull(); |
| 1192 prototype = prototype->GetPrototype(this)) { | 1192 prototype = prototype->GetPrototype(this)) { |
| 1193 if (!prototype->IsJSObject()) return false; | 1193 if (!prototype->IsJSObject()) return false; |
| 1194 if (JSObject::cast(prototype)->map()->constructor() == error_constructor) { | 1194 if (JSObject::cast(prototype)->map()->constructor() == error_constructor) { |
| 1195 return true; | 1195 return true; |
| 1196 } | 1196 } |
| 1197 } | 1197 } |
| 1198 return false; | 1198 return false; |
| 1199 } | 1199 } |
| 1200 | 1200 |
| 1201 static int fatal_exception_depth = 0; | |
| 1201 | 1202 |
| 1202 void Isolate::DoThrow(Object* exception, MessageLocation* location) { | 1203 void Isolate::DoThrow(Object* exception, MessageLocation* location) { |
| 1203 ASSERT(!has_pending_exception()); | 1204 ASSERT(!has_pending_exception()); |
| 1204 | 1205 |
| 1205 HandleScope scope(this); | 1206 HandleScope scope(this); |
| 1206 Handle<Object> exception_handle(exception, this); | 1207 Handle<Object> exception_handle(exception, this); |
| 1207 | 1208 |
| 1208 // Determine reporting and whether the exception is caught externally. | 1209 // Determine reporting and whether the exception is caught externally. |
| 1209 bool catchable_by_javascript = is_catchable_by_javascript(exception); | 1210 bool catchable_by_javascript = is_catchable_by_javascript(exception); |
| 1210 bool can_be_caught_externally = false; | 1211 bool can_be_caught_externally = false; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1274 location, | 1275 location, |
| 1275 HandleVector<Object>(&exception_arg, 1), | 1276 HandleVector<Object>(&exception_arg, 1), |
| 1276 stack_trace, | 1277 stack_trace, |
| 1277 stack_trace_object); | 1278 stack_trace_object); |
| 1278 thread_local_top()->pending_message_obj_ = *message_obj; | 1279 thread_local_top()->pending_message_obj_ = *message_obj; |
| 1279 if (location != NULL) { | 1280 if (location != NULL) { |
| 1280 thread_local_top()->pending_message_script_ = *location->script(); | 1281 thread_local_top()->pending_message_script_ = *location->script(); |
| 1281 thread_local_top()->pending_message_start_pos_ = location->start_pos(); | 1282 thread_local_top()->pending_message_start_pos_ = location->start_pos(); |
| 1282 thread_local_top()->pending_message_end_pos_ = location->end_pos(); | 1283 thread_local_top()->pending_message_end_pos_ = location->end_pos(); |
| 1283 } | 1284 } |
| 1285 | |
| 1286 // If the abort-on-uncaught-exception flag is specified, abort on any | |
| 1287 // exception not caught by JavaScript, even when an external handler is | |
| 1288 // present. This flag is intended for use by JavaScript developers, so | |
| 1289 // print a user-friendly stack trace (not an internal one). | |
| 1290 if (fatal_exception_depth == 0 && | |
| 1291 FLAG_abort_on_uncaught_exception && | |
| 1292 (report_exception || can_be_caught_externally)) { | |
| 1293 fatal_exception_depth++; | |
| 1294 fprintf(stderr, "UNCAUGHT EXCEPTION: "); | |
| 1295 exception->ShortPrint(stderr); | |
| 1296 | |
| 1297 if (IsErrorObject(exception_handle)) { | |
| 1298 Handle<String> key = factory()->InternalizeOneByteString( | |
| 1299 STATIC_ASCII_VECTOR("message")); | |
| 1300 MaybeObject *maybeMessage = | |
| 1301 JSObject::cast(*exception_handle)->GetProperty(*key); | |
| 1302 Object *messageObject; | |
| 1303 if (maybeMessage->ToObject(&messageObject)) { | |
| 1304 String *message = String::cast(messageObject); | |
| 1305 fprintf(stderr, "\nEXCEPTION MESSAGE: "); | |
| 1306 message->PrintOn(stderr); | |
| 1307 } | |
| 1308 } | |
|
Yang
2013/04/02 10:42:30
I was actually suggesting to replace the entire ab
| |
| 1309 | |
| 1310 fprintf(stderr, "\nFROM:\n"); | |
| 1311 PrintCurrentStackTrace(stderr); | |
| 1312 OS::Abort(); | |
| 1313 } | |
| 1314 | |
| 1284 } else if (location != NULL && !location->script().is_null()) { | 1315 } else if (location != NULL && !location->script().is_null()) { |
| 1285 // We are bootstrapping and caught an error where the location is set | 1316 // We are bootstrapping and caught an error where the location is set |
| 1286 // and we have a script for the location. | 1317 // and we have a script for the location. |
| 1287 // In this case we could have an extension (or an internal error | 1318 // In this case we could have an extension (or an internal error |
| 1288 // somewhere) and we print out the line number at which the error occured | 1319 // somewhere) and we print out the line number at which the error occured |
| 1289 // to the console for easier debugging. | 1320 // to the console for easier debugging. |
| 1290 int line_number = GetScriptLineNumberSafe(location->script(), | 1321 int line_number = GetScriptLineNumberSafe(location->script(), |
| 1291 location->start_pos()); | 1322 location->start_pos()); |
| 1292 if (exception->IsString()) { | 1323 if (exception->IsString()) { |
| 1293 OS::PrintError( | 1324 OS::PrintError( |
| (...skipping 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2365 | 2396 |
| 2366 #ifdef DEBUG | 2397 #ifdef DEBUG |
| 2367 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ | 2398 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ |
| 2368 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); | 2399 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); |
| 2369 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) | 2400 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) |
| 2370 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) | 2401 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) |
| 2371 #undef ISOLATE_FIELD_OFFSET | 2402 #undef ISOLATE_FIELD_OFFSET |
| 2372 #endif | 2403 #endif |
| 2373 | 2404 |
| 2374 } } // namespace v8::internal | 2405 } } // namespace v8::internal |
| OLD | NEW |