Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(347)

Side by Side Diff: runtime/lib/errors.cc

Issue 2845053003: Fix asserts in StackFrameIterator which were effectively disabled (Closed)
Patch Set: remote two assertions which cannot be made Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | runtime/lib/object.cc » ('j') | runtime/vm/debugger.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 // No need to type check the arguments. This function can only be called 68 // No need to type check the arguments. This function can only be called
69 // internally from the VM. 69 // internally from the VM.
70 const TokenPosition assertion_start = 70 const TokenPosition assertion_start =
71 TokenPosition(Smi::CheckedHandle(arguments->NativeArgAt(0)).Value()); 71 TokenPosition(Smi::CheckedHandle(arguments->NativeArgAt(0)).Value());
72 const TokenPosition assertion_end = 72 const TokenPosition assertion_end =
73 TokenPosition(Smi::CheckedHandle(arguments->NativeArgAt(1)).Value()); 73 TokenPosition(Smi::CheckedHandle(arguments->NativeArgAt(1)).Value());
74 74
75 const Instance& message = Instance::CheckedHandle(arguments->NativeArgAt(2)); 75 const Instance& message = Instance::CheckedHandle(arguments->NativeArgAt(2));
76 const Array& args = Array::Handle(Array::New(5)); 76 const Array& args = Array::Handle(Array::New(5));
77 77
78 DartFrameIterator iterator; 78 DartFrameIterator iterator(thread, false);
Vyacheslav Egorov (Google) 2017/05/01 15:54:38 I suggest that this false needs a name. thread,
kustermann 2017/05/02 07:11:18 Made both bools an enum
79 iterator.NextFrame(); // Skip native call. 79 iterator.NextFrame(); // Skip native call.
80 const Script& script = Script::Handle(FindScript(&iterator)); 80 const Script& script = Script::Handle(FindScript(&iterator));
81 81
82 // Initialize argument 'failed_assertion' with source snippet. 82 // Initialize argument 'failed_assertion' with source snippet.
83 intptr_t from_line, from_column; 83 intptr_t from_line, from_column;
84 script.GetTokenLocation(assertion_start, &from_line, &from_column); 84 script.GetTokenLocation(assertion_start, &from_line, &from_column);
85 intptr_t to_line, to_column; 85 intptr_t to_line, to_column;
86 script.GetTokenLocation(assertion_end, &to_line, &to_column); 86 script.GetTokenLocation(assertion_end, &to_line, &to_column);
87 // The snippet will extract the correct assertion code even if the source 87 // The snippet will extract the correct assertion code even if the source
88 // is generated. 88 // is generated.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 // Allocate and throw a new FallThroughError. 132 // Allocate and throw a new FallThroughError.
133 // Arg0: index of the case clause token into which we fall through. 133 // Arg0: index of the case clause token into which we fall through.
134 // Return value: none, throws an exception. 134 // Return value: none, throws an exception.
135 DEFINE_NATIVE_ENTRY(FallThroughError_throwNew, 1) { 135 DEFINE_NATIVE_ENTRY(FallThroughError_throwNew, 1) {
136 GET_NON_NULL_NATIVE_ARGUMENT(Smi, smi_pos, arguments->NativeArgAt(0)); 136 GET_NON_NULL_NATIVE_ARGUMENT(Smi, smi_pos, arguments->NativeArgAt(0));
137 TokenPosition fallthrough_pos = TokenPosition(smi_pos.Value()); 137 TokenPosition fallthrough_pos = TokenPosition(smi_pos.Value());
138 138
139 const Array& args = Array::Handle(Array::New(2)); 139 const Array& args = Array::Handle(Array::New(2));
140 140
141 // Initialize 'url' and 'line' arguments. 141 // Initialize 'url' and 'line' arguments.
142 DartFrameIterator iterator; 142 DartFrameIterator iterator(thread, false);
143 iterator.NextFrame(); // Skip native call. 143 iterator.NextFrame(); // Skip native call.
144 const Script& script = Script::Handle(Exceptions::GetCallerScript(&iterator)); 144 const Script& script = Script::Handle(Exceptions::GetCallerScript(&iterator));
145 args.SetAt(0, String::Handle(script.url())); 145 args.SetAt(0, String::Handle(script.url()));
146 intptr_t line; 146 intptr_t line;
147 script.GetTokenLocation(fallthrough_pos, &line, NULL); 147 script.GetTokenLocation(fallthrough_pos, &line, NULL);
148 args.SetAt(1, Smi::Handle(Smi::New(line))); 148 args.SetAt(1, Smi::Handle(Smi::New(line)));
149 149
150 Exceptions::ThrowByType(Exceptions::kFallThrough, args); 150 Exceptions::ThrowByType(Exceptions::kFallThrough, args);
151 UNREACHABLE(); 151 UNREACHABLE();
152 return Object::null(); 152 return Object::null();
153 } 153 }
154 154
155 155
156 // Allocate and throw a new AbstractClassInstantiationError. 156 // Allocate and throw a new AbstractClassInstantiationError.
157 // Arg0: Token position of allocation statement. 157 // Arg0: Token position of allocation statement.
158 // Arg1: class name of the abstract class that cannot be instantiated. 158 // Arg1: class name of the abstract class that cannot be instantiated.
159 // Return value: none, throws an exception. 159 // Return value: none, throws an exception.
160 DEFINE_NATIVE_ENTRY(AbstractClassInstantiationError_throwNew, 2) { 160 DEFINE_NATIVE_ENTRY(AbstractClassInstantiationError_throwNew, 2) {
161 GET_NON_NULL_NATIVE_ARGUMENT(Smi, smi_pos, arguments->NativeArgAt(0)); 161 GET_NON_NULL_NATIVE_ARGUMENT(Smi, smi_pos, arguments->NativeArgAt(0));
162 GET_NON_NULL_NATIVE_ARGUMENT(String, class_name, arguments->NativeArgAt(1)); 162 GET_NON_NULL_NATIVE_ARGUMENT(String, class_name, arguments->NativeArgAt(1));
163 TokenPosition error_pos = TokenPosition(smi_pos.Value()); 163 TokenPosition error_pos = TokenPosition(smi_pos.Value());
164 164
165 const Array& args = Array::Handle(Array::New(3)); 165 const Array& args = Array::Handle(Array::New(3));
166 166
167 // Initialize 'className', 'url' and 'line' arguments. 167 // Initialize 'className', 'url' and 'line' arguments.
168 DartFrameIterator iterator; 168 DartFrameIterator iterator(thread, false);
169 iterator.NextFrame(); // Skip native call. 169 iterator.NextFrame(); // Skip native call.
170 const Script& script = Script::Handle(Exceptions::GetCallerScript(&iterator)); 170 const Script& script = Script::Handle(Exceptions::GetCallerScript(&iterator));
171 args.SetAt(0, class_name); 171 args.SetAt(0, class_name);
172 args.SetAt(1, String::Handle(script.url())); 172 args.SetAt(1, String::Handle(script.url()));
173 intptr_t line; 173 intptr_t line;
174 script.GetTokenLocation(error_pos, &line, NULL); 174 script.GetTokenLocation(error_pos, &line, NULL);
175 args.SetAt(2, Smi::Handle(Smi::New(line))); 175 args.SetAt(2, Smi::Handle(Smi::New(line)));
176 176
177 Exceptions::ThrowByType(Exceptions::kAbstractClassInstantiation, args); 177 Exceptions::ThrowByType(Exceptions::kAbstractClassInstantiation, args);
178 UNREACHABLE(); 178 UNREACHABLE();
179 return Object::null(); 179 return Object::null();
180 } 180 }
181 181
182 // Rethrow an error with a stacktrace. 182 // Rethrow an error with a stacktrace.
183 DEFINE_NATIVE_ENTRY(Async_rethrow, 2) { 183 DEFINE_NATIVE_ENTRY(Async_rethrow, 2) {
184 GET_NON_NULL_NATIVE_ARGUMENT(Instance, error, arguments->NativeArgAt(0)); 184 GET_NON_NULL_NATIVE_ARGUMENT(Instance, error, arguments->NativeArgAt(0));
185 GET_NON_NULL_NATIVE_ARGUMENT(Instance, stacktrace, arguments->NativeArgAt(1)); 185 GET_NON_NULL_NATIVE_ARGUMENT(Instance, stacktrace, arguments->NativeArgAt(1));
186 Exceptions::ReThrow(thread, error, stacktrace); 186 Exceptions::ReThrow(thread, error, stacktrace);
187 return Object::null(); 187 return Object::null();
188 } 188 }
189 189
190 } // namespace dart 190 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/object.cc » ('j') | runtime/vm/debugger.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698