| 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 #include "vm/symbols.h" | 10 #include "vm/symbols.h" |
| 11 | 11 |
| 12 namespace dart { | 12 namespace dart { |
| 13 | 13 |
| 14 // Scan the stack until we hit the first function in the _AssertionError | 14 // Scan the stack until we hit the first function in the _AssertionError |
| 15 // class. We then return the next frame's script taking inlining into account. | 15 // class. We then return the next frame's script taking inlining into account. |
| 16 static RawScript* FindScript(DartFrameIterator* iterator) { | 16 static RawScript* FindScript(DartFrameIterator* iterator) { |
| 17 #if defined(DART_PRECOMPILED_RUNTIME) | 17 if (FLAG_precompiled_runtime) { |
| 18 // The precompiled runtime faces two issues in recovering the correct | 18 // The precompiled runtime faces two issues in recovering the correct |
| 19 // assertion text. First, the precompiled runtime does not include | 19 // assertion text. First, the precompiled runtime does not include |
| 20 // the inlining meta-data so we cannot walk the inline-aware stack trace. | 20 // the inlining meta-data so we cannot walk the inline-aware stack trace. |
| 21 // Second, the script text itself is missing so whatever script is returned | 21 // Second, the script text itself is missing so whatever script is returned |
| 22 // from here will be missing the assertion expression text. | 22 // from here will be missing the assertion expression text. |
| 23 iterator->NextFrame(); // Skip _AssertionError._evaluateAssertion frame | 23 iterator->NextFrame(); // Skip _AssertionError._evaluateAssertion frame |
| 24 return Exceptions::GetCallerScript(iterator); | 24 return Exceptions::GetCallerScript(iterator); |
| 25 #else | 25 } |
| 26 StackFrame* stack_frame = iterator->NextFrame(); | 26 StackFrame* stack_frame = iterator->NextFrame(); |
| 27 Code& code = Code::Handle(); | 27 Code& code = Code::Handle(); |
| 28 Function& func = Function::Handle(); | 28 Function& func = Function::Handle(); |
| 29 const Class& assert_error_class = | 29 const Class& assert_error_class = |
| 30 Class::Handle(Library::LookupCoreClass(Symbols::AssertionError())); | 30 Class::Handle(Library::LookupCoreClass(Symbols::AssertionError())); |
| 31 ASSERT(!assert_error_class.IsNull()); | 31 ASSERT(!assert_error_class.IsNull()); |
| 32 bool hit_assertion_error = false; | 32 bool hit_assertion_error = false; |
| 33 while (stack_frame != NULL) { | 33 while (stack_frame != NULL) { |
| 34 code ^= stack_frame->LookupDartCode(); | 34 code ^= stack_frame->LookupDartCode(); |
| 35 if (code.is_optimized()) { | 35 if (code.is_optimized()) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 49 if (hit_assertion_error) { | 49 if (hit_assertion_error) { |
| 50 return func.script(); | 50 return func.script(); |
| 51 } | 51 } |
| 52 ASSERT(!hit_assertion_error); | 52 ASSERT(!hit_assertion_error); |
| 53 hit_assertion_error = (func.Owner() == assert_error_class.raw()); | 53 hit_assertion_error = (func.Owner() == assert_error_class.raw()); |
| 54 } | 54 } |
| 55 stack_frame = iterator->NextFrame(); | 55 stack_frame = iterator->NextFrame(); |
| 56 } | 56 } |
| 57 UNREACHABLE(); | 57 UNREACHABLE(); |
| 58 return Script::null(); | 58 return Script::null(); |
| 59 #endif // defined(DART_PRECOMPILED_RUNTIME) | |
| 60 } | 59 } |
| 61 | 60 |
| 62 // Allocate and throw a new AssertionError. | 61 // Allocate and throw a new AssertionError. |
| 63 // Arg0: index of the first token of the failed assertion. | 62 // Arg0: index of the first token of the failed assertion. |
| 64 // Arg1: index of the first token after the failed assertion. | 63 // Arg1: index of the first token after the failed assertion. |
| 65 // Arg2: Message object or null. | 64 // Arg2: Message object or null. |
| 66 // Return value: none, throws an exception. | 65 // Return value: none, throws an exception. |
| 67 DEFINE_NATIVE_ENTRY(AssertionError_throwNew, 3) { | 66 DEFINE_NATIVE_ENTRY(AssertionError_throwNew, 3) { |
| 68 // No need to type check the arguments. This function can only be called | 67 // No need to type check the arguments. This function can only be called |
| 69 // internally from the VM. | 68 // internally from the VM. |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 | 180 |
| 182 // Rethrow an error with a stacktrace. | 181 // Rethrow an error with a stacktrace. |
| 183 DEFINE_NATIVE_ENTRY(Async_rethrow, 2) { | 182 DEFINE_NATIVE_ENTRY(Async_rethrow, 2) { |
| 184 GET_NON_NULL_NATIVE_ARGUMENT(Instance, error, arguments->NativeArgAt(0)); | 183 GET_NON_NULL_NATIVE_ARGUMENT(Instance, error, arguments->NativeArgAt(0)); |
| 185 GET_NON_NULL_NATIVE_ARGUMENT(Instance, stacktrace, arguments->NativeArgAt(1)); | 184 GET_NON_NULL_NATIVE_ARGUMENT(Instance, stacktrace, arguments->NativeArgAt(1)); |
| 186 Exceptions::ReThrow(thread, error, stacktrace); | 185 Exceptions::ReThrow(thread, error, stacktrace); |
| 187 return Object::null(); | 186 return Object::null(); |
| 188 } | 187 } |
| 189 | 188 |
| 190 } // namespace dart | 189 } // namespace dart |
| OLD | NEW |