| 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 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 stacktrace.SetCatchStacktrace(catch_func_array, | 405 stacktrace.SetCatchStacktrace(catch_func_array, |
| 406 catch_code_array, | 406 catch_code_array, |
| 407 catch_pc_offset_array); | 407 catch_pc_offset_array); |
| 408 if (exception.GetField(stacktrace_field) == Object::null()) { | 408 if (exception.GetField(stacktrace_field) == Object::null()) { |
| 409 exception.SetField(stacktrace_field, stacktrace); | 409 exception.SetField(stacktrace_field, stacktrace); |
| 410 } | 410 } |
| 411 } | 411 } |
| 412 // TODO(5411263): At some point we can optimize by figuring out if a | 412 // TODO(5411263): At some point we can optimize by figuring out if a |
| 413 // stack trace is needed based on whether the catch code specifies a | 413 // stack trace is needed based on whether the catch code specifies a |
| 414 // stack trace object or there is a rethrow in the catch clause. | 414 // stack trace object or there is a rethrow in the catch clause. |
| 415 if (pc_offset_array.Length() != 0) { | 415 if (existing_stacktrace.IsNull()) { |
| 416 if (existing_stacktrace.IsNull()) { | |
| 417 stacktrace = Stacktrace::New(func_array, code_array, pc_offset_array); | 416 stacktrace = Stacktrace::New(func_array, code_array, pc_offset_array); |
| 418 } else { | |
| 419 stacktrace ^= existing_stacktrace.raw(); | |
| 420 stacktrace.Append(func_array, code_array, pc_offset_array); | |
| 421 // Since we are re throwing and appending to the existing stack trace | |
| 422 // we clear out the catch trace collected in the existing stack trace | |
| 423 // as that trace will not be valid anymore. | |
| 424 stacktrace.SetCatchStacktrace(Object::empty_array(), | |
| 425 Object::empty_array(), | |
| 426 Object::empty_array()); | |
| 427 } | |
| 428 } else { | 417 } else { |
| 429 stacktrace ^= existing_stacktrace.raw(); | 418 stacktrace ^= existing_stacktrace.raw(); |
| 419 if (pc_offset_array.Length() != 0) { |
| 420 stacktrace.Append(func_array, code_array, pc_offset_array); |
| 421 } |
| 430 // Since we are re throwing and appending to the existing stack trace | 422 // Since we are re throwing and appending to the existing stack trace |
| 431 // we clear out the catch trace collected in the existing stack trace | 423 // we clear out the catch trace collected in the existing stack trace |
| 432 // as that trace will not be valid anymore. | 424 // as that trace will not be valid anymore. |
| 433 stacktrace.SetCatchStacktrace(Object::empty_array(), | 425 stacktrace.SetCatchStacktrace(Object::empty_array(), |
| 434 Object::empty_array(), | 426 Object::empty_array(), |
| 435 Object::empty_array()); | 427 Object::empty_array()); |
| 436 } | 428 } |
| 437 } | 429 } |
| 438 // We expect to find a handler_pc, if the exception is unhandled | 430 // We expect to find a handler_pc, if the exception is unhandled |
| 439 // then we expect to at least have the dart entry frame on the | 431 // then we expect to at least have the dart entry frame on the |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 break; | 702 break; |
| 711 } | 703 } |
| 712 | 704 |
| 713 return DartLibraryCalls::InstanceCreate(library, | 705 return DartLibraryCalls::InstanceCreate(library, |
| 714 *class_name, | 706 *class_name, |
| 715 *constructor_name, | 707 *constructor_name, |
| 716 arguments); | 708 arguments); |
| 717 } | 709 } |
| 718 | 710 |
| 719 } // namespace dart | 711 } // namespace dart |
| OLD | NEW |