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 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
650 } | 650 } |
651 } | 651 } |
652 | 652 |
653 | 653 |
654 Handle<JSArray> Isolate::CaptureCurrentStackTrace( | 654 Handle<JSArray> Isolate::CaptureCurrentStackTrace( |
655 int frame_limit, StackTrace::StackTraceOptions options) { | 655 int frame_limit, StackTrace::StackTraceOptions options) { |
656 // Ensure no negative values. | 656 // Ensure no negative values. |
657 int limit = Max(frame_limit, 0); | 657 int limit = Max(frame_limit, 0); |
658 Handle<JSArray> stack_trace = factory()->NewJSArray(frame_limit); | 658 Handle<JSArray> stack_trace = factory()->NewJSArray(frame_limit); |
659 | 659 |
660 Handle<String> column_key = factory()->LookupAsciiSymbol("column"); | 660 Handle<String> column_key = |
661 Handle<String> line_key = factory()->LookupAsciiSymbol("lineNumber"); | 661 factory()->LookupOneByteSymbol(STATIC_ASCII_VECTOR("column")); |
662 Handle<String> script_key = factory()->LookupAsciiSymbol("scriptName"); | 662 Handle<String> line_key = |
| 663 factory()->LookupOneByteSymbol(STATIC_ASCII_VECTOR("lineNumber")); |
| 664 Handle<String> script_key = |
| 665 factory()->LookupOneByteSymbol(STATIC_ASCII_VECTOR("scriptName")); |
663 Handle<String> script_name_or_source_url_key = | 666 Handle<String> script_name_or_source_url_key = |
664 factory()->LookupAsciiSymbol("scriptNameOrSourceURL"); | 667 factory()->LookupOneByteSymbol( |
665 Handle<String> function_key = factory()->LookupAsciiSymbol("functionName"); | 668 STATIC_ASCII_VECTOR("scriptNameOrSourceURL")); |
666 Handle<String> eval_key = factory()->LookupAsciiSymbol("isEval"); | 669 Handle<String> function_key = |
| 670 factory()->LookupOneByteSymbol(STATIC_ASCII_VECTOR("functionName")); |
| 671 Handle<String> eval_key = |
| 672 factory()->LookupOneByteSymbol(STATIC_ASCII_VECTOR("isEval")); |
667 Handle<String> constructor_key = | 673 Handle<String> constructor_key = |
668 factory()->LookupAsciiSymbol("isConstructor"); | 674 factory()->LookupOneByteSymbol(STATIC_ASCII_VECTOR("isConstructor")); |
669 | 675 |
670 StackTraceFrameIterator it(this); | 676 StackTraceFrameIterator it(this); |
671 int frames_seen = 0; | 677 int frames_seen = 0; |
672 while (!it.done() && (frames_seen < limit)) { | 678 while (!it.done() && (frames_seen < limit)) { |
673 JavaScriptFrame* frame = it.frame(); | 679 JavaScriptFrame* frame = it.frame(); |
674 // Set initial size to the maximum inlining level + 1 for the outermost | 680 // Set initial size to the maximum inlining level + 1 for the outermost |
675 // function. | 681 // function. |
676 List<FrameSummary> frames(Compiler::kMaxInliningLevels + 1); | 682 List<FrameSummary> frames(Compiler::kMaxInliningLevels + 1); |
677 frame->Summarize(&frames); | 683 frame->Summarize(&frames); |
678 for (int i = frames.length() - 1; i >= 0 && frames_seen < limit; i--) { | 684 for (int i = frames.length() - 1; i >= 0 && frames_seen < limit; i--) { |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1148 } else { | 1154 } else { |
1149 // Report the exception if it isn't caught by JavaScript code. | 1155 // Report the exception if it isn't caught by JavaScript code. |
1150 return handler == NULL; | 1156 return handler == NULL; |
1151 } | 1157 } |
1152 } | 1158 } |
1153 | 1159 |
1154 | 1160 |
1155 bool Isolate::IsErrorObject(Handle<Object> obj) { | 1161 bool Isolate::IsErrorObject(Handle<Object> obj) { |
1156 if (!obj->IsJSObject()) return false; | 1162 if (!obj->IsJSObject()) return false; |
1157 | 1163 |
1158 String* error_key = *(factory()->LookupAsciiSymbol("$Error")); | 1164 String* error_key = |
| 1165 *(factory()->LookupOneByteSymbol(STATIC_ASCII_VECTOR("$Error"))); |
1159 Object* error_constructor = | 1166 Object* error_constructor = |
1160 js_builtins_object()->GetPropertyNoExceptionThrown(error_key); | 1167 js_builtins_object()->GetPropertyNoExceptionThrown(error_key); |
1161 | 1168 |
1162 for (Object* prototype = *obj; !prototype->IsNull(); | 1169 for (Object* prototype = *obj; !prototype->IsNull(); |
1163 prototype = prototype->GetPrototype()) { | 1170 prototype = prototype->GetPrototype()) { |
1164 if (!prototype->IsJSObject()) return false; | 1171 if (!prototype->IsJSObject()) return false; |
1165 if (JSObject::cast(prototype)->map()->constructor() == error_constructor) { | 1172 if (JSObject::cast(prototype)->map()->constructor() == error_constructor) { |
1166 return true; | 1173 return true; |
1167 } | 1174 } |
1168 } | 1175 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1229 } | 1236 } |
1230 | 1237 |
1231 Handle<Object> exception_arg = exception_handle; | 1238 Handle<Object> exception_arg = exception_handle; |
1232 // If the exception argument is a custom object, turn it into a string | 1239 // If the exception argument is a custom object, turn it into a string |
1233 // before throwing as uncaught exception. Note that the pending | 1240 // before throwing as uncaught exception. Note that the pending |
1234 // exception object to be set later must not be turned into a string. | 1241 // exception object to be set later must not be turned into a string. |
1235 if (exception_arg->IsJSObject() && !IsErrorObject(exception_arg)) { | 1242 if (exception_arg->IsJSObject() && !IsErrorObject(exception_arg)) { |
1236 bool failed = false; | 1243 bool failed = false; |
1237 exception_arg = Execution::ToDetailString(exception_arg, &failed); | 1244 exception_arg = Execution::ToDetailString(exception_arg, &failed); |
1238 if (failed) { | 1245 if (failed) { |
1239 exception_arg = factory()->LookupAsciiSymbol("exception"); | 1246 exception_arg = |
| 1247 factory()->LookupOneByteSymbol(STATIC_ASCII_VECTOR("exception")); |
1240 } | 1248 } |
1241 } | 1249 } |
1242 Handle<Object> message_obj = MessageHandler::MakeMessageObject( | 1250 Handle<Object> message_obj = MessageHandler::MakeMessageObject( |
1243 "uncaught_exception", | 1251 "uncaught_exception", |
1244 location, | 1252 location, |
1245 HandleVector<Object>(&exception_arg, 1), | 1253 HandleVector<Object>(&exception_arg, 1), |
1246 stack_trace, | 1254 stack_trace, |
1247 stack_trace_object); | 1255 stack_trace_object); |
1248 thread_local_top()->pending_message_obj_ = *message_obj; | 1256 thread_local_top()->pending_message_obj_ = *message_obj; |
1249 if (location != NULL) { | 1257 if (location != NULL) { |
(...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2177 | 2185 |
2178 #ifdef DEBUG | 2186 #ifdef DEBUG |
2179 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ | 2187 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ |
2180 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); | 2188 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); |
2181 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) | 2189 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) |
2182 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) | 2190 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) |
2183 #undef ISOLATE_FIELD_OFFSET | 2191 #undef ISOLATE_FIELD_OFFSET |
2184 #endif | 2192 #endif |
2185 | 2193 |
2186 } } // namespace v8::internal | 2194 } } // namespace v8::internal |
OLD | NEW |