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 "src/isolate.h" | 5 #include "src/isolate.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 | 8 |
9 #include <fstream> // NOLINT(readability/streams) | 9 #include <fstream> // NOLINT(readability/streams) |
10 #include <sstream> | 10 #include <sstream> |
(...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1065 | 1065 |
1066 Object* Isolate::Throw(Object* exception, MessageLocation* location) { | 1066 Object* Isolate::Throw(Object* exception, MessageLocation* location) { |
1067 DCHECK(!has_pending_exception()); | 1067 DCHECK(!has_pending_exception()); |
1068 | 1068 |
1069 HandleScope scope(this); | 1069 HandleScope scope(this); |
1070 Handle<Object> exception_handle(exception, this); | 1070 Handle<Object> exception_handle(exception, this); |
1071 | 1071 |
1072 if (FLAG_print_all_exceptions) { | 1072 if (FLAG_print_all_exceptions) { |
1073 printf("=========================================================\n"); | 1073 printf("=========================================================\n"); |
1074 printf("Exception thrown:\n"); | 1074 printf("Exception thrown:\n"); |
| 1075 if (location) { |
| 1076 Handle<Script> script = location->script(); |
| 1077 Handle<Object> name = Script::GetNameOrSourceURL(script); |
| 1078 printf("at "); |
| 1079 if (name->IsString() && String::cast(*name)->length() > 0) |
| 1080 String::cast(*name)->PrintOn(stdout); |
| 1081 else |
| 1082 printf("<anonymous>"); |
| 1083 // Script::GetLineNumber and Script::GetColumnNumber can allocate on the heap to |
| 1084 // initialize the line_ends array, so be careful when calling them. |
| 1085 #ifdef DEBUG |
| 1086 if (AllowHeapAllocation::IsAllowed()) { |
| 1087 #else |
| 1088 if (false) { |
| 1089 #endif |
| 1090 printf(", %d:%d - %d:%d\n", |
| 1091 Script::GetLineNumber(script, location->start_pos()) + 1, |
| 1092 Script::GetColumnNumber(script, location->start_pos()), |
| 1093 Script::GetLineNumber(script, location->end_pos()) + 1, |
| 1094 Script::GetColumnNumber(script, location->end_pos())); |
| 1095 } else { |
| 1096 printf(", line %d\n", script->GetLineNumber(location->start_pos()) + 1); |
| 1097 } |
| 1098 } |
1075 exception->Print(); | 1099 exception->Print(); |
1076 printf("Stack Trace:\n"); | 1100 printf("Stack Trace:\n"); |
1077 PrintStack(stdout); | 1101 PrintStack(stdout); |
1078 printf("=========================================================\n"); | 1102 printf("=========================================================\n"); |
1079 } | 1103 } |
1080 | 1104 |
1081 // Determine whether a message needs to be created for the given exception | 1105 // Determine whether a message needs to be created for the given exception |
1082 // depending on the following criteria: | 1106 // depending on the following criteria: |
1083 // 1) External v8::TryCatch missing: Always create a message because any | 1107 // 1) External v8::TryCatch missing: Always create a message because any |
1084 // JavaScript handler for a finally-block might re-throw to top-level. | 1108 // JavaScript handler for a finally-block might re-throw to top-level. |
(...skipping 2379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3464 // Then check whether this scope intercepts. | 3488 // Then check whether this scope intercepts. |
3465 if ((flag & intercept_mask_)) { | 3489 if ((flag & intercept_mask_)) { |
3466 intercepted_flags_ |= flag; | 3490 intercepted_flags_ |= flag; |
3467 return true; | 3491 return true; |
3468 } | 3492 } |
3469 return false; | 3493 return false; |
3470 } | 3494 } |
3471 | 3495 |
3472 } // namespace internal | 3496 } // namespace internal |
3473 } // namespace v8 | 3497 } // namespace v8 |
OLD | NEW |