| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/exceptions.h" | 5 #include "vm/exceptions.h" |
| 6 | 6 |
| 7 #include "vm/dart_api_impl.h" | 7 #include "vm/dart_api_impl.h" |
| 8 #include "vm/dart_entry.h" | 8 #include "vm/dart_entry.h" |
| 9 #include "vm/debugger.h" | 9 #include "vm/debugger.h" |
| 10 #include "vm/flags.h" | 10 #include "vm/flags.h" |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 // stack as Exceptions::Throw should happen only after a dart | 196 // stack as Exceptions::Throw should happen only after a dart |
| 197 // invocation has been done. | 197 // invocation has been done. |
| 198 ASSERT(handler_pc != 0); | 198 ASSERT(handler_pc != 0); |
| 199 | 199 |
| 200 // TODO(5411263): At some point we can optimize by figuring out if a | 200 // TODO(5411263): At some point we can optimize by figuring out if a |
| 201 // stack trace is needed based on whether the catch code specifies a | 201 // stack trace is needed based on whether the catch code specifies a |
| 202 // stack trace object or there is a rethrow in the catch clause. | 202 // stack trace object or there is a rethrow in the catch clause. |
| 203 Stacktrace& stacktrace = Stacktrace::Handle(); | 203 Stacktrace& stacktrace = Stacktrace::Handle(); |
| 204 if (pc_offset_list.Length() != 0) { | 204 if (pc_offset_list.Length() != 0) { |
| 205 if (existing_stacktrace.IsNull()) { | 205 if (existing_stacktrace.IsNull()) { |
| 206 stacktrace = Stacktrace::New(func_list, code_list, pc_offset_list); | 206 const Array& func_array = Array::Handle(Array::MakeArray(func_list)); |
| 207 const Array& code_array = Array::Handle(Array::MakeArray(code_list)); |
| 208 const Array& pc_offset_array = |
| 209 Array::Handle(Array::MakeArray(pc_offset_list)); |
| 210 |
| 211 stacktrace = Stacktrace::New(func_array, code_array, pc_offset_array); |
| 207 } else { | 212 } else { |
| 208 stacktrace ^= existing_stacktrace.raw(); | 213 stacktrace ^= existing_stacktrace.raw(); |
| 209 stacktrace.Append(func_list, code_list, pc_offset_list); | 214 stacktrace.Append(func_list, code_list, pc_offset_list); |
| 215 // Since we are re throwing and appending to the existing stack trace |
| 216 // we clear out the catch trace collected in the existing stack trace |
| 217 // as that trace will not be valid anymore. |
| 218 stacktrace.SetCatchStacktrace(Object::empty_array(), |
| 219 Object::empty_array(), |
| 220 Object::empty_array()); |
| 210 } | 221 } |
| 211 } else { | 222 } else { |
| 212 stacktrace ^= existing_stacktrace.raw(); | 223 stacktrace ^= existing_stacktrace.raw(); |
| 224 // Since we are re throwing the existing stack trace |
| 225 // we clear out the catch trace collected in it |
| 226 // as that trace will not be valid anymore. |
| 227 stacktrace.SetCatchStacktrace(Object::empty_array(), |
| 228 Object::empty_array(), |
| 229 Object::empty_array()); |
| 213 } | 230 } |
| 214 if (FLAG_print_stacktrace_at_throw) { | 231 if (FLAG_print_stacktrace_at_throw) { |
| 215 OS::Print("Exception '%s' thrown:\n", exception.ToCString()); | 232 OS::Print("Exception '%s' thrown:\n", exception.ToCString()); |
| 216 OS::Print("%s\n", stacktrace.ToCString()); | 233 OS::Print("%s\n", stacktrace.ToCString()); |
| 217 } | 234 } |
| 218 if (handler_exists) { | 235 if (handler_exists) { |
| 219 // Found a dart handler for the exception, jump to it. | 236 // Found a dart handler for the exception, jump to it. |
| 220 JumpToExceptionHandler(handler_pc, | 237 JumpToExceptionHandler(handler_pc, |
| 221 handler_sp, | 238 handler_sp, |
| 222 handler_fp, | 239 handler_fp, |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 break; | 497 break; |
| 481 } | 498 } |
| 482 | 499 |
| 483 return DartLibraryCalls::ExceptionCreate(library, | 500 return DartLibraryCalls::ExceptionCreate(library, |
| 484 *class_name, | 501 *class_name, |
| 485 *constructor_name, | 502 *constructor_name, |
| 486 arguments); | 503 arguments); |
| 487 } | 504 } |
| 488 | 505 |
| 489 } // namespace dart | 506 } // namespace dart |
| OLD | NEW |