| 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/cpu.h" | 7 #include "vm/cpu.h" |
| 8 #include "vm/dart_entry.h" | 8 #include "vm/dart_entry.h" |
| 9 #include "vm/flags.h" | 9 #include "vm/flags.h" |
| 10 #include "vm/object.h" | 10 #include "vm/object.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 uword handler_sp = 0; | 52 uword handler_sp = 0; |
| 53 uword handler_fp = 0; | 53 uword handler_fp = 0; |
| 54 GrowableArray<uword> stack_frame_pcs; | 54 GrowableArray<uword> stack_frame_pcs; |
| 55 bool handler_exists = FindExceptionHandler(&handler_pc, | 55 bool handler_exists = FindExceptionHandler(&handler_pc, |
| 56 &handler_sp, | 56 &handler_sp, |
| 57 &handler_fp, | 57 &handler_fp, |
| 58 &stack_frame_pcs); | 58 &stack_frame_pcs); |
| 59 // TODO(5411263): At some point we can optimize by figuring out if a | 59 // TODO(5411263): At some point we can optimize by figuring out if a |
| 60 // stack trace is needed based on whether the catch code specifies a | 60 // stack trace is needed based on whether the catch code specifies a |
| 61 // stack trace object or there is a rethrow in the catch clause. | 61 // stack trace object or there is a rethrow in the catch clause. |
| 62 ASSERT(stack_frame_pcs.length() > 0); // At least one dart frame must exist. | |
| 63 Stacktrace& stacktrace = Stacktrace::Handle(); | 62 Stacktrace& stacktrace = Stacktrace::Handle(); |
| 64 if (existing_stacktrace.IsNull()) { | 63 if (stack_frame_pcs.length() > 0) { |
| 65 stacktrace = Stacktrace::New(stack_frame_pcs); | 64 if (existing_stacktrace.IsNull()) { |
| 65 stacktrace = Stacktrace::New(stack_frame_pcs); |
| 66 } else { |
| 67 stacktrace ^= existing_stacktrace.raw(); |
| 68 stacktrace.Append(stack_frame_pcs); |
| 69 } |
| 66 } else { | 70 } else { |
| 67 stacktrace ^= existing_stacktrace.raw(); | 71 stacktrace ^= existing_stacktrace.raw(); |
| 68 stacktrace.Append(stack_frame_pcs); | |
| 69 } | 72 } |
| 70 if (FLAG_print_stack_trace_at_throw) { | 73 if (FLAG_print_stack_trace_at_throw) { |
| 71 OS::Print("Exception '%s' thrown:\n", exception.ToCString()); | 74 OS::Print("Exception '%s' thrown:\n", exception.ToCString()); |
| 72 OS::Print("%s\n", stacktrace.ToCString()); | 75 OS::Print("%s\n", stacktrace.ToCString()); |
| 73 } | 76 } |
| 74 if (handler_exists) { | 77 if (handler_exists) { |
| 75 // Found a dart handler for the exception, jump to it. | 78 // Found a dart handler for the exception, jump to it. |
| 76 CPU::JumpToExceptionHandler(handler_pc, | 79 CPU::JumpToExceptionHandler(handler_pc, |
| 77 handler_sp, | 80 handler_sp, |
| 78 handler_fp, | 81 handler_fp, |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 break; | 155 break; |
| 153 case kIllegalJSRegExp: | 156 case kIllegalJSRegExp: |
| 154 class_name = String::NewSymbol("IllegalJSRegExpException"); | 157 class_name = String::NewSymbol("IllegalJSRegExpException"); |
| 155 break; | 158 break; |
| 156 } | 159 } |
| 157 | 160 |
| 158 return DartLibraryCalls::ExceptionCreate(class_name, arguments); | 161 return DartLibraryCalls::ExceptionCreate(class_name, arguments); |
| 159 } | 162 } |
| 160 | 163 |
| 161 } // namespace dart | 164 } // namespace dart |
| OLD | NEW |