| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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/bootstrap_natives.h" | 5 #include "vm/bootstrap_natives.h" |
| 6 #include "vm/exceptions.h" | 6 #include "vm/exceptions.h" |
| 7 #include "vm/object_store.h" | 7 #include "vm/object_store.h" |
| 8 #include "vm/runtime_entry.h" | 8 #include "vm/runtime_entry.h" |
| 9 #include "vm/stack_frame.h" | 9 #include "vm/stack_frame.h" |
| 10 | 10 |
| 11 namespace dart { | 11 namespace dart { |
| 12 | 12 |
| 13 DECLARE_FLAG(bool, abort_on_assertion_errors); | |
| 14 | |
| 15 // Allocate and throw a new AssertionError. | 13 // Allocate and throw a new AssertionError. |
| 16 // Arg0: index of the first token of the failed assertion. | 14 // Arg0: index of the first token of the failed assertion. |
| 17 // Arg1: index of the first token after the failed assertion. | 15 // Arg1: index of the first token after the failed assertion. |
| 18 // Return value: none, throws an exception. | 16 // Return value: none, throws an exception. |
| 19 DEFINE_NATIVE_ENTRY(AssertionError_throwNew, 2) { | 17 DEFINE_NATIVE_ENTRY(AssertionError_throwNew, 2) { |
| 20 if (FLAG_abort_on_assertion_errors) { | |
| 21 Exceptions::PrintStackTraceAndAbort("an assertion failure"); | |
| 22 } | |
| 23 | |
| 24 // No need to type check the arguments. This function can only be called | 18 // No need to type check the arguments. This function can only be called |
| 25 // internally from the VM. | 19 // internally from the VM. |
| 26 const TokenPosition assertion_start = | 20 const TokenPosition assertion_start = |
| 27 TokenPosition(Smi::CheckedHandle(arguments->NativeArgAt(0)).Value()); | 21 TokenPosition(Smi::CheckedHandle(arguments->NativeArgAt(0)).Value()); |
| 28 const TokenPosition assertion_end = | 22 const TokenPosition assertion_end = |
| 29 TokenPosition(Smi::CheckedHandle(arguments->NativeArgAt(1)).Value()); | 23 TokenPosition(Smi::CheckedHandle(arguments->NativeArgAt(1)).Value()); |
| 30 | 24 |
| 31 const Array& args = Array::Handle(Array::New(4)); | 25 const Array& args = Array::Handle(Array::New(4)); |
| 32 | 26 |
| 33 DartFrameIterator iterator; | 27 DartFrameIterator iterator; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 | 129 |
| 136 // Rethrow an error with a stacktrace. | 130 // Rethrow an error with a stacktrace. |
| 137 DEFINE_NATIVE_ENTRY(Async_rethrow, 2) { | 131 DEFINE_NATIVE_ENTRY(Async_rethrow, 2) { |
| 138 GET_NON_NULL_NATIVE_ARGUMENT(Instance, error, arguments->NativeArgAt(0)); | 132 GET_NON_NULL_NATIVE_ARGUMENT(Instance, error, arguments->NativeArgAt(0)); |
| 139 GET_NON_NULL_NATIVE_ARGUMENT(Instance, stacktrace, arguments->NativeArgAt(1)); | 133 GET_NON_NULL_NATIVE_ARGUMENT(Instance, stacktrace, arguments->NativeArgAt(1)); |
| 140 Exceptions::ReThrow(thread, error, stacktrace); | 134 Exceptions::ReThrow(thread, error, stacktrace); |
| 141 return Object::null(); | 135 return Object::null(); |
| 142 } | 136 } |
| 143 | 137 |
| 144 } // namespace dart | 138 } // namespace dart |
| OLD | NEW |