Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(382)

Side by Side Diff: src/isolate.cc

Issue 11365200: Correctly handle uncaught exception objects. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1210 matching lines...) Expand 10 before | Expand all | Expand 10 after
1221 stack_trace_object = Handle<JSArray>(JSArray::cast(stack_property)); 1221 stack_trace_object = Handle<JSArray>(JSArray::cast(stack_property));
1222 } 1222 }
1223 } 1223 }
1224 if (stack_trace_object.is_null()) { 1224 if (stack_trace_object.is_null()) {
1225 // Not an error object, we capture at throw site. 1225 // Not an error object, we capture at throw site.
1226 stack_trace_object = CaptureCurrentStackTrace( 1226 stack_trace_object = CaptureCurrentStackTrace(
1227 stack_trace_for_uncaught_exceptions_frame_limit_, 1227 stack_trace_for_uncaught_exceptions_frame_limit_,
1228 stack_trace_for_uncaught_exceptions_options_); 1228 stack_trace_for_uncaught_exceptions_options_);
1229 } 1229 }
1230 } 1230 }
1231 // Stringify custom error objects for the message object. 1231
1232 Handle<Object> exception_arg = exception_handle;
1233 // If the exception argument is a custom object, turn it into a string
1234 // before throwing as uncaught exception. Note that the pending
1235 // exception object to be set later must not be turned into a string.
1232 if (exception_handle->IsJSObject() && !IsErrorObject(exception_handle)) { 1236 if (exception_handle->IsJSObject() && !IsErrorObject(exception_handle)) {
1233 bool failed = false; 1237 bool failed = false;
1234 exception_handle = Execution::ToString(exception_handle, &failed); 1238 exception_arg = Execution::ToString(exception_arg, &failed);
1235 if (failed) { 1239 if (failed) {
1236 exception_handle = factory()->LookupAsciiSymbol("exception"); 1240 exception_arg = factory()->LookupAsciiSymbol("exception");
1237 } 1241 }
1238 } 1242 }
1239 Handle<Object> message_obj = MessageHandler::MakeMessageObject( 1243 Handle<Object> message_obj = MessageHandler::MakeMessageObject(
1240 "uncaught_exception", 1244 "uncaught_exception",
1241 location, 1245 location,
1242 HandleVector<Object>(&exception_handle, 1), 1246 HandleVector<Object>(&exception_arg, 1),
1243 stack_trace, 1247 stack_trace,
1244 stack_trace_object); 1248 stack_trace_object);
1245 thread_local_top()->pending_message_obj_ = *message_obj; 1249 thread_local_top()->pending_message_obj_ = *message_obj;
1246 if (location != NULL) { 1250 if (location != NULL) {
1247 thread_local_top()->pending_message_script_ = *location->script(); 1251 thread_local_top()->pending_message_script_ = *location->script();
1248 thread_local_top()->pending_message_start_pos_ = location->start_pos(); 1252 thread_local_top()->pending_message_start_pos_ = location->start_pos();
1249 thread_local_top()->pending_message_end_pos_ = location->end_pos(); 1253 thread_local_top()->pending_message_end_pos_ = location->end_pos();
1250 } 1254 }
1251 } else if (location != NULL && !location->script().is_null()) { 1255 } else if (location != NULL && !location->script().is_null()) {
1252 // We are bootstrapping and caught an error where the location is set 1256 // We are bootstrapping and caught an error where the location is set
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after
2156 2160
2157 #ifdef DEBUG 2161 #ifdef DEBUG
2158 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ 2162 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \
2159 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); 2163 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_);
2160 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) 2164 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET)
2161 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) 2165 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET)
2162 #undef ISOLATE_FIELD_OFFSET 2166 #undef ISOLATE_FIELD_OFFSET
2163 #endif 2167 #endif
2164 2168
2165 } } // namespace v8::internal 2169 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698